28.10.2014 Views

Synergy User Manual and Tutorial. - THE CORE MEMORY

Synergy User Manual and Tutorial. - THE CORE MEMORY

Synergy User Manual and Tutorial. - THE CORE MEMORY

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Synergy</strong> <strong>User</strong> <strong>Manual</strong> <strong>and</strong> <strong>Tutorial</strong><br />

tplength = sizeof(int);<br />

// Set name of entry<br />

strcpy(tpname, "chunk_size");<br />

// Put entry in ts<br />

status = cnf_tsput(tsd, tpname, &chunk_size, tplength);<br />

printf("Master: Sent chunk size\n");<br />

// Send integers to problem tuple space<br />

// Set length of entry to chunk_size + 1 integers<br />

tplength = (chunk_size+1) * sizeof(int);<br />

printf("Master: tplength = %d\n", tplength);<br />

// Prepare <strong>and</strong> send integer arrays into tuple space<br />

printf("Master: Putting 1...%d to problem tuple space\n", N);<br />

if((sendArr = (int *) malloc(tplength)) == NULL)<br />

exit(1);<br />

// Loop until all numbers are sent to workers<br />

remainder = N;<br />

job = 0;<br />

sendNum = 1;<br />

while (remainder > 0) {<br />

if (remainder < chunk_size)<br />

chunk_size = remainder;<br />

remainder = remainder - chunk_size;<br />

job++;<br />

// Set name of entry to job number<br />

sprintf(tpname,"A%d", job);<br />

// Put chunk_size in index zero<br />

sendArr[0] = chunk_size;<br />

printf("Master: Putting %s Size %d\n ", tpname, sendArr[0]);<br />

// Put chunk_size integers in array<br />

for(i=1; i 0){<br />

// Set name of entry to any<br />

strcpy(tpname,"*");<br />

// Get entry from result tuple space<br />

tplength = cnf_tsget(res, tpname, (char *)recdPtr, 0);<br />

printf("Master: Recieved %d from %s\n", recdSum, tpname);<br />

// Add result to total<br />

sumTotal += recdSum;<br />

// Increment counter<br />

}<br />

167

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!