/* 指导语句: #pragma omp parallel for 结构功能: user function of parallel for struct ,an implicit task 函数功能: for指导语句中调用的用户子函数 */ static void callme_pardo(void *p1) { TaskInfo old_task; char fun_name[30] = "Parallel_User_do_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 (pardo_uf_id, id); strcat (fun_name, id); Event.event_name = fun_name; Event.eid = 233; 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 (pardo_uf == NULL) { printf_d("Error! Invalid initialization of 'pardo_uf'\n"); return ; } if (PAPI == PAPI_ON) { PAPI_get_info (fun_name, 0, PAPI_THREAD); Event.starttime = gettime (); pardo_uf (p1); Event.endtime = gettime (); PAPI_get_info (fun_name, 1, PAPI_THREAD); } else { Event.starttime = gettime (); pardo_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_pardo (char*, ull, ull) With the same header as the routine to be called by the SMP runtime, just acts as a trampoline to this call. Invokes the required iterations of the parallel do loop. */ static void callme_pardo (char *ptr, long lbnd, long ubnd, unsigned thid) { void *p = *((void**) pardo_uf); #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME": callme_pardo: ptr=%p lbnd=%ld ubnd=%ld thid=%u\n", ptr, lbnd, ubnd, thid); fprintf (stderr, PACKAGE_NAME": callme_pardo: pardo_uf=%p\n", p); #endif Extrae_OpenMP_UF_Entry (p); Backend_Leave_Instrumentation (); /* We're entering in user code */ pardo_uf (ptr, lbnd, ubnd, thid); Extrae_OpenMP_UF_Exit (); }