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 />

// Get chunk_size from master<br />

// Set tpname to chunk_size<br />

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

// Read chunk_size from tuple space<br />

status = cnf_tsread(tsd, tpname, &chunk_size, 0);<br />

// Prepare integer array for tuple space exchanges<br />

tplength = (2+chunk_size*N)*sizeof(double);<br />

if ((rows = (double*)malloc(tplength)) == NULL)<br />

exit(-1);<br />

// Loop until terminal signal is recieved<br />

while(1){<br />

// Set entry name to any begins with A<br />

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

// Set length of entry<br />

tplength = cnf_tsget(tsd, tpname, rows, 0);<br />

// Normal recieve<br />

if(tplength > 0){<br />

// Check termination signal<br />

if (!strcmp(tpname, "A-term")){<br />

printf("Worker: Recieved the terminal signal\n");<br />

// Replace the terminal signal in problem ts<br />

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

// Free memory for rows<br />

free(rows);<br />

// Terminate worker<br />

printf("Worker: Terminated\n");<br />

cnf_term();<br />

}<br />

// Get number rows in this chunk from last index<br />

chunk_size = (int)rows[0];<br />

// Convert beginning row of entry to an integer<br />

matrix_row = atoi(&tpname[1]);<br />

printf("Worker: Recieved chunk_size %d matrix_row %d\n",<br />

chunk_size, matrix_row);<br />

// Get beginning worker time<br />

worker_time = wall_clock();<br />

// For each row in chunk_size<br />

// Copy rows from rows to Ai<br />

for(i=0; i

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

Saved successfully!

Ooh no, something went wrong!