/* 指导语句: #pragma omp parallel 结构功能: parallel用户子函数 函数功能: parallel中调用的用户子函数 */ static void callme_par (void *p1) { TaskInfo old_task; char fun_name[30] = "Parallel_User_fun_"; char id [10]; Record_Event Event = Event_init (); old_task = current_task; current_task = create_itask (); //Is it necessary to add this task to the thread team ? add_itask (current_task); itoa (par_uf_id, id); strcat (fun_name, id); Event.event_name = fun_name; Event.eid = 234; Event.type = NONE; Event.omp_rank = get_thread_num (); Event.omp_level = get_level (); Event.p_rank = omp_get_ancestor_thread_num (get_level () - 1); Event.p_task_id_start = current_task.task_parent_id; Event.task_id_start = current_task.task_id; Event.task_state_start = TASK_CREATE; if (par_uf == NULL) { printf_d("Error! Invalid initialization of 'par_uf'\n"); return ; } if (PAPI == PAPI_ON) { PAPI_get_info (fun_name, 0, PAPI_THREAD); Event.starttime = gettime (); par_uf (p1); Event.endtime = gettime (); PAPI_get_info (fun_name, 1, PAPI_THREAD); } else { Event.starttime = gettime (); par_uf (p1); Event.endtime = gettime (); } Event.p_task_id_end = current_task.task_parent_id; Event.task_id_end = current_task.task_id; Event.task_state_end = TASK_END; remove_itask (current_task); current_task = old_task; Record (&Event, OMPI_TRACE); }
/* callme_par (char*) With the same header as the routine to be called by the SMP runtime, just acts as a trampoline to this call. Each thread runs the very same routine with different params. */ static void callme_par (char *ptr) { void *p = *((void**) par_uf); #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME": callme_par: ptr=%p\n", ptr); fprintf (stderr, PACKAGE_NAME": callme_par: par_uf=%p\n", p); #endif Extrae_OpenMP_UF_Entry (p); Backend_Leave_Instrumentation (); /* We're entering in user code */ par_uf (ptr); Extrae_OpenMP_UF_Exit (); }