void BackProjection::create_prob() { int i, j; input = (unsigned char *)malloc(r * c * sizeof(unsigned char)); for (i = 0; i < r; i++) { for (j = 0; j < c; j++) { input[ i * c + j ] = FALSE; } } create_image(r, c, input, r < c ? r : c, r < c ? (F_TYPE) r / (F_TYPE) 4.0: (F_TYPE) c / (F_TYPE) 4.0); std::string inName = "BackProjection_ref_in.dat"; std::string bmpName = "BackProjection_ref_in.bmp"; printimage(r, c, input, inName.c_str()); write_bmp(bmpName.c_str(), input, r, c); rproj = (int *)malloc(r * sizeof(int)); cproj = (int *)malloc(c * sizeof(int)); uproj = (int *)malloc((r + c - 1) * sizeof(int)); dproj = (int *)malloc((r + c - 1) * sizeof(int)); rband = (int *)malloc(r * c * sizeof(int)); cband = (int *)malloc(c * sizeof(int)); uband = (int *)malloc((r + c - 1) * sizeof(int)); dband = (int *)malloc((r + c - 1) * sizeof(int)); makeband(r, c, rband, cband, uband, dband); create_input(r, c, input, rproj, cproj, uproj, dproj, uband, dband); }
const char * fl_show_simple_input( const char * str1, const char * defstr ) { if ( fd_input ) { fl_hide_form( fd_input->form ); fl_free_form( fd_input->form ); fli_safe_free( fd_input ); } else fl_deactivate_all_forms( ); fli_safe_free( ret_str ); fd_input = create_input( str1, defstr ); fl_show_form( fd_input->form, FL_PLACE_HOTSPOT, FL_TRANSIENT, "Input" ); fl_update_display( 0 ); while ( fl_do_only_forms( ) != fd_input->but ) /* empty */ ; ret_str = fl_strdup( fl_get_input( fd_input->input ) ); fl_hide_form( fd_input->form ); fl_free_form( fd_input->form ); fli_safe_free( fd_input ); fl_activate_all_forms( ); return ret_str; }
int add_input(t_pane *pane, char *input) { t_input *new_input; new_input = create_input(input, pane->max_input_id); if (new_input != NULL) { pane->max_input_id += 1; new_input->next = pane->inputs; pane->inputs = new_input; return (LIBCURSES_OK); } else return (LIBCURSES_NOK); }
int main(void) { // initialize seed for random value function srand(time(NULL)); create_input("const.txt",1000, -3.4,0.1, 0); create_input("square.txt",1000, -10.0,20.0/1000, 1); create_input("quadratic.txt",1000, -10.0,20.0/1000, 2); create_input("power.txt",1000,0.0001,20.0/1000, 3); create_input("sin.txt",1000, 1.00, 22.0/7.0/100.0, 4); create_input("rand.txt",1000, 1.00, 1.00, 5); return 0; }
int main() { char *header; int i, nkeyrec, nreject, nwcs, stat[NWCSFIX], status = 0; fitsfile *fptr; struct wcsprm *wcs; /* Set line buffering in case stdout is redirected to a file, otherwise * stdout and stderr messages will be jumbled (stderr is unbuffered). */ setvbuf(stdout, NULL, _IOLBF, 0); printf("Testing -TAB interpreter (twcstab.c)\n" "------------------------------------\n\n"); /* Create the input FITS test file. */ if (create_input()) { fprintf(stderr, "Failed to create FITS test file."); return 1; } /* Open the FITS test file and read the primary header. */ fits_open_file(&fptr, "wcstab.fits", READONLY, &status); if ((status = fits_hdr2str(fptr, 1, NULL, 0, &header, &nkeyrec, &status))) { fits_report_error(stderr, status); return 1; } /*-----------------------------------------------------------------------*/ /* Basic steps required to interpret a FITS WCS header, including -TAB. */ /*-----------------------------------------------------------------------*/ /* Parse the primary header of the FITS file. */ if ((status = wcspih(header, nkeyrec, WCSHDR_all, 2, &nreject, &nwcs, &wcs))) { fprintf(stderr, "wcspih ERROR %d: %s.\n", status,wcshdr_errmsg[status]); } /* Read coordinate arrays from the binary table extension. */ if ((status = fits_read_wcstab(fptr, wcs->nwtb, (wtbarr *)wcs->wtb, &status))) { fits_report_error(stderr, status); return 1; } /* Translate non-standard WCS keyvalues. */ if ((status = wcsfix(7, 0, wcs, stat))) { for (i = 0; i < NWCSFIX; i++) { if (stat[i] > 0) { fprintf(stderr, "wcsfix ERROR %d: %s.\n", status, wcsfix_errmsg[stat[i]]); } } return 1; } /*-----------------------------------------------------------------------*/ /* The wcsprm struct is now ready for use. */ /*-----------------------------------------------------------------------*/ /* Do something with it. */ do_wcs_stuff(fptr, wcs); /* Finished with the FITS file. */ fits_close_file(fptr, &status); free(header); /* Clean up. */ status = wcsvfree(&nwcs, &wcs); return 0; }
void build_network (void) { NUM_ISOLATE_NEURON_LAYERS = 12; NUM_INPUTS = 2; NUM_OUTPUTS = 6; NUM_FILTERS = 2; srand (5); memset((void *) &(nl_ita_lp_f), 0, sizeof(NEURON_LAYER)); nl_ita_lp_f.name = "nl_ita_lp_f"; memset((void *) &(nl_prediction), 0, sizeof(NEURON_LAYER)); nl_prediction.name = "nl_prediction"; memset((void *) &(nl_test), 0, sizeof(NEURON_LAYER)); nl_test.name = "nl_test"; memset((void *) &(nl_result), 0, sizeof(NEURON_LAYER)); nl_result.name = "nl_result"; memset((void *) &(nl_ita2_lp_f), 0, sizeof(NEURON_LAYER)); nl_ita2_lp_f.name = "nl_ita2_lp_f"; memset((void *) &(nl_prediction2), 0, sizeof(NEURON_LAYER)); nl_prediction2.name = "nl_prediction2"; memset((void *) &(ita), 0, sizeof(INPUT_DESC)); ita.name = "ita"; memset((void *) &(ita2), 0, sizeof(INPUT_DESC)); ita2.name = "ita2"; memset((void *) &(out_ita_lp_f), 0, sizeof(OUTPUT_DESC)); out_ita_lp_f.name = "out_ita_lp_f"; memset((void *) &(out_prediction), 0, sizeof(OUTPUT_DESC)); out_prediction.name = "out_prediction"; memset((void *) &(out_test), 0, sizeof(OUTPUT_DESC)); out_test.name = "out_test"; memset((void *) &(out_result), 0, sizeof(OUTPUT_DESC)); out_result.name = "out_result"; memset((void *) &(out_ita2_lp_f), 0, sizeof(OUTPUT_DESC)); out_ita2_lp_f.name = "out_ita2_lp_f"; memset((void *) &(out_prediction2), 0, sizeof(OUTPUT_DESC)); out_prediction2.name = "out_prediction2"; __line = 2; NEURON_MEMORY_SIZE = 10000; __line = 4; TYPE_SHOW = SHOW_FRAME; __line = 5; TYPE_MOVING_FRAME = STOP; __line = 8; //; __line = 9; //; __line = 11; //; __line = 12; //; __line = 14; //; __line = 16; //; __line = 17; //; __line = 18; //; __line = 19; //; __line = 20; //; __line = 21; //; __line = 22; //; __line = 25; create_neuron_layer (&nl_ita_lp_f, NULL, NOT_SPECIFIED, GREYSCALE_FLOAT, INPUT_WIDTH,INPUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE); __line = 26; create_neuron_layer (&nl_prediction, &minchinton, GREYSCALE_FLOAT, GREYSCALE_FLOAT, OUT_WIDTH,OUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE); __line = 27; create_neuron_layer (&nl_test, &minchinton, GREYSCALE_FLOAT, GREYSCALE_FLOAT, OUT_WIDTH,OUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE); __line = 28; create_neuron_layer (&nl_result, &minchinton, GREYSCALE_FLOAT, GREYSCALE_FLOAT, OUT_WIDTH,OUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE); __line = 30; create_neuron_layer (&nl_ita2_lp_f, NULL, NOT_SPECIFIED, GREYSCALE_FLOAT, INPUT_WIDTH,INPUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE); __line = 31; create_neuron_layer (&nl_prediction2, &minchinton, GREYSCALE_FLOAT, GREYSCALE_FLOAT, OUT_WIDTH,OUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE); __line = 34; create_output (&out_ita_lp_f, INPUT_WIDTH,INPUT_HEIGHT, NULL, 0); __line = 35; create_output (&out_prediction, OUT_WIDTH,OUT_HEIGHT, output_handler, " "); __line = 36; create_output (&out_test, OUT_WIDTH,OUT_HEIGHT, NULL, 0); __line = 37; create_output (&out_result, OUT_WIDTH,OUT_HEIGHT, NULL, 0); __line = 39; create_output (&out_ita2_lp_f, INPUT_WIDTH,INPUT_HEIGHT, NULL, 0); __line = 40; create_output (&out_prediction2, OUT_WIDTH,OUT_HEIGHT, output_handler, " "); __line = 43; create_input (&ita, INPUT_WIDTH,INPUT_HEIGHT, GREYSCALE_FLOAT, 0, REGULAR_PYRAMID, input_generator, input_controler, " ", " "); __line = 45; create_input (&ita2, INPUT_WIDTH,INPUT_HEIGHT, GREYSCALE_FLOAT, 0, REGULAR_PYRAMID, input_generator, input_controler, " ", " "); __line = 49; create_filter (copy_nl_filter, &nl_ita_lp_f, 1, ita.neuron_layer, ""); __line = 51; create_filter (copy_nl_filter, &nl_ita2_lp_f, 1, ita2.neuron_layer, ""); __line = 54; output_connect (&nl_ita_lp_f, &out_ita_lp_f); __line = 55; output_connect (&nl_prediction, &out_prediction); __line = 56; output_connect (&nl_test, &out_test); __line = 57; output_connect (&nl_result, &out_result); __line = 59; output_connect (&nl_ita2_lp_f, &out_ita2_lp_f); __line = 60; output_connect (&nl_prediction2, &out_prediction2); __line = 63; associate_neurons (&nl_prediction, &nl_prediction); __line = 65; associate_neurons (&nl_prediction2, &nl_prediction2); __line = 68; connect_neurons (GAU2, &nl_ita_lp_f, &nl_prediction, SYNAPSES, 0.0, 9.32433, 0.0, -1,-1,-1,-1, -1,-1,-1,-1, DIFFERENT_INTERCONNECTION_PATTERN); __line = 74; connect_neurons (GAU2, &nl_ita2_lp_f, &nl_prediction2, SYNAPSES, 0.0, 9.32433, 0.0, -1,-1,-1,-1, -1,-1,-1,-1, DIFFERENT_INTERCONNECTION_PATTERN); __line = 77; create_interpreter_user_function (INT_TYPE, GetRandomReturns, "GetRandomReturns", "%d"); ; __line = 78; create_interpreter_user_function (INT_TYPE, ShowStatistics, "ShowStatistics", "%d"); ; __line = 79; create_interpreter_user_function (INT_TYPE, ResetStatistics, "ResetStatistics", "%d"); ; __line = 80; create_interpreter_user_function (INT_TYPE, SetNetworkStatus, "SetNetworkStatus", "%d"); ; __line = 81; create_interpreter_user_function (INT_TYPE, LoadReturns, "LoadReturns", "%s"); ; __line = 82; create_interpreter_user_function (INT_TYPE, LoadDayFileName, "LoadDayFileName", "%s"); ; __line = 83; create_interpreter_user_function (INT_TYPE, LoadDay, "LoadDay", "%d"); ; __line = 84; create_interpreter_user_function (INT_TYPE, ShowStatisticsExp, "ShowStatisticsExp", "%d"); ; __line = 85; create_interpreter_user_function (INT_TYPE, MeanStatisticsExp, "MeanStatisticsExp", "%d"); ; __line = 86; create_interpreter_user_function (INT_TYPE, SetLongShort, "SetLongShort", "%d"); ; map_layers2id (); count_num_neurons (); initialise_memory (); create_io_windows (); }
shared_ptr<primitive> MKLDNNMemoryDescriptor<Dtype, is_diff>::create_input(bool set_prv_ptr) { // TODO: need to iptimize code return create_input(this->_blob, set_prv_ptr); }
int main(int argc, char *argv[]) { const char *code = argv[1]; const char *slash = strrchr(code, '/'); int ret; /* stupid automake! */ if (slash) code = slash + 1; if (code[0] == '_') { struct stat st; if (lstat(INPUT_FILE, &st)) return 77; switch (code[1]) { case T_BROKEN_SYMLINK: ex_linkdest[0]++; } } else { /* XXX: replace tests */ unlink(INPUT_FILE); unlink(OUTPUT_FILE); switch (code[0]) { case T_REGULAR: case T_EMPTY: if (!create_input(INPUT_FILE, code[0] == T_REGULAR)) { perror("Input creation failed"); return 2; } break; case T_BROKEN_SYMLINK: ex_linkdest[0]++; case T_SYMLINK: if (symlink(ex_linkdest, INPUT_FILE)) { perror("Input symlink creation failed"); return 77; } break; case T_NAMED_PIPE: if (mkfifo(INPUT_FILE, 0700)) { perror("Named pipe creation failed"); return 77; } break; case T_BLK_DEV: #ifdef S_IFBLK if (mknod(INPUT_FILE, 0700 | S_IFBLK, 0xff00)) { perror("Block device creation failed"); return 77; } #else fprintf(stderr, "Block devices not supported\n"); return 77; #endif break; case T_CHR_DEV: #ifdef S_IFCHR if (mknod(INPUT_FILE, 0700 | S_IFCHR, 0x0103)) { perror("Character device creation failed"); return 77; } #else fprintf(stderr, "Character devices not supported\n"); return 77; #endif break; default: fprintf(stderr, "Invalid arg: [%s]\n", code); return 3; } } ret = ai_cp_a(INPUT_FILE, OUTPUT_FILE); if (ret) { fprintf(stderr, "[%s] Copying failed: %s\n", code, strerror(errno)); return 1; } return compare_files(INPUT_FILE, OUTPUT_FILE, code); }
void Verifier::begin_pepper() { #ifdef INTERFACE_MPI MPI_Send(&batch_size, 1, MPI_INT, MPI_COORD_RANK, MPI_PARAMS, MPI_COMM_WORLD); MPI_Send(&num_repetitions, 1, MPI_INT, MPI_COORD_RANK, MPI_PARAMS, MPI_COMM_WORLD); MPI_Send(&input_size, 1, MPI_INT, MPI_COORD_RANK, MPI_PARAMS, MPI_COMM_WORLD); MPI_Send(&optimize_answers, 1, MPI_INT, MPI_COORD_RANK, MPI_PARAMS, MPI_COMM_WORLD); #endif cout << "batch_size " << batch_size << endl; cout << "num_reps " << num_repetitions << endl; cout << "input_size " << input_size << endl; cout << "output_size " << size_output << endl; cout << "num_bits_in_input " << num_bits_in_input << endl; cout << "num_bits_in_prime " << num_bits_in_prime << endl; double v_setup_total = 0; Measurement m, m_prover; int status; m.begin_with_init(); create_commitment_query(); m.end(); cout << "v_commitmentq_create " << m.get_ru_elapsed_time() << endl; cout << "v_commitmentq_create_latency " << m.get_papi_elapsed_time() << endl; v_setup_total += m.get_ru_elapsed_time(); m.begin_with_init(); create_input(); m.end(); cout << "v_input_create " << m.get_ru_elapsed_time() << endl; cout << "v_input_create_latency " << m.get_papi_elapsed_time() << endl; m_prover.begin_with_init(); // send the computation and input invoke_prover(PHASE_PROVER_COMMITMENT); #ifdef INTERFACE_MPI MPI_Recv(&status, 1, MPI_INT, 1, MPI_PROVER_FINISHED, MPI_COMM_WORLD, MPI_STATUS_IGNORE); #endif m_prover.end(); // receive output recv_outputs(); // receive proof recv_comm_answers(); #if !(NONINTERACTIVE == 1) v->dump_seed_decommit_queries(); invoke_prover(PHASE_PROVER_DEDUCE_QUERIES); create_plain_queries(); #endif cout << "v_plainq_create " << m_plainq.get_ru_elapsed_time() << endl; cout << "v_plainq_create_latency " << m_plainq.get_papi_elapsed_time() << endl; v_setup_total += m_plainq.get_ru_elapsed_time(); #if !(NONINTERACTIVE == 1) m_prover.begin_with_history(); invoke_prover(PHASE_PROVER_PCP); #ifdef INTERFACE_MPI MPI_Recv(&status, 1, MPI_INT, 1, MPI_PROVER_FINISHED, MPI_COMM_WORLD, MPI_STATUS_IGNORE); #endif m_prover.end(); recv_plain_answers(); #endif if (num_verification_runs == 0) num_verification_runs = 1; // verify the computation is done correctly bool result = true; // prepare for the verification by loading VK. for (int beta=0; beta<batch_size; beta++) { prepare_answers(beta); m_runtests.begin_with_history(); // part of it is in the prev function call for (int i=0; i<num_verification_runs; i++) { result = run_tests(beta) & result; } m_runtests.end(); } if (false == result) cout <<endl<<"LOG: The prover failed one of the tests; set VERBOSE to 1 to find the test that failed"<<endl<<endl; else cout <<endl<<"LOG: The prover passed the decommitment test and PCP tests"<<endl<<endl; // output measurements. cout << "v_setup_total " << v_setup_total << endl; cout << "v_run_pcp_tests " << m_runtests.get_ru_elapsed_time()/num_verification_runs << endl; cout << "v_run_pcp_tests_latency " << m_runtests.get_papi_elapsed_time()/num_verification_runs << endl; cout << "v_run_pcp_tests_rclock " << m_runtests.get_rclock_elapsed_time()/num_verification_runs << endl; cout << "v_net_bytes_sent " << network_bytes_sent << endl; cout << "v_net_bytes_rcvd " << network_bytes_rcvd << endl; cout << "v_net_send_time_elapsed " << network_send_time_elapsed << endl; cout << "v_net_rcv_time_elapsed " << network_rcv_time_elapsed << endl; cout << "v_net_bytes_input_sent " << network_bytes_input_sent << endl; cout << "v_net_bytes_output_rcvd " << network_bytes_output_rcvd << endl; cout << "p_d_latency " << m_prover.get_papi_elapsed_time() << endl; #ifdef INTERFACE_MPI char *tmp_str = (char *)"terminate"; // content of string doesnt matter. MPI_Send(tmp_str, strlen(tmp_str) + 1, MPI_CHAR, MPI_COORD_RANK, MPI_TERMINATE, MPI_COMM_WORLD); MPI_Finalize(); #endif }