void genDumpMod_call(int data, int reason) { handle child_handle, module_handle; char *pargs, *ptr, *mod_name; int pargs_found, level; char buf[128]; pargs = mc_scan_plusargs ("gen_dump_module="); pargs_found = 0; if (pargs != (char *)0) { strcpy(buf, pargs); mod_name = strtok (buf, ":"); ptr = strtok (NULL, " \n"); level = atoi (ptr); if (level > 0 ) {pargs_found = 1;} } if (pargs_found == 0) return; io_printf ("%s %d\n", mod_name, level); if ((fp = fopen("dump.mod", "w")) == 0) tf_error ("can't open dump.mod file\n"); acc_initialize(); module_handle = acc_handle_object (mod_name); child_handle = null; next_level (module_handle, level); acc_close(); fclose (fp); tf_dofinish(); }
/* CheckAccClose() *========================================================================== */ BOOLEAN CheckAccClose( void ) { if( acc_close_flag ) acc_close( (int*)msg ); return( acc_close_flag ); }
/************************************************* lxt2_recordsetup - specify options ************************************************/ int lxt2_recordsetup( int data, int reason ) { int i; acc_initialize(); switch( reason ) { case reason_checktf: if( tf_nump() == 0 ) { tf_error( "not enough arguments to recordsetup" ); tf_dofinish(); } goto DONE; case reason_calltf: if( lxt.inited ) { tf_error( "recording has already started" ); tf_dofinish(); } break; default: goto DONE; } for( i = 1; i <= tf_nump(); ++i ) { lxt2_option( acc_fetch_tfarg_str(i) ); } DONE: acc_close(); return 0; }
/************************************************* lxt2_recordclose - close lxt file and stop recording ************************************************/ int lxt2_recordclose( int data, int reason ) { acc_initialize(); switch( reason ) { case reason_checktf: if( tf_nump() != 0 ) { tf_error( "too many arguments to recordclose" ); tf_dofinish(); } goto DONE; case reason_calltf: if( !lxt.inited ) { tf_error( "recording has not started" ); tf_dofinish(); goto DONE; } break; default: goto DONE; } lxt2_close(); DONE: acc_close(); return 0; }
/* CheckXAccClose() *========================================================================== * Check to see if we received an acc_close message while in an * XFORM_DO routine. Note: we call the acc_close routine directly. * If we put the message on the pipe instead, the message might * arrive too late. */ void CheckXAccClose( void ) { if( xacc_close_flag ) { SetAccCloseState( FALSE ); acc_close( ( int *)msg ); } }
static krb5_error_code KRB5_CALLCONV acc_resolve(krb5_context context, krb5_ccache *id, const char *res) { krb5_error_code ret; cc_int32 error; krb5_acc *a; ret = acc_alloc(context, id); if (ret) return ret; a = ACACHE(*id); error = (*a->context->func->open_ccache)(a->context, res, &a->ccache); if (error == ccNoError) { cc_time_t offset; error = get_cc_name(a); if (error != ccNoError) { acc_close(context, *id); *id = NULL; return translate_cc_error(context, error); } error = (*a->ccache->func->get_kdc_time_offset)(a->ccache, cc_credentials_v5, &offset); if (error == 0) context->kdc_sec_offset = offset; } else if (error == ccErrCCacheNotFound) { a->ccache = NULL; a->cache_name = NULL; } else { *id = NULL; return translate_cc_error(context, error); } return 0; }
static krb5_error_code KRB5_CALLCONV acc_get_cache_next(krb5_context context, krb5_cc_cursor cursor, krb5_ccache *id) { struct cache_iter *iter = cursor; cc_ccache_t cache; krb5_acc *a; krb5_error_code ret; int32_t error; error = (*iter->iter->func->next)(iter->iter, &cache); if (error) return translate_cc_error(context, error); ret = _krb5_cc_allocate(context, &krb5_acc_ops, id); if (ret) { (*cache->func->release)(cache); return ret; } ret = acc_alloc(context, id); if (ret) { (*cache->func->release)(cache); free(*id); return ret; } a = ACACHE(*id); a->ccache = cache; error = get_cc_name(a); if (error) { acc_close(context, *id); *id = NULL; return translate_cc_error(context, error); } return 0; }
int util_get_plus_args_str() { /* Example use: invocation script (bosox is passed in as first argument) ----------------- set basename = $1 verilog mymodule.v +tst_file_name${basename}.tst +log_file_name${basename}.log +err_file_name${basename}.err +result_file_name${basename}.result mymodule.v ---------- reg [32*8:1] tst_file_name; // plus argument string value reg [32*8:1] err_file_name; // plus argument string value reg [32*8:1] log_file_name; // plus argument string value reg [32*8:1] result_file_name; // plus argument string value integer plus_arg_ok; // 0 if ok, 1 if no plus argument value initial begin // get strings from plus argument values plus_arg_ok = $util_get_plus_args_str("tst_file_name", tst_file_name); plus_arg_ok = $util_get_plus_args_str("err_file_name", err_file_name); plus_arg_ok = $util_get_plus_args_str("log_file_name", log_file_name); plus_arg_ok = $util_get_plus_args_str("result_file_name",result_file_name); $display("tst_file_name is %s", tst_file_name); $display("err_file_name is %s", err_file_name); $display("log_file_name is %s", log_file_name); $display("result_file_name is %s", result_file_name); end */ /* Input is string Returning value is string. */ handle wrk_out; char *strArgIn; int sizeOut,sizeS_in; int numArgs; int cnt,size; char *buffer, *bufferout; s_setval_value value_out; s_setval_delay delay_out; delay_out.model = accNoDelay; delay_out.time.type = accRealTime; delay_out.time.real = 0.0; value_out.format = accHexStrVal; acc_initialize(); numArgs = tf_nump(); if(numArgs !=2) { tf_error("$get_plus_arg_string must have two arguments"); tf_putp(0,VERILOG_ERROR); return(VERILOG_ERROR); } /* Fetch the input register and size */ wrk_out = acc_handle_tfarg(2); sizeOut = (acc_fetch_size(wrk_out)/8); /* Get the string value */ strArgIn = mc_scan_plusargs(tf_getcstringp(1)); if (strArgIn == NULL) { if (DEBUG_PLUS_ARGS) io_printf("get_plus_args_str(): Matching string is not found: %s.\n", tf_getcstringp(1)); tf_putp(0,VERILOG_ERROR); return(VERILOG_ERROR); } if (strArgIn) { if (DEBUG_PLUS_ARGS) io_printf("get_plus_args_str(): Got string value: %s\n",strArgIn); } else { io_printf("get_plus_args_str(): Bad input string value.\n"); tf_putp(0,VERILOG_ERROR); return(VERILOG_ERROR); } /* Build new string */ sizeS_in = strlen(strArgIn); bufferout = (char *) malloc(sizeS_in + 1); sprintf(bufferout, "%s",strArgIn); if (sizeOut < sizeS_in) { tf_error("get_plus_args_str(): Register %s is not large enough.\n", acc_fetch_fullname(wrk_out)); tf_putp(0,VERILOG_ERROR); return(VERILOG_ERROR); } size = sizeS_in*2; buffer = (char *) malloc(size + 1); for (cnt =0; cnt < size; cnt +=2){ if (cnt < size){ /* Convert string into HEX code */ sprintf(&buffer[cnt],"%x",bufferout[cnt/2]); } } /* Null out the rest of the register else { buffer[cnt] = '\0'; buffer[cnt +1] = '\0'; } */ /* assign buffer to the verilog register */ value_out.value.str = buffer; acc_set_value(wrk_out, &value_out, &delay_out); tf_putp(0,VERILOG_OK); acc_close(); free(buffer); free(bufferout); return(VERILOG_OK); }
int main (int argc, char **argv) { long ret, iters; int count, section_id; struct acc_handler_t acc_handler; char * acc_name; unsigned char *ptr; void * in_buffer, *result_buffer; unsigned int real_in_size, real_out_size, in_buffer_size, out_buffer_size; struct timeval open_start, open_end, open_dt; struct timeval exe_start, exe_end, exe_dt; char param [16]; param [0] = 0x24; ret = 0; section_id = 3; if (argc != 3) { printf ("Usage : micro_test ACC_name/ACC_ID /Workload\n"); printf ("\tworkload must be a mutiple of 4 K bytes\n"); printf ("\tExample : micro_test AES 1 (means execute AES with workloads of 1* 4K bytes)\n"); printf ("\tExample : micro_test 0x1234 1\n\n"); return -1; } acc_name = argv[1]; count = atoi(argv[2]); double bw; real_in_size = count * sysconf(_SC_PAGESIZE); real_out_size = count * sysconf(_SC_PAGESIZE); in_buffer_size = real_in_size; out_buffer_size = real_out_size; printf("in_buffer_size = %d\n", real_in_size); //opening accelerator if (count >= 1024){ in_buffer_size = 1024 * sysconf(_SC_PAGESIZE); out_buffer_size = 1024 * sysconf(_SC_PAGESIZE); } //if a job is lareger than 4M, we allocate an 4M size acc to this job and copy data to acc_handler->data_buffer iterately. gettimeofday(&open_start, NULL); in_buffer = pri_acc_open(&acc_handler, acc_name, in_buffer_size, out_buffer_size, section_id); gettimeofday(&open_end, NULL); timersub(&open_end, &open_start, &open_dt); long open_usec = open_dt.tv_usec + 1000000 * open_dt.tv_sec; printf("[OPEN] %s takes %ld microseconds.\n", acc_name, open_usec); if (in_buffer == NULL) { printf ("Open %s fail.\n", acc_name); } else { unsigned int i, job_len; gettimeofday(&exe_start, NULL); for(i = 0; i<real_in_size; i+=in_buffer_size){ if ((real_in_size - i) >= in_buffer_size) job_len = in_buffer_size; else job_len = real_in_size - i; if(job_len > 0){ in_buffer = memset(in_buffer, 1, job_len); ret = acc_do_job(&acc_handler, param, job_len, &result_buffer); if (ret < 0) printf ("Do job fail. code = 0x%lx\n", ret); } } gettimeofday(&exe_end, NULL); timersub(&exe_end, &exe_start, &exe_dt); long job_usec = exe_dt.tv_usec + 1000000 * exe_dt.tv_sec; printf("[EXECUTION] %s takes %ld microseconds.\n", acc_name, job_usec); bw = ((double)(real_in_size))/(1024*1024)/((1.0*job_usec)/1000000.0); printf("[BW] is %f\n", bw); } // Here we close the accelerator acc_close(&acc_handler); return 0; }
void main( int argc, char *argv[], char *envp[] ) { int i; /* ----- evnt_multi return parameters */ int event, msg[8], key, nclicks; MRETS mrets; int rez; /* * Initialize global arguments */ if( (nargs = argc) != 1) args = argv; env = envp; /* * See if we were run from the AUTO folder... */ if( (gl_apid = appl_init()) == -1 ) { Cconws("\r\nError initializing GEM, hit a key..."); Cconin(); exit( gl_apid ); } rez = Getrez() + 2; if(( rez != 2 ) && ( rez != 6 ) ) { /* Ensure that we run ONLY in ST LOW or TT MED - 640x480 16 colors */ form_alert( 1, "[3][ | This program runs in| ST LOW or TT MED Only][ OK ]" ); appl_exit(); exit( -1 ); } /* * Set up work_in to initialize VDI functions to useful values, * Get the physical workstation handle from the AES, then * open a virtual workstation and get our AES work area's extent. */ work_in[0] = Getrez()+2; /* let's not gag GDOS */ for( i = 1; i < 10; work_in[i++] = 1 ) ; work_in[10] = 2; /* raster coordinates */ vhandle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox ); v_opnvwk( work_in, &vhandle, work_out ); xres = work_out[0]; yres = work_out[1]; /* * Call initialization hooks */ Wind_get( 0, WF_WORKXYWH, ( WARGS *)&desk ); if( !rsrc_init() ) { form_alert( 1, "[3][ RSC ERROR ][ OK ]" ); v_clsvwk( vhandle ); appl_exit(); exit( -1 ); } wind_init(); evnt_init(); /* * Main event loop */ do { event = Evnt_multi( ev_mask, ev_clicks, ev_bmask, ev_bstate, &ev_m1, &ev_m2, ( WORD *)msg, ev_time, &mrets, ( WORD *)&key, ( WORD *)&nclicks ); wind_update( BEG_UPDATE ); /* * call pre-event-processing hook */ if( evnt_hook( event, msg, &mrets, &key, &nclicks ) ) continue; /* Dispatch events. * It is possible to get more than one event at a time, so if the * order of event handling is important to you, change the order * in which they're handled here. */ if( event & MU_TIMER ) do_timer( &event ); if( event & MU_KEYBD ) do_key( mrets.kstate, key, &event ); if( event & MU_BUTTON ) do_button( &mrets, nclicks, &event ); if( event & MU_M1 ) do_m1( &mrets, &event ); if( event & MU_M2 ) do_m2( &mrets, &event ); if( event & MU_MESAG ) switch( msg[0] ) { case MN_SELECTED: do_menu( msg, &event ); break; case WM_REDRAW: case WM_TOPPED: case WM_CLOSED: case WM_FULLED: case WM_ARROWED: case WM_HSLID: case WM_VSLID: case WM_SIZED: case WM_MOVED: case WM_NEWTOP: do_windows( msg, &event ); break; case AC_OPEN: acc_open( msg ); break; case AC_CLOSE: acc_close( msg ); break; default: msg_hook( msg, &event ); } /* switch */ /* MU_MESAG */ wind_update( END_UPDATE ); /* * Event handling routines zero out the event variable * to exit the application. */ } while( event ); gem_exit( 0 ); }
void tcp_local_fpga_close(void * server_context){ struct tcp_server_context_t * my_context = (struct tcp_server_context_t *)server_context; acc_close((struct acc_handler_t *)(my_context->acc_handler)); printf("tcp local fpga close\n"); return; }
/************************************************* lxt2_recordvars - add objects to be recorded ************************************************/ int lxt2_recordvars( int data, int reason ) { int update = 0; int objects = 0; int i; acc_initialize(); switch( reason ) { case reason_calltf: break; case reason_checktf: goto DONE; case reason_finish: if( lxt.inited ) { lxt2_close(); } goto DONE; case reason_rosynch: update = (lxt.updateList != NULL); while( lxt.updateList ) { info_p info; info = lxt.updateList; lxt2_dump( info, 0 ); lxt.updateList = info->updateNext; info->updateNext = 0; } if( update ) { lxt2_timemarkerp1(); } while( lxt.eventList ) { info_p info; info = lxt.eventList; lxt2_dump( info, 1 ); lxt.eventList = info->updateNext; info->updateNext = 0; } lxt2_nexttimemarker(); goto DONE; default: goto DONE; } ginstance = tf_getinstance(); /* * parse options first */ for( i = 1; i <= tf_nump(); ++i ) { handle object; if( tf_typep(i) == tf_nullparam ) { continue; } if( tf_typep(i) == tf_string ) { char* str = acc_fetch_tfarg_str(i); lxt2_option( str ); continue; } } /* * on first call, initialize structure */ if( !lxt.inited ) { lxt2_init(); } for( i = 1; i <= tf_nump(); ++i ) { handle object; if( tf_typep(i) == tf_nullparam ) { continue; } if( tf_typep(i) == tf_string ) { continue; } object = acc_handle_tfarg(i); if( !object ) { tf_error( "cannot find object" ); tf_dofinish(); goto DONE; } lxt2_add( object, lxt.depth ); objects++; } if( objects == 0 ) { #if DEBUG io_printf( "lxt2_recordvars: defaultpath=%s\n", acc_fetch_fullname(acc_handle_parent(acc_handle_tfinst())), lxt.depth ); #endif lxt2_add( acc_handle_parent(acc_handle_tfinst()), lxt.depth ); } lxt2_dump( lxt.objectList, 1 ); DONE: acc_close(); return 0; }
/* * main() * ================================================================ */ void main( void ) { int event, msg[8], key, nclicks; MRETS mrets; /* * See if we were run from the AUTO folder... */ gl_apid = appl_init(); /* Get the AES version #. TOS 3.0 is TT TOS */ AES_Version = _GemParBlk.global[0]; /* * Set up work_in to initialize VDI functions to useful values, * Get the physical workstation handle from the AES, then * open a virtual workstation and get our AES work area's extent. */ phys_handle = graf_handle(&gl_wchar,&gl_hchar,&gl_wbox,&gl_hbox ); Wind_get( 0, WF_WORKXYWH, ( WARGS *)&desk ); /* Call initialization hooks */ rsrc_init(); if( !open_vwork() ) { /* Unable to open workstation - exit application */ form_alert( 1, alert18 ); gem_exit( 0 ); } close_vwork(); gl_ncolors = work_out[13]; xres = work_out[0]; yres = work_out[1]; vhandle = 0; wind_init(); evnt_init(); /* Main event loop */ do { event = Evnt_multi( ev_mask, ev_clicks, ev_bmask, ev_bstate, &ev_m1, &ev_m2, ( WORD *)msg, ev_time, &mrets,(WORD *)&key,(WORD *)&nclicks ); wind_update( BEG_UPDATE ); /* Dispatch events. * It is possible to get more than one event at a time, so if the * order of event handling is important to you, change the order * in which they're handled here. */ if( event & MU_MESAG ) switch( msg[0] ) { case MN_SELECTED: break; case WM_REDRAW: case WM_TOPPED: case WM_CLOSED: case WM_FULLED: case WM_ARROWED: case WM_HSLID: case WM_VSLID: case WM_SIZED: case WM_MOVED: case WM_NEWTOP: do_windows( msg, &event ); break; case AC_OPEN: acc_open( msg ); break; case AP_TERM: case AC_CLOSE: acc_close( msg ); break; default: break; } /* switch */ /* MU_MESAG */ wind_update( END_UPDATE ); /* * Event handling routines zero out the event variable * to exit the application. */ } while( event ); gem_exit( 0 ); }