int main(int argc, char* argv[]) { float result[ORDER]; signal(SIGINT, Exit); signal(SIGTERM, Exit); #ifdef SW init_pipe_handler(); PTHREAD_DECL(vectorSum); PTHREAD_CREATE(vectorSum); #endif PTHREAD_DECL(Sender); PTHREAD_CREATE(Sender); uint8_t idx; read_float32_n("out_data_pipe",result,ORDER); for(idx = 0; idx < ORDER; idx++) { fprintf(stdout,"Result = %f, expected = %f.\n", result[idx],expected_result[idx]); } PTHREAD_CANCEL(Sender); #ifdef SW close_pipe_handler(); PTHREAD_CANCEL(vectorSum); #endif return(0); }
int main(int argc, char* argv[]) { float result[ORDER]; signal(SIGINT, Exit); signal(SIGTERM, Exit); #ifdef SW #ifdef USE_GNUPTH pth_init(); #endif init_pipe_handler(); PTHREAD_DECL(conversionTest); PTHREAD_CREATE(conversionTest); #endif PTHREAD_DECL(Sender); PTHREAD_CREATE(Sender); uint8_t idx; read_uint64_n("out_data",((uint64_t*) result),ORDER/2); for(idx = 0; idx < ORDER; idx++) { fprintf(stdout,"Result = %f, expected = %f.\n", result[idx],expected_result[idx]); } PTHREAD_CANCEL(Sender); #ifdef SW close_pipe_handler(); PTHREAD_CANCEL(conversionTest); #endif return(0); }
void stop_daemons () { PTHREAD_CANCEL (stage_0); PTHREAD_CANCEL (stage_1); PTHREAD_CANCEL (stage_2); PTHREAD_CANCEL (stage_3); }
int main(int argc, char* argv[]) { signal(SIGINT, Exit); signal(SIGTERM, Exit); PTHREAD_DECL(Sender); PTHREAD_CREATE(Sender); uint8_t idx; uint32_t result[ORDER]; read_uint32_n("out_data", result, ORDER); for(idx = 0; idx < ORDER; idx++) { fprintf(stdout,"%d. Result = %x, expected %x\n", idx, result[idx], (idx + 1)); } PTHREAD_CANCEL(Sender); for(idx = 0; idx < ORDER; idx++) { write_uint32("in_data", idx); uint32_t res = read_uint32("out_data"); fprintf(stdout,"%d. Result = %x, expected %x\n", idx, res, (idx + 1)); } return(0); }
int main(int argc, char* argv[]) { #ifdef SW init_pipe_handler_with_log("pipelog.txt"); PTHREAD_DECL(maxDaemon); // declare the Daemon thread. PTHREAD_CREATE(maxDaemon); // start the Daemon.. #endif while(1) { uint32_t a, b; scanf("%d", &a); scanf("%d", &b); write_uint32("in_data",a); write_uint32("in_data",b); uint32_t c = read_uint32("out_data"); fprintf(stdout,"Result = %d.\n", c); if(a == 0) break; } #ifdef SW close_pipe_handler(); PTHREAD_CANCEL(maxDaemon); #endif return(0); }
int main(int argc, char* argv[]) { float result; signal(SIGINT, Exit); signal(SIGTERM, Exit); #ifdef SW init_pipe_handler(); PTHREAD_DECL(dotProduct); PTHREAD_CREATE(dotProduct); #endif uint8_t idx; float expected_result = 0.0; for(idx = 0; idx < ORDER; idx++) { float val = drand48(); expected_result += (val*val); write_float32("in_data_pipe",val); } result = read_float32("out_data_pipe"); fprintf(stdout,"Result = %f, expected = %f.\n", result, expected_result); #ifdef SW close_pipe_handler(); PTHREAD_CANCEL(dotProduct); return(0); #endif }
int main(int argc, char* argv[]) { signal(SIGINT, Exit); signal(SIGTERM, Exit); #ifdef SW init_pipe_handler(); PTHREAD_DECL(vectorSum); PTHREAD_CREATE(vectorSum); #endif write_uint32("in_data",1); write_uint32("in_data",2); write_uint32("in_data",3); write_uint32("in_data",4); uint32_t rval = read_uint32("out_data"); fprintf(stdout,"Result = %d.\n", rval); #ifdef SW close_pipe_handler(); PTHREAD_CANCEL(vectorSum); #endif return(0); }
int main(int argc, char* argv[]) { uint32_t result[ORDER]; signal(SIGINT, Exit); signal(SIGTERM, Exit); #ifdef SW init_pipe_handler_with_log("pipeHandler.log"); _start_daemons(stderr); #endif PTHREAD_DECL_AND_CREATE(Sender); read_uint32_n("out_data",result,ORDER); uint32_t idx; for(idx = 0; idx < ORDER; idx++) { fprintf(stdout,"Result = %u, expected = %u.\n", result[idx],idx+1); } PTHREAD_CANCEL(Sender); #ifdef SW close_pipe_handler(); _stop_daemons(); #endif return(0); }
asmlinkage int pthread_cancel_sys (pthread_t thread) { if (!thread || thread -> magic_number != PTHREAD_MAGIC_NUMBER) { SET_ERRNO (ESRCH); return -1; } PTHREAD_CANCEL (thread); return 0; }
int main(int argc, char* argv[]) { FILE* ofile1; FILE* ofile2; char ostr[17]; uint16_t N[ORDER]; #ifdef SW init_pipe_handler(); PTHREAD_DECL(gcd_daemon); PTHREAD_CREATE(gcd_daemon); #endif ofile1 = fopen("gcd_inputs.txt","w"); ofile2 = fopen("gcd_result.txt","w"); int err = 0; uint16_t S = 1; if(argc > 1) S = atoi(argv[1]); fprintf(stderr,"Scale-factor = %d.\n",S); srand48(19); uint16_t i; for(i = 0; i < ORDER; i++) { N[i] = ((uint16_t) (0x0fff * drand48())) * S; fprintf(stderr,"N[%d] = %d\n", i, N[i]); write_uint16("in_data",N[i]); to_string(ostr,N[i]); fprintf(ofile1,"%s\n", ostr); } uint16_t g = read_uint16("out_data"); fprintf(stderr,"GCD = %d.\n",g); to_string(ostr,g); fprintf(ofile2,"%s\n",ostr); uint32_t et = read_uint32("elapsed_time"); fprintf(stderr,"Elapsed time = %u.\n", et); fclose(ofile1); fclose(ofile2); #ifdef SW PTHREAD_CANCEL(gcd_daemon); close_pipe_handler(); #endif return(0); }
int main(int argc, char* argv[]) { uint16_t result[ORDER]; signal(SIGINT, Exit); signal(SIGTERM, Exit); PTHREAD_DECL(Sender); PTHREAD_CREATE(Sender); uint8_t idx; read_uint16_n("out_data",result,ORDER); for(idx = 0; idx < ORDER; idx++) { fprintf(stdout,"Result[%d] = %x.\n", idx, result[idx]); } PTHREAD_CANCEL(Sender); PTHREAD_CANCEL(Sender); return(0); }
int main(int argc, char* argv[]) { float result; int I, J; if(argc < 2) { fprintf(stderr,"Supply data set file.\n"); return(1); } signal(SIGINT, Exit); signal(SIGTERM, Exit); #ifdef SW init_pipe_handler(); PTHREAD_DECL(bestFit); PTHREAD_DECL(qrsDet); PTHREAD_CREATE(bestFit); PTHREAD_CREATE(qrsDet); #endif PTHREAD_DECL(Sender); PTHREAD_DECL(Receiver); PTHREAD_CREATE_WITH_ARG(Sender, argv[1]); PTHREAD_CREATE(Receiver); PTHREAD_JOIN(Sender); PTHREAD_CANCEL(Receiver); #ifdef SW PTHREAD_CANCEL(qrsDet); PTHREAD_CANCEL(bestFit); close_pipe_handler(); return(0); #endif }
int main(int argc, char* argv[]) { uint8_t result[ORDER]; signal(SIGINT, Exit); signal(SIGTERM, Exit); PTHREAD_DECL(Write_Sender); PTHREAD_CREATE(Write_Sender); PTHREAD_DECL(Read_Sender); PTHREAD_CREATE(Read_Sender); uint8_t idx; read_uint8_n("read_response",result,ORDER); for(idx = 0; idx < ORDER; idx++) { fprintf(stdout,"Result = %x, expected = %x.\n", result[idx],idx); } PTHREAD_CANCEL(Write_Sender); PTHREAD_CANCEL(Read_Sender); return(0); }
int main(int argc, char* argv[]) { #ifdef SW init_pipe_handler_with_log("pipelog.txt"); PTHREAD_DECL(vector_control_daemon); // declare the Daemon thread. PTHREAD_CREATE(vector_control_daemon); // start the Daemon.. #endif double *iq, *iq_prev, *id, *id_prev, *flq, *flq_prev, *fld, *fld_prev, *spd, *spd_prev, vd, vq, torque, load_torque, *time = 0; double speed_ref int i=0; int no_of_cycles = 4000 ; // 100u/25n (Ideal time necessary for conputation for FPGA/Motor_iteration_step) while(1) { for(i = 0; i< no_of_cycles; i++){ im_zep(&iq,&iq_prev,&id,&id_prev,&flq,&flq_prev,&fld,&fld_prev,&spd_prev,vd,vq,&torque,load_torque,&time) } write_float32("in_data",*id); write_float32("in_data",*iq); write_float32("in_data",speed_ref); vd = read_float32("out_data"); vq = read_float32("out_data"); } #ifdef SW close_pipe_handler(); PTHREAD_CANCEL(vector_control_daemon); #endif return(0); }
int main(int argc, char* argv[]) { float result[ORDER]; signal(SIGINT, Exit); signal(SIGTERM, Exit); uint8_t idx; for(idx = 0; idx < ORDER; idx++) { op[idx] = idx % 4; x[idx] = drand48(); y[idx] = drand48(); } #ifdef SW init_pipe_handler(); PTHREAD_DECL(streamProcessor); PTHREAD_CREATE(streamProcessor); #endif PTHREAD_DECL(sendX); PTHREAD_CREATE(sendX); PTHREAD_DECL(sendY); PTHREAD_CREATE(sendY); PTHREAD_DECL(sendOp); PTHREAD_CREATE(sendOp); read_float32_n("z_pipe",result,ORDER); for(idx = 0; idx < ORDER; idx++) { fprintf(stdout,"Result = %f, expected = %f.\n", result[idx],expectedResult(op[idx], x[idx], y[idx])); } #ifdef SW close_pipe_handler(); PTHREAD_CANCEL(streamProcessor); #endif return(0); }
int main(void) { BYTE init[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; #ifdef SW init_pipe_handler(); PTHREAD_DECL(Daemon); PTHREAD_CREATE(Daemon); #endif sendConstants(); int i, run; long long t1[10], t2[10]; for (run = 0; run < 10; run++) { fprintf(stderr," run %d.\n", run); for (i = 0; i < 16; i++) { write_uint8("input_block_pipe", init[i]); fprintf(stderr," wrote %x \n", init[i]); } for (i = 0; i < 16; i++) { uint8_t rV = read_uint8("output_block_pipe"); fprintf(stderr," read-back %x \n", rV); } } #ifdef SW close_pipe_handler(); PTHREAD_CANCEL(Daemon); #endif return 0; }
int main(int argc, char* argv[]) { signal(SIGINT, Exit); signal(SIGTERM, Exit); int idx; int expected, diff; PTHREAD_DECL(Sender); PTHREAD_CREATE(Sender); for(idx = 0; idx < ORDER; idx++) { result[idx] = read_uint32("out_data"); expected = *((uint32_t*) &expected_result[idx]); diff = result[idx] - expected; fprintf(stdout,"Result = %x, expected = %x, diff = %d.\n", result[idx], expected,diff); } PTHREAD_CANCEL(Sender); return(0); }
int op_timed_out(CTXTdeclc xsbTimeout *timeout) { struct timespec wakeup_time; // time.h int rc; wakeup_time.tv_sec = time(NULL) + (int)pflags[SYS_TIMER]; pthread_mutex_lock(&timeout->timeout_info.mutex); rc = pthread_cond_timedwait(&timeout->timeout_info.condition, &timeout->timeout_info.mutex, &wakeup_time); pthread_mutex_unlock(&timeout->timeout_info.mutex); if (rc != 0) { switch(rc) { case EINVAL: xsb_bug("pthread_cond_timedwait returned EINVAL"); break; case ETIMEDOUT: break; case ENOMEM: xsb_error("Not enough memory to wait\n"); break; default: xsb_bug("pthread_cond_timedwait returned an unexpected value (%d)\n", rc); } } TURNOFFALARM; // mt-noop(?) switch (timeout->timeout_info.exitFlag) { case STILL_WAITING: /* The call timed out */ PTHREAD_CANCEL(timeout->timeout_info.timedThread); return TRUE; case TIMED_OUT: return TRUE; case NORMAL_TERMINATION: return FALSE; default: xsb_bug("timed call's exit flag is an unexpected value (%d)", timeout->timeout_info.exitFlag); return FALSE; } }
int main(int argc, char* argv[]) { uint64_t result[2]; signal(SIGINT, Exit); signal(SIGTERM, Exit); PTHREAD_DECL(Sender); PTHREAD_CREATE(Sender); uint8_t idx, jdx; for(idx = 0; idx < ORDER; idx++) { read_uint64_n("out_data",result,2); fprintf(stdout,"\n%16llx %16llx", result[0],result[1]); } PTHREAD_CANCEL(Sender); return(0); }
int main(int argc, char* argv[]) { signal(SIGINT, Exit); signal(SIGTERM, Exit); signal(SIGSEGV, Exit); int i,j,k; srand48(100); for(i = 0; i < ORDER; i++) { for(j = 0; j < ORDER; j++) { a_matrix[i][j] = drand48(); b_matrix[i][j] = drand48(); } } for(i = 0; i < ORDER; i++) { for(j = 0; j < ORDER; j++) { expected_c_matrix[i][j] = 0; for(k = 0; k < ORDER; k++) expected_c_matrix[i][j] += a_matrix[i][k] * b_matrix[k][j]; } } #ifdef SW init_pipe_handler(); PTHREAD_DECL(mmultiply); PTHREAD_DECL(mmultiply_LL); PTHREAD_DECL(mmultiply_LH); PTHREAD_DECL(mmultiply_HH); PTHREAD_DECL(mmultiply_HL); PTHREAD_CREATE(mmultiply); PTHREAD_CREATE(mmultiply_LL); PTHREAD_CREATE(mmultiply_LH); PTHREAD_CREATE(mmultiply_HH); PTHREAD_CREATE(mmultiply_HL); #endif write_matrices(); read_result_matrix(); fprintf(stdout,"results: \n "); for(i = 0; i < ORDER; i++) { for(j = 0; j < ORDER; j++) { if(expected_c_matrix[i][j] == c_matrix[i][j]) fprintf(stdout,"result[%d][%d] = %f\n", i, j, c_matrix[i][j]); else fprintf(stdout,"Error: result[%d][%d] = %f, expected = %f\n", i, j, c_matrix[i][j], expected_c_matrix[i][j]); } } fprintf(stdout,"done\n"); #ifdef SW PTHREAD_CANCEL(mmultiply); PTHREAD_CANCEL(mmultiply_LL); PTHREAD_CANCEL(mmultiply_LH); PTHREAD_CANCEL(mmultiply_HH); PTHREAD_CANCEL(mmultiply_HL); close_pipe_handler(); #endif }
int main(int argc, char* argv[]) { float result; int I; if(argc < 2) { fprintf(stderr,"Supply data set file.\n"); return(1); } FILE* fp = fopen(argv[1],"r"); if(fp == NULL) { fprintf(stderr,"Could not open data set file %s.\n", argv[1]); return(1); } signal(SIGINT, Exit); signal(SIGTERM, Exit); PTHREAD_DECL(Logger); PTHREAD_CREATE(Logger); #ifdef SW init_pipe_handler(); PTHREAD_DECL(bestFit); PTHREAD_CREATE(bestFit); #endif Sender(); for(I = 0; I < NSAMPLES; I++) { double X; fscanf(fp, "%le", &X); write_float64("sample_data_pipe", X); samples[I] = X; } fprintf(stderr," Sent samples.\n"); fclose(fp); calculateReferenceFit(); uint32_t best_sigma_index = read_uint32("best_sigma_pipe"); fprintf(stdout, " Best sigma= %f (index = %d).\n", (MIN_SIGMA + (best_sigma_index*(MAX_SIGMA - MIN_SIGMA)/NSIGMAS)), best_sigma_index); double p0 = read_float64("fit_coefficient_pipe"); double p1 = read_float64("fit_coefficient_pipe"); double p2 = read_float64("fit_coefficient_pipe"); double p3 = read_float64("fit_coefficient_pipe"); double p4 = read_float64("fit_coefficient_pipe"); double p5 = read_float64("fit_coefficient_pipe"); fprintf(stdout, "Fit coefficients = %le, %le, %le, %le, %le, %le.\n", p0,p1,p2,p3,p4,p5); uint32_t elapsed_time = read_uint32("elapsed_time_pipe"); fprintf(stdout,"Elapsed time = %d.\n", elapsed_time); #ifdef SW PTHREAD_CANCEL(bestFit); close_pipe_handler(); return(0); #endif }