void lexer_process(void) { token_t token; token_t (*process_token)(void) = NULL; if (_.eoi_reached) return; _scan(); _flush_buffer(); switch (_cur_char()) { case '\0': process_token = _process_eoi; _.eoi_reached = true; break; case SIGIL_STR_VAR: case SIGIL_INT_VAR: case SIGIL_BOOL_VAR: process_token = _process_variable; break; case DELIMITER_STR: process_token = _process_string; break; default: // identifer if (_char_is_alpha(_cur_char())) { process_token = _process_identifier; break; } // literal unsigned integer without prefix sign if (_char_is_digit(_cur_char())) { process_token = _process_luinteger; break; } // unknown process_token = _process_unknown; } token = process_token(); _set_token(token); }
int main(int argc, char **argv[]) { /* <reference> */ float inSubMat[M][M], outSubMat[M][M], LU[M][M], L[M][M], U[M][M]; int subdist, rowdist, coldist; int i, j, dist, k1, k2, p1, p2, q1, q2, q3; /* </reference> */ double t0, t1; t0 = wall_clock(); for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { if (i == j) { outMat[i][j] = N; } else { outMat[i][j] = 1; } } } /* <master id="234567"> */ _distributor = _open_space("distributor", 0, "234567"); _constructor = _open_space("constructor", 0, "234567"); i = 0; while (i < N) { j = i + M - 1; dist = M; if (j > N-1) { j = N-1; dist = N - i; } /* LU factors for submatrix */ for (k1 = 0; k1 < dist; k1++) { for (k2 = 0; k2 < dist; k2++) { inSubMat[k1][k2] = outMat[i+k1][i+k2]; } } LUFactor(inSubMat, outSubMat, dist); /* update */ for (k1 = 0; k1 < dist; k1++) { for (k2 = 0; k2 < dist; k2++) { outMat[i+k1][i+k2] = outSubMat[k1][k2]; LU[k1][k2] = outSubMat[k1][k2]; } } /* Solve triangles, LZ and WU */ for (k1 = j+1; k1 < N; k1 = k1+M) { k2 = k1 + M - 1; subdist = M; if (k2 > N-1) { k2 = N - 1; subdist = N - k1; } /* Solve LZ */ for (p1 = i; p1 < i+M; p1++) { for (p2 = k1; p2 <= k2; p2++) { inSubMat[p1-i][p2-k1] = outMat[p1][p2]; } } TriangleSolver(LU, inSubMat, outSubMat, subdist, 1); /* update */ for (p1 = i; p1 < i+M; p1++) { for (p2 = k1; p2 <= k2; p2++) { outMat[p1][p2] = outSubMat[p1-i][p2-k1]; } } /* Solve WU */ for (p1 = i; p1 < i+M; p1++) { for (p2 = k1; p2 <= k2; p2++) { inSubMat[p2-k1][p1-i] = outMat[p2][p1]; } } TriangleSolver(LU, inSubMat, outSubMat, subdist, 2); /* update */ for (p1 = i; p1 < i+M; p1++) { for (p2 = k1; p2 <= k2; p2++) { outMat[p2][p1] = outSubMat[p2-k1][p1-i]; } } } _cleanup_space(_distributor, "234567"); _cleanup_space(_constructor, "234567"); /* <token action="SET" idxset="(k1)"/> */ sprintf(_tp_name, "token#%s", "234567"); sprintf(_tp_token, "=(k1:%d~%d,%d:#%d)", j+1, N, 1, M); _tp_size = sizeof(_tp_token); _tokens = _set_token(_distributor, _tp_name, (char *)_tp_token, _tp_size); if (_tokens < 0) exit(-1); /* <send var="i" type="int"/> */ sprintf(_tp_name, "int:i#%s", "234567"); _tp_size = sizeof(int); _tp_i_234567 = &i; _status = _send_data(_distributor, _tp_name, (char *)_tp_i_234567, _tp_size); if (_status < 0) exit(-1); /* <send var="j" type="int"/> */ sprintf(_tp_name, "int:j#%s", "234567"); _tp_size = sizeof(int); _tp_j_234567 = &j; _status = _send_data(_distributor, _tp_name, (char *)_tp_j_234567, _tp_size); if (_status < 0) exit(-1); /* <send var="outMat" type="float[N(i~N)][N(i~N)]"/> */ sprintf(_tp_name, "float(%d)(%d):outMat#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "234567", (i), (N), 1, (i), (N), 1, sizeof(float)); _tp_size = (((N) - (i)) * ((N) - (i))) * sizeof(float); _tp_outMat_234567 = (float *)malloc(_tp_size); for (_x0_234567 = (i), _y0_234567 =0; _x0_234567 < (N); _x0_234567 +=1, _y0_234567 ++) { for (_x1_234567 = (i), _y1_234567 =0; _x1_234567 < (N); _x1_234567 +=1, _y1_234567 ++) { _tp_outMat_234567[_y0_234567 * ((N) - (i)) + _y1_234567] = outMat[_x0_234567][_x1_234567]; } } _status = _send_data(_distributor, _tp_name, (char *)_tp_outMat_234567, _tp_size); if (_status < 0) exit(-1); free(_tp_outMat_234567); /* <read var="outMat" type="float[N(j+1~N)][N(j+1~N)]"/> */ sprintf(_tp_name, "float(%d)(%d):outMat#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "234567", (j+1), (N), 1, (j+1), (N), 1, sizeof(float)); _tp_size = (((N) - (j+1)) * ((N) - (j+1))) * sizeof(float); _tp_outMat_234567 = (float *)malloc(_tp_size); _tp_size = _read_data(_constructor, _tp_name, (char *)_tp_outMat_234567, _tp_size); if (_tp_size < 0) exit(-1); for (_x0_234567 = (j+1), _y0_234567 =0; _x0_234567 < (N); _x0_234567 +=1, _y0_234567 ++) { for (_x1_234567 = (j+1), _y1_234567 =0; _x1_234567 < (N); _x1_234567 +=1, _y1_234567 ++) { outMat[_x0_234567][_x1_234567] = _tp_outMat_234567[_y0_234567 * ((N) - (j+1)) + _y1_234567]; } } free(_tp_outMat_234567); i = i + M; } _close_space(_constructor, "234567", 1); _close_space(_distributor, "234567", 1); /* </master> */ /* for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { printf("%6.3f ", outMat[i][j]); } printf("\n"); } */ t1 = wall_clock() - t0; if (t1>0) printf(" (%f) MFLOPS.\n", (float) 2*N*N*N/3/t1); else printf(" MFLOPS: Not measured.\n"); printf("elapse time = %10.6f\n", t1/1000000); return 0; }
main(int argc, char **argv[]) { /* <reference id="123456"> */ int scalar = 0; double A[N][N], B[N][N], C[N][N]; int i, j, k; /* </reference> */ for (i = 0; i < N ; i++) { for (j = 0; j < N; j++) { A[i][j] = (double) i * j ; B[i][j] = (double) i * j ; C[i][j] = 0; } } /* <master id="123456"> */ _distributor = _open_space("distributor", 0, "123456"); _constructor = _open_space("constructor", 0, "123456"); _cleanup_space(_distributor, "123456"); _cleanup_space(_constructor, "123456"); /* <send var="scalar" type="int" opt="ONCE|XCHG"/> */ sprintf(_tp_name, "int:scalar#%s", "123456"); _tp_size = sizeof(int); _tp_scalar_123456 = &scalar; _status = _send_data(_constructor, _tp_name, (char *)_tp_scalar_123456, _tp_size); if (_status < 0) exit(-1); /* <send var="scalar" type="int" opt="ONCE"/> */ sprintf(_tp_name, "int:scalar#%s", "123456"); _tp_size = sizeof(int); _tp_scalar_123456 = &scalar; _status = _send_data(_distributor, _tp_name, (char *)_tp_scalar_123456, _tp_size); if (_status < 0) exit(-1); /* <send var="A" type="double[N ][N ]" opt="ONCE|XCHG"/> */ sprintf(_tp_name, "double(%d)(%d):A#%s", (N), (N), "123456"); _tp_size = ((N) * (N)) * sizeof(double); _tp_A_123456 = (double *)malloc(_tp_size); for (_x0_123456 = 0; _x0_123456 < (N); _x0_123456 +=1) { for (_x1_123456 = 0; _x1_123456 < (N); _x1_123456 +=1) { _tp_A_123456[_x0_123456 * (N) + _x1_123456] = A[_x0_123456][_x1_123456]; } } _status = _send_data(_constructor, _tp_name, (char *)_tp_A_123456, _tp_size); if (_status < 0) exit(-1); free(_tp_A_123456); /* <send var="A" type="double[N(i:i-1) ][N ]" opt="ONCE|XCHG"/> */ sprintf(_tp_name, "double(%d)(%d):A#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "123456", (_i_start-1), (_i_stop-1), _i_step, 0, (N), 1, sizeof(double)); _tp_size = ((((_i_stop-1) - (_i_start-1) - 1) / _i_step + 1) * (N)) * sizeof(double); _tp_A_123456 = (double *)malloc(_tp_size); for (_x0_123456 = (_i_start-1), _y0_123456 =0; _x0_123456 < (_i_stop-1); _x0_123456 +=_i_step, _y0_123456 ++) { for (_x1_123456 = 0; _x1_123456 < (N); _x1_123456 +=1) { _tp_A_123456[_y0_123456 * (N) + _x1_123456] = A[_x0_123456][_x1_123456]; } } _status = _send_data(_constructor, _tp_name, (char *)_tp_A_123456, _tp_size); if (_status < 0) exit(-1); free(_tp_A_123456); /* <send var="A" type="double[N ][N(k) ]" opt="ONCE"/> */ sprintf(_tp_name, "double(%d)(%d):A#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "123456", 0, (N), 1, _k_start, _k_stop, _k_step, sizeof(double)); _tp_size = ((N) * ((_k_stop - _k_start - 1) / _k_step + 1)) * sizeof(double); _tp_A_123456 = (double *)malloc(_tp_size); for (_x0_123456 = 0; _x0_123456 < (N); _x0_123456 +=1) { for (_x1_123456 = _k_start, _y1_123456 =0; _x1_123456 < _k_stop; _x1_123456 +=_k_step, _y1_123456 ++) { _tp_A_123456[_x0_123456 * ((_k_stop - _k_start - 1) / _k_step + 1) + _y1_123456] = A[_x0_123456][_x1_123456]; } } _status = _send_data(_distributor, _tp_name, (char *)_tp_A_123456, _tp_size); if (_status < 0) exit(-1); free(_tp_A_123456); /* <send var="A" type="double[N(i) ][N(k:$H-1)]" opt="ONCE"/> */ sprintf(_tp_name, "double(%d)(%d):A#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "123456", _i_start, _i_stop, _i_step, _k_stop, (_k_stop-1), _k_step, sizeof(double)); _tp_size = (((_i_stop - _i_start - 1) / _i_step + 1) * (((_k_stop-1) - _k_stop - 1) / _k_step + 1)) * sizeof(double); _tp_A_123456 = (double *)malloc(_tp_size); for (_x0_123456 = _i_start, _y0_123456 =0; _x0_123456 < _i_stop; _x0_123456 +=_i_step, _y0_123456 ++) { for (_x1_123456 = _k_stop, _y1_123456 =0; _x1_123456 < (_k_stop-1); _x1_123456 +=_k_step, _y1_123456 ++) { _tp_A_123456[_y0_123456 * (((_k_stop-1) - _k_stop - 1) / _k_step + 1) + _y1_123456] = A[_x0_123456][_x1_123456]; } } _status = _send_data(_distributor, _tp_name, (char *)_tp_A_123456, _tp_size); if (_status < 0) exit(-1); free(_tp_A_123456); /* <token action="SET" idxset="(i)(k)"/> */ sprintf(_tp_name, "token#%s", "123456"); sprintf(_tp_token, "=(i:%d~%d,%d:#%d)(k:%d~%d,%d:^%d)", 0, N, 1, 100, 0, N, 1, 20); _tp_size = sizeof(_tp_token); _tokens = _set_token(_distributor, _tp_name, (char *)_tp_token, _tp_size); if (_tokens < 0) exit(-1); /* <send var="scalar" type="int" opt="XCHG"/> */ sprintf(_tp_name, "int:scalar#%s", "123456"); _tp_size = sizeof(int); _tp_scalar_123456 = &scalar; _status = _send_data(_constructor, _tp_name, (char *)_tp_scalar_123456, _tp_size); if (_status < 0) exit(-1); /* <send var="scalar" type="int"/> */ sprintf(_tp_name, "int:scalar#%s", "123456"); _tp_size = sizeof(int); _tp_scalar_123456 = &scalar; _status = _send_data(_distributor, _tp_name, (char *)_tp_scalar_123456, _tp_size); if (_status < 0) exit(-1); /* <send var="B" type="double[N ][N ]"/> */ sprintf(_tp_name, "double(%d)(%d):B#%s", (N), (N), "123456"); _tp_size = ((N) * (N)) * sizeof(double); _tp_B_123456 = (double *)malloc(_tp_size); for (_x0_123456 = 0; _x0_123456 < (N); _x0_123456 +=1) { for (_x1_123456 = 0; _x1_123456 < (N); _x1_123456 +=1) { _tp_B_123456[_x0_123456 * (N) + _x1_123456] = B[_x0_123456][_x1_123456]; } } _status = _send_data(_distributor, _tp_name, (char *)_tp_B_123456, _tp_size); if (_status < 0) exit(-1); free(_tp_B_123456); /* <send var="B" type="double[N(i) ][N ]"/> */ sprintf(_tp_name, "double(%d)(%d):B#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "123456", _i_start, _i_stop, _i_step, 0, (N), 1, sizeof(double)); _tp_size = (((_i_stop - _i_start - 1) / _i_step + 1) * (N)) * sizeof(double); _tp_B_123456 = (double *)malloc(_tp_size); for (_x0_123456 = _i_start, _y0_123456 =0; _x0_123456 < _i_stop; _x0_123456 +=_i_step, _y0_123456 ++) { for (_x1_123456 = 0; _x1_123456 < (N); _x1_123456 +=1) { _tp_B_123456[_y0_123456 * (N) + _x1_123456] = B[_x0_123456][_x1_123456]; } } _status = _send_data(_distributor, _tp_name, (char *)_tp_B_123456, _tp_size); if (_status < 0) exit(-1); free(_tp_B_123456); /* <send var="B" type="double[N ][N(k:k-1) ]" opt="XCHG"/> */ sprintf(_tp_name, "double(%d)(%d):B#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "123456", 0, (N), 1, (_k_start-1), (_k_stop-1), _k_step, sizeof(double)); _tp_size = ((N) * (((_k_stop-1) - (_k_start-1) - 1) / _k_step + 1)) * sizeof(double); _tp_B_123456 = (double *)malloc(_tp_size); for (_x0_123456 = 0; _x0_123456 < (N); _x0_123456 +=1) { for (_x1_123456 = (_k_start-1), _y1_123456 =0; _x1_123456 < (_k_stop-1); _x1_123456 +=_k_step, _y1_123456 ++) { _tp_B_123456[_x0_123456 * (((_k_stop-1) - (_k_start-1) - 1) / _k_step + 1) + _y1_123456] = B[_x0_123456][_x1_123456]; } } _status = _send_data(_constructor, _tp_name, (char *)_tp_B_123456, _tp_size); if (_status < 0) exit(-1); free(_tp_B_123456); /* <send var="B" type="double[N(i:$L-1)][N(k) ]" opt="XCHG"/> */ sprintf(_tp_name, "double(%d)(%d):B#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "123456", (_i_start-1), _i_start, _i_step, _k_start, _k_stop, _k_step, sizeof(double)); _tp_size = (((_i_start - (_i_start-1) - 1) / _i_step + 1) * ((_k_stop - _k_start - 1) / _k_step + 1)) * sizeof(double); _tp_B_123456 = (double *)malloc(_tp_size); for (_x0_123456 = (_i_start-1), _y0_123456 =0; _x0_123456 < _i_start; _x0_123456 +=_i_step, _y0_123456 ++) { for (_x1_123456 = _k_start, _y1_123456 =0; _x1_123456 < _k_stop; _x1_123456 +=_k_step, _y1_123456 ++) { _tp_B_123456[_y0_123456 * ((_k_stop - _k_start - 1) / _k_step + 1) + _y1_123456] = B[_x0_123456][_x1_123456]; } } _status = _send_data(_constructor, _tp_name, (char *)_tp_B_123456, _tp_size); if (_status < 0) exit(-1); free(_tp_B_123456); /* <read var="C" type="double[N ][N ]"/> */ sprintf(_tp_name, "double(%d)(%d):C#%s", (N), (N), "123456"); _tp_size = ((N) * (N)) * sizeof(double); _tp_C_123456 = (double *)malloc(_tp_size); _tp_size = _read_data(_constructor, _tp_name, (char *)_tp_C_123456, _tp_size); if (_tp_size < 0) exit(-1); for (_x0_123456 = 0; _x0_123456 < (N); _x0_123456 +=1) { for (_x1_123456 = 0; _x1_123456 < (N); _x1_123456 +=1) { C[_x0_123456][_x1_123456] = _tp_C_123456[_x0_123456 * (N) + _x1_123456]; } } free(_tp_C_123456); /* <read var="C" type="double[N(i:i-1) ][N ]" opt="XCHG"/> */ sprintf(_tp_name, "double(%d)(%d):C#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "123456", (_i_start-1), (_i_stop-1), _i_step, 0, (N), 1, sizeof(double)); _tp_size = ((((_i_stop-1) - (_i_start-1) - 1) / _i_step + 1) * (N)) * sizeof(double); _tp_C_123456 = (double *)malloc(_tp_size); _tp_size = _read_data(_distributor, _tp_name, (char *)_tp_C_123456, _tp_size); if (_tp_size < 0) exit(-1); for (_x0_123456 = (_i_start-1), _y0_123456 =0; _x0_123456 < (_i_stop-1); _x0_123456 +=_i_step, _y0_123456 ++) { for (_x1_123456 = 0; _x1_123456 < (N); _x1_123456 +=1) { C[_x0_123456][_x1_123456] = _tp_C_123456[_y0_123456 * (N) + _x1_123456]; } } free(_tp_C_123456); /* <read var="C" type="double[N ][N(k:k-1) ]" opt="XCHG"/> */ sprintf(_tp_name, "double(%d)(%d):C#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "123456", 0, (N), 1, (_k_start-1), (_k_stop-1), _k_step, sizeof(double)); _tp_size = ((N) * (((_k_stop-1) - (_k_start-1) - 1) / _k_step + 1)) * sizeof(double); _tp_C_123456 = (double *)malloc(_tp_size); _tp_size = _read_data(_distributor, _tp_name, (char *)_tp_C_123456, _tp_size); if (_tp_size < 0) exit(-1); for (_x0_123456 = 0; _x0_123456 < (N); _x0_123456 +=1) { for (_x1_123456 = (_k_start-1), _y1_123456 =0; _x1_123456 < (_k_stop-1); _x1_123456 +=_k_step, _y1_123456 ++) { C[_x0_123456][_x1_123456] = _tp_C_123456[_x0_123456 * (((_k_stop-1) - (_k_start-1) - 1) / _k_step + 1) + _y1_123456]; } } free(_tp_C_123456); /* <read var="C" type="double[N(i:$H-1)][N(k:$L-1)]"/> */ sprintf(_tp_name, "double(%d)(%d):C#%s[%d~%d,%d][%d~%d,%d]@%d", (N), (N), "123456", _i_stop, (_i_stop-1), _i_step, (_k_start-1), _k_start, _k_step, sizeof(double)); _tp_size = ((((_i_stop-1) - _i_stop - 1) / _i_step + 1) * ((_k_start - (_k_start-1) - 1) / _k_step + 1)) * sizeof(double); _tp_C_123456 = (double *)malloc(_tp_size); _tp_size = _read_data(_constructor, _tp_name, (char *)_tp_C_123456, _tp_size); if (_tp_size < 0) exit(-1); for (_x0_123456 = _i_stop, _y0_123456 =0; _x0_123456 < (_i_stop-1); _x0_123456 +=_i_step, _y0_123456 ++) { for (_x1_123456 = (_k_start-1), _y1_123456 =0; _x1_123456 < _k_start; _x1_123456 +=_k_step, _y1_123456 ++) { C[_x0_123456][_x1_123456] = _tp_C_123456[_y0_123456 * ((_k_start - (_k_start-1) - 1) / _k_step + 1) + _y1_123456]; } } free(_tp_C_123456); /* <read var="scalar" type="int" opt="_MAX|XCHG"/> */ sprintf(_tp_name, "int:scalar#%s?MAX@%d", "123456", _tokens); _tp_size = sizeof(int); _tp_scalar_123456 = &scalar; _tp_size = _read_data(_distributor, _tp_name, (char *)_tp_scalar_123456, _tp_size); if (_tp_size < 0) exit(-1); /* <read var="scalar" type="int" opt="_MIN"/> */ sprintf(_tp_name, "int:scalar#%s?MIN@%d", "123456", _tokens); _tp_size = sizeof(int); _tp_scalar_123456 = &scalar; _tp_size = _read_data(_constructor, _tp_name, (char *)_tp_scalar_123456, _tp_size); if (_tp_size < 0) exit(-1); _close_space(_constructor, "123456", 1); _close_space(_distributor, "123456", 1); /* </master> */ for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { printf("%8.1f ", C[i][j]); } printf("\n"); } exit(0); }
main(int argc, char **argv[]) { /* <reference id="123456"> */ int i, j, k; /* </reference> */ for (i = 0; i < N ; i++) { for (j = 0; j < N; j++) { A[i][j] = (double) i * j ; B[i][j] = (double) i * j ; C[i][j] = 0; } } /* <master id="123456"> */ _distributor = _open_space("distributor", 0, "123456"); _constructor = _open_space("constructor", 0, "123456"); _cleanup_space(_distributor, "123456"); _cleanup_space(_constructor, "123456"); /* <send var="B" type="double[N ][N ]" opt="ONCE"/> */ sprintf(_tp_name, "double(%d)(%d):B#%s", (N), (N), "123456"); _tp_size = ((N) * (N)) * sizeof(double); _tp_B_123456 = (double *)malloc(_tp_size); for (_x0_123456 = 0; _x0_123456 < (N); _x0_123456 +=1) { for (_x1_123456 = 0; _x1_123456 < (N); _x1_123456 +=1) { _tp_B_123456[_x0_123456 * (N) + _x1_123456] = B[_x0_123456][_x1_123456]; } } _status = _send_data(_distributor, _tp_name, (char *)_tp_B_123456, _tp_size); if (_status < 0) exit(-1); free(_tp_B_123456); /* <token action="SET" idxset="(i)"/> */ sprintf(_tp_name, "token#%s", "123456"); sprintf(_tp_token, "=(i:%d~%d,%d:#%d)", 0, N, 1, G); _tp_size = sizeof(_tp_token); _tokens = _set_token(_distributor, _tp_name, (char *)_tp_token, _tp_size); if (_tokens < 0) exit(-1); /* <send var="A" type="double[N ][N ]"/> */ sprintf(_tp_name, "double(%d)(%d):A#%s", (N), (N), "123456"); _tp_size = ((N) * (N)) * sizeof(double); _tp_A_123456 = (double *)malloc(_tp_size); for (_x0_123456 = 0; _x0_123456 < (N); _x0_123456 +=1) { for (_x1_123456 = 0; _x1_123456 < (N); _x1_123456 +=1) { _tp_A_123456[_x0_123456 * (N) + _x1_123456] = A[_x0_123456][_x1_123456]; } } _status = _send_data(_distributor, _tp_name, (char *)_tp_A_123456, _tp_size); if (_status < 0) exit(-1); free(_tp_A_123456); /* <read var="C" type="double[N ][N ]"/> */ sprintf(_tp_name, "double(%d)(%d):C#%s", (N), (N), "123456"); _tp_size = ((N) * (N)) * sizeof(double); _tp_C_123456 = (double *)malloc(_tp_size); _tp_size = _read_data(_constructor, _tp_name, (char *)_tp_C_123456, _tp_size); if (_tp_size < 0) exit(-1); for (_x0_123456 = 0; _x0_123456 < (N); _x0_123456 +=1) { for (_x1_123456 = 0; _x1_123456 < (N); _x1_123456 +=1) { C[_x0_123456][_x1_123456] = _tp_C_123456[_x0_123456 * (N) + _x1_123456]; } } free(_tp_C_123456); _close_space(_constructor, "123456", 1); _close_space(_distributor, "123456", 1); /* </master> */ for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { printf("%8.1f ", C[i][j]); } printf("\n"); } exit(0); }
int main() { /* <reference> */ double A[N][N]; double v; int i, j; /* </reference> */ v = 99.9; /* <master id="123"> */ _distributor = _open_space("distributor", 0, "123"); _constructor = _open_space("constructor", 0, "123"); _cleanup_space(_distributor, "123"); _cleanup_space(_constructor, "123"); /* <send var="v" type="double" opt="ONCE"/> */ sprintf(_tp_name, "double:v#%s", "123"); _tp_size = sizeof(double); _tp_v_123 = &v; _status = _send_data(_distributor, _tp_name, (char *)_tp_v_123, _tp_size); if (_status < 0) exit(-1); /* <token action="SET" idxset="(j)"/> */ sprintf(_tp_name, "token#%s", "123"); sprintf(_tp_token, "=(j:%d~%d,%d:#%d)", 0, N, 1, G); _tp_size = sizeof(_tp_token); _tokens = _set_token(_distributor, _tp_name, (char *)_tp_token, _tp_size); if (_tokens < 0) exit(-1); /* <send var="A" type="double[N][N(j)]"/> */ sprintf(_tp_name, "double(%d)(%d):A#%s", (N), (N), "123"); _tp_size = ((N) * (N)) * sizeof(double); _tp_A_123 = (double *)malloc(_tp_size); for (_x0_123 = 0; _x0_123 < (N); _x0_123 +=1) { for (_x1_123 = 0; _x1_123 < (N); _x1_123 +=1) { _tp_A_123[_x0_123 * (N) + _x1_123] = A[_x0_123][_x1_123]; } } _status = _send_data(_distributor, _tp_name, (char *)_tp_A_123, _tp_size); if (_status < 0) exit(-1); free(_tp_A_123); /* <read var="A" type="double[N][N(j)]"/> */ sprintf(_tp_name, "double(%d)(%d):A#%s", (N), (N), "123"); _tp_size = ((N) * (N)) * sizeof(double); _tp_A_123 = (double *)malloc(_tp_size); _tp_size = _read_data(_constructor, _tp_name, (char *)_tp_A_123, _tp_size); if (_tp_size < 0) exit(-1); for (_x0_123 = 0; _x0_123 < (N); _x0_123 +=1) { for (_x1_123 = 0; _x1_123 < (N); _x1_123 +=1) { A[_x0_123][_x1_123] = _tp_A_123[_x0_123 * (N) + _x1_123]; } } free(_tp_A_123); _close_space(_constructor, "123", 1); _close_space(_distributor, "123", 1); /* </master> */ }