int main(int argc, char *argv[]) { errval_t err; coreid_t mycore = disp_get_core_id(); debug_printf("This is mem_bench\n"); if (argc >= 2) { assert(mycore == 0); int num_cores = strtol(argv[1], NULL, 10); debug_printf("spawning on %d cores\n", num_cores); err = init_tracing(); if (err_is_fail(err)) { DEBUG_ERR(err, "initialising tracing"); return EXIT_FAILURE; } prepare_dump(); start_tracing(); char *path = argv[0]; argv[1] = NULL; for (int i = 1; i <= num_cores; i++) { err = spawn_program(i, path, argv, NULL, 0, NULL); if (err_is_fail(err)) { DEBUG_ERR(err, "failed spawn %d", i); return EXIT_FAILURE; } debug_printf("spawned on core %d\n", i); } //start_tracing(); run_benchmark_0(mycore); ns_barrier_master(1, num_cores, "mem_bench"); debug_printf("all benchmarks completed\n"); stop_tracing(); // dump_trace(); } else { run_benchmark(mycore); } return EXIT_SUCCESS; }
void start_collector(void) { pthread_t collector_thread; int num_cpus; Collector_args_s *args; int i; int rc; Syscall_count = ezalloc(Num_syscalls * sizeof(*Syscall_count)); init_tracing(); enable_sys_enter(); if (Trace_exit) { enable_sys_exit(); } num_cpus = sysconf(_SC_NPROCESSORS_CONF); if (Dump) num_cpus = 1; // for now while playing with it args = ezalloc(num_cpus * sizeof(Collector_args_s)); for (i = 0; i < num_cpus; i++, args++) { args->cpu_id = i; rc = pthread_create(&collector_thread, NULL, Dump ? dump_collector : collector, args); if (rc) fatal("Couldn't create collector %d:", rc); } }
int main(int argc, char *argv[]) { struct sigaction sa; sigset_t allsigs; struct itimerspec timerspec; struct timespec now; timer_t timer; struct sigevent timer_event; if(argc != 5) { fprintf(stderr, "Argu ERROR! ./calib_stage1 period count priority taskId\n"); exit(EXIT_FAILURE); } /* We do not need a Wcet this time */ /* wcet = atoi(argv[1]); */ period = atoi(argv[1]); count = atoi(argv[2]); priority = atoi(argv[3]); gu16RefID = atoi(argv[4]); printf("Task[%d] period[%d] count[%d] priority[%d]\n", gu16RefID, period, count, priority); sprintf(gacFileName, "Task%04d.trace", gu16RefID); /* Set SCHED_FIFO */ set_sched(); /* INIT Tracing */ init_tracing(); gs32PID = getpid(); /* Bind a sighandler, using SIGRTMIN */ sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = work; if (sigaction(SIGRTMIN, &sa, NULL) < 0) { perror("sigaction error"); exit(EXIT_FAILURE); } /* Bind another sighander, using SIGINT */ sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = exit_dump; if (sigaction(SIGINT, &sa, NULL) < 0) { perror("sigaction error"); exit(EXIT_FAILURE); } /* We don't need an external trigger */ /* raise(SIGSTOP); */ /* the timer */ timerspec.it_interval.tv_sec = period / 1000; /* Correct the Timer Interval Error Regardless of rdtsc*/ timerspec.it_interval.tv_nsec = (period % 1000) * 1000000; /* the start time */ /* if(clock_gettime(CLOCK_MONOTONIC, &now) < 0) { */ if(clock_gettime(CLOCK_REALTIME, &now) < 0) { perror("clock_gettime"); exit(EXIT_FAILURE); } // Start one second from now. /* add_record_task(TASK_EVENT_SET_TIMER, gu16RefID, gs32PID, 0); */ timerspec.it_value.tv_sec = now.tv_sec + 1; /* Correct the Timer Start Error Regardless of rdtsc*/ timerspec.it_value.tv_nsec = now.tv_nsec; timer_event.sigev_notify = SIGEV_SIGNAL; timer_event.sigev_signo = SIGRTMIN; timer_event.sigev_value.sival_ptr = (void *)&timer; if (timer_create(CLOCK_REALTIME, &timer_event, &timer) < 0) { perror("timer_create"); exit(EXIT_FAILURE); } if (timer_settime(timer, TIMER_ABSTIME, &timerspec, NULL) < 0) { perror("timer_settime"); exit(EXIT_FAILURE); } sigemptyset(&allsigs); while(1) { sigsuspend(&allsigs); } exit(EXIT_SUCCESS); }
tsd_t *ReginaInitializeProcess(void) { int OK; if (__regina_tsd_initialized) return(&__regina_tsd); __regina_tsd_initialized = 1; /* Set up the current (single) tsd_t:*/ /* Default all values to zero */ memset(&__regina_tsd,0,sizeof(__regina_tsd)); __regina_tsd.MTMalloc = MTMalloc; __regina_tsd.MTFree = MTFree; __regina_tsd.MTExit = MTExit; /* Since the local data structure contains a memory chain for the memory * management we initialize it first. */ if ((__regina_tsd.mt_tsd = malloc(sizeof(mt_tsd_t))) == NULL) return(NULL); /* This is a catastrophy */ memset(__regina_tsd.mt_tsd,0,sizeof(mt_tsd_t)); OK = init_memory(&__regina_tsd); /* Initialize the memory module FIRST*/ /* Without the initial memory we don't have ANY chance! */ if (!OK) return(NULL); /* * Some systems with an own MT file don't compile in MT mode. But they * still are systems of that kind. */ #if defined(WIN32) || defined(__WIN32__) { extern OS_Dep_funcs __regina_OS_Win; __regina_tsd.OS = &__regina_OS_Win; } #elif defined(OS2) && !defined(DOS) { extern OS_Dep_funcs __regina_OS_Os2; __regina_tsd.OS = &__regina_OS_Os2; } #elif defined(GO32) { extern OS_Dep_funcs __regina_OS_Other; __regina_tsd.OS = &__regina_OS_Other; } #elif defined(unix) || defined(__unix__) || defined(__unix) || defined(__QNX__) || defined(__BEOS__) || defined(SKYOS) || ( defined( __APPLE_CC__ ) && defined( __MACH__ ) ) { extern OS_Dep_funcs __regina_OS_Unx; __regina_tsd.OS = &__regina_OS_Unx; } #else { extern OS_Dep_funcs __regina_OS_Other; __regina_tsd.OS = &__regina_OS_Other; } #endif __regina_tsd.OS->init(); OK |= init_vars(&__regina_tsd); /* Initialize the variable module */ OK |= init_stacks(&__regina_tsd); /* Initialize the stack module */ OK |= init_filetable(&__regina_tsd); /* Initialize the files module */ OK |= init_math(&__regina_tsd); /* Initialize the math module */ OK |= init_spec_vars(&__regina_tsd); /* Initialize the interprt module */ OK |= init_tracing(&__regina_tsd); /* Initialize the tracing module */ OK |= init_builtin(&__regina_tsd); /* Initialize the builtin module */ OK |= init_client(&__regina_tsd); /* Initialize the client module */ OK |= init_library(&__regina_tsd); /* Initialize the library module */ OK |= init_rexxsaa(&__regina_tsd); /* Initialize the rexxsaa module */ OK |= init_shell(&__regina_tsd); /* Initialize the shell module */ OK |= init_envir(&__regina_tsd); /* Initialize the envir module */ OK |= init_expr(&__regina_tsd); /* Initialize the expr module */ OK |= init_error(&__regina_tsd); /* Initialize the error module */ #ifdef VMS OK |= init_vms(&__regina_tsd); /* Initialize the vmscmd module */ OK |= init_vmf(&__regina_tsd); /* Initialize the vmsfuncs module */ #endif OK |= init_arexxf(&__regina_tsd); /* Initialize the arxfuncs modules */ __regina_tsd.loopcnt = 1; /* stupid r2perl-module */ __regina_tsd.traceparse = -1; __regina_tsd.thread_id = 1; if (!OK) exiterror( ERR_STORAGE_EXHAUSTED, 0 ) ; return(&__regina_tsd); }
static int run_master(coreid_t mycore, int argc, char *argv[]) { errval_t err; int num_spawn = strtol(argv[1], NULL, 10); int first_core = mycore + 1; debug_printf("spawning on %d cores\n", num_spawn); #ifdef TRACING err = init_tracing(); if (err_is_fail(err)) { DEBUG_ERR(err, "initialising tracing"); return EXIT_FAILURE; } // start_tracing(); prepare_dump(); #endif trace_event(TRACE_SUBSYS_MEMTEST, TRACE_EVENT_MEMTEST_STARTED, 0); // spawn some dispatchers char *path = argv[0]; // reuse argv and path argv[1] = NULL; for (int i = first_core; i <= num_spawn; i++) { err = spawn_program(i, path, argv, NULL, 0, NULL); if (err_is_fail(err)) { DEBUG_ERR(err, "spawning on core %d", i); } else { //debug_printf("dispatcher %d on core %d spawned\n", i, i); } } trace_event(TRACE_SUBSYS_MEMTEST, TRACE_EVENT_MEMTEST_WAIT, 0); // debug_printf("waiting for all spawns to start\n"); err = ns_barrier_master(first_core, num_spawn, "mem_bench_ready"); if (err_is_fail(err)) { DEBUG_ERR(err, "failed barrier_master"); return EXIT_FAILURE; } start_tracing(); trace_event(TRACE_SUBSYS_MEMTEST, TRACE_EVENT_MEMTEST_RUN, 0); // run_benchmark(mycore, MAX_REQUESTS_0); trace_event(TRACE_SUBSYS_MEMTEST, TRACE_EVENT_MEMTEST_WAIT, 0); // debug_printf("waiting for all spawns to complete\n"); err = ns_barrier_master(first_core, num_spawn, "mem_bench_finished"); if (err_is_fail(err)) { DEBUG_ERR(err, "failed barrier_master"); return EXIT_FAILURE; } trace_event(TRACE_SUBSYS_MEMTEST, TRACE_EVENT_MEMTEST_DONE, 0); debug_printf("all benchmarks completed\n"); #ifdef TRACING stop_tracing(); // dump_trace(); #endif return EXIT_SUCCESS; }
void init_soar_agent(agent* thisAgent) { /* JC ADDED: initialize the rhs function linked list */ thisAgent->rhs_functions = NIL; /* --- initialize everything --- */ init_symbol_tables(thisAgent); create_predefined_symbols(thisAgent); init_production_utilities(thisAgent); init_built_in_rhs_functions (thisAgent); init_rete (thisAgent); init_lexer (thisAgent); init_firer (thisAgent); init_decider (thisAgent); init_soar_io (thisAgent); init_chunker (thisAgent); init_tracing (thisAgent); init_explain(thisAgent); /* AGR 564 */ select_init(thisAgent); predict_init(thisAgent); init_memory_pool( thisAgent, &( thisAgent->gds_pool ), sizeof( goal_dependency_set ), "gds" ); init_memory_pool( thisAgent, &( thisAgent->rl_info_pool ), sizeof( rl_data ), "rl_id_data" ); init_memory_pool( thisAgent, &( thisAgent->rl_et_pool ), sizeof( rl_et_map ), "rl_et" ); init_memory_pool( thisAgent, &( thisAgent->rl_rule_pool ), sizeof( rl_rule_list ), "rl_rules" ); init_memory_pool( thisAgent, &( thisAgent->wma_decay_element_pool ), sizeof( wma_decay_element ), "wma_decay" ); init_memory_pool( thisAgent, &( thisAgent->wma_decay_set_pool ), sizeof( wma_decay_set ), "wma_decay_set" ); init_memory_pool( thisAgent, &( thisAgent->wma_wme_oset_pool ), sizeof( wma_pooled_wme_set ), "wma_oset" ); init_memory_pool( thisAgent, &( thisAgent->wma_slot_refs_pool ), sizeof( wma_sym_reference_map ), "wma_slot_ref" ); init_memory_pool( thisAgent, &( thisAgent->epmem_wmes_pool ), sizeof( epmem_wme_stack ), "epmem_wmes" ); init_memory_pool( thisAgent, &( thisAgent->epmem_info_pool ), sizeof( epmem_data ), "epmem_id_data" ); init_memory_pool( thisAgent, &( thisAgent->smem_wmes_pool ), sizeof( smem_wme_stack ), "smem_wmes" ); init_memory_pool( thisAgent, &( thisAgent->smem_info_pool ), sizeof( smem_data ), "smem_id_data" ); init_memory_pool( thisAgent, &( thisAgent->epmem_literal_pool ), sizeof( epmem_literal), "epmem_literals" ); init_memory_pool( thisAgent, &( thisAgent->epmem_pedge_pool ), sizeof( epmem_pedge ), "epmem_pedges" ); init_memory_pool( thisAgent, &( thisAgent->epmem_uedge_pool ), sizeof( epmem_uedge ), "epmem_uedges" ); init_memory_pool( thisAgent, &( thisAgent->epmem_interval_pool ), sizeof( epmem_interval ), "epmem_intervals" ); thisAgent->epmem_params->exclusions->set_value( "epmem" ); thisAgent->epmem_params->exclusions->set_value( "smem" ); thisAgent->smem_params->base_incremental_threshes->set_string( "10" ); #ifdef REAL_TIME_BEHAVIOR /* RMJ */ init_real_time(thisAgent); #endif /* --- add default object trace formats --- */ add_trace_format (thisAgent, FALSE, FOR_ANYTHING_TF, NIL, "%id %ifdef[(%v[name])]"); add_trace_format (thisAgent, FALSE, FOR_STATES_TF, NIL, "%id %ifdef[(%v[attribute] %v[impasse])]"); { Symbol *evaluate_object_sym; evaluate_object_sym = make_sym_constant (thisAgent, "evaluate-object"); add_trace_format (thisAgent, FALSE, FOR_OPERATORS_TF, evaluate_object_sym, "%id (evaluate-object %o[object])"); symbol_remove_ref (thisAgent, evaluate_object_sym); } /* --- add default stack trace formats --- */ add_trace_format (thisAgent, TRUE, FOR_STATES_TF, NIL, "%right[6,%dc]: %rsd[ ]==>S: %cs"); add_trace_format (thisAgent, TRUE, FOR_OPERATORS_TF, NIL, "%right[6,%dc]: %rsd[ ] O: %co"); reset_statistics (thisAgent); /* RDF: For gSKI */ init_agent_memory(thisAgent); /* END */ }