void vt_fmpiconst_init() { vt_get_mpi_f_bottom___(); vt_assert(vt_mpi_f_bottom_addr != NULL); vt_cntl_msg(2, "Detected address of MPI_BOTTOM=%x", vt_mpi_f_bottom_addr); #if (defined(HAVE_DECL_MPI_IN_PLACE) && HAVE_DECL_MPI_IN_PLACE) vt_get_mpi_f_in_place___(); vt_assert(vt_mpi_f_in_place_addr != NULL); vt_cntl_msg(2, "Detected address of MPI_IN_PLACE=%x", vt_mpi_f_in_place_addr); #endif /* HAVE_DECL_MPI_IN_PLACE */ vt_get_mpi_f_statuses_ignore___(); vt_assert(vt_mpi_f_status_ignore_addr != NULL); vt_cntl_msg(2, "Detected address of MPI_F_STATUS_IGNORE=%x", vt_mpi_f_status_ignore_addr); vt_assert(vt_mpi_f_statuses_ignore_addr != NULL); vt_cntl_msg(2, "Detected address of MPI_F_STATUSES_IGNORE=%x", vt_mpi_f_statuses_ignore_addr); #if !(defined(HAVE_DECL_MPI_STATUS_SIZE) && HAVE_DECL_MPI_STATUS_SIZE) vt_get_mpi_status_size___(&vt_mpi_status_size); vt_assert(vt_mpi_status_size > 0); vt_cntl_msg(2, "Detected value of MPI_STATUS_SIZE=%d", vt_mpi_status_size); #endif /* HAVE_DECL_MPI_STATUS_SIZE */ }
void VTThrd_createMutex(VTThrdMutex** mutex) { jvmtiError error; vt_assert(mutexInitMutex != NULL); error = (*jvmti)->RawMonitorEnter(jvmti, mutexInitMutex); vt_java_check_error(jvmti, error, "RawMonitorEnter"); if (*mutex == NULL) { static uint8_t rawmon_id = 0; char rawmon_name[10]; *mutex = (VTThrdMutex*)malloc(sizeof(VTThrdMutex)); if (*mutex == NULL) vt_error(); snprintf(rawmon_name, sizeof(rawmon_name) - 1, "rawmon%d", rawmon_id++); error = (*jvmti)->CreateRawMonitor(jvmti, rawmon_name, &((*mutex)->m)); vt_java_check_error(jvmti, error, "CreateRawMonitor"); } error = (*jvmti)->RawMonitorExit(jvmti, mutexInitMutex); vt_java_check_error(jvmti, error, "RawMonitorExit"); }
uint64_t correctTime( const uint32_t & process, const uint64_t & time ) const { // get master process id uint32_t mprocess = process & VT_TRACEID_BITMASK; std::map<uint32_t, UnifyControlS*>::const_iterator it = StreamId2UnifyCtl.find( mprocess ); vt_assert( it != StreamId2UnifyCtl.end() ); #ifdef VT_ETIMESYNC if( m_syncMethod == METHOD_ENHANCED ) { const int64_t & offset = it->second->sync_offset; const double & drift = it->second->sync_drift; return (uint64_t)( offset + (uint64_t)( drift * (double)time ) ); } else #endif // VT_ETIMESYNC { const int64_t * ltime = it->second->ltime; const int64_t * offset = it->second->offset; const double a = ( (double)( (int64_t)( ltime[1] - time ) ) / (double)( (int64_t)( ltime[1] - ltime[0] ) ) ); return (uint64_t)( time + offset[1] - (int64_t)( a * (double)offset[1] ) + (int64_t)( a * (double)offset[0] ) - m_minStartTime ); } }
// get start time of certain stream uint64_t getStartTime( const uint32_t & streamId ) const { std::map<uint32_t, uint64_t>::const_iterator it = m_streamId2StartTime.find( streamId ); vt_assert( it != m_streamId2StartTime.end() ); return it->second; }
void VTThrd_unlock(VTThrdMutex** mutex) { jvmtiError error; vt_assert(*mutex != NULL); error = (*jvmti)->RawMonitorExit(jvmti, (*mutex)->m); vt_java_check_error(jvmti, error, "RawMonitorExit"); }
void vt_getcpu_init() { vt_assert(vt_misc_cgid != 0); /* write counter definition */ vt_getcpu_cid = vt_def_counter(VT_CURRENT_THREAD, "CPU_ID", VT_CNTR_ABS | VT_CNTR_NEXT, vt_misc_cgid, "#"); }
uint32_t VTThrd_getThreadId() { jvmtiError error; uint32_t *tid; /* get thread-ID from thread-specific data */ error = (*jvmti)->GetThreadLocalStorage(jvmti, NULL, (void**)&tid); vt_java_check_error(jvmti, error, "GetThreadLocalStorage"); if (tid == NULL && vt_jvmti_agent->vm_is_dead) return 0; else vt_assert(tid != NULL); return *tid; }
void vt_esync_app_uctl_file(FILE* uctlFile) { Sync_Map* sync_map_temp; Sync_TsPerRun* sync_tsperrun_temp; Sync_TsPerPhase* sync_tsperphase_temp; vt_assert(uctlFile != NULL); /* write map ids */ sync_map_temp = SyncMapIdFirst; while(sync_map_temp) { fprintf(uctlFile, "%lli:%lli:%lli:", (long long int)(sync_map_temp->id + 1), (long long int)(sync_map_temp->time), (long long int)(sync_map_temp->duration)); sync_map_temp = sync_map_temp->next; } fprintf(uctlFile, "\n"); /* write synchronization information for each phase */ sync_tsperrun_temp = SyncTsPerRunFirst; while(sync_tsperrun_temp) { sync_tsperphase_temp = sync_tsperrun_temp->sync_phase; while(sync_tsperphase_temp) { fprintf(uctlFile, "%lli:%lli:%lli:%lli:%lli:%lli:", (long long int)(sync_tsperphase_temp->id1), (long long int)(sync_tsperphase_temp->id2), (long long int)(sync_tsperphase_temp->t1), (long long int)(sync_tsperphase_temp->t2), (long long int)(sync_tsperphase_temp->t3), (long long int)(sync_tsperphase_temp->t4)); sync_tsperphase_temp = sync_tsperphase_temp->next; } fprintf(uctlFile, "\n"); sync_tsperrun_temp = sync_tsperrun_temp->next; } }
static void register_region(struct profile_gen_struct* d, uint8_t rtype) { struct data_list_struct* data; char* rname = d->pu_name; uint32_t fid = VT_NO_ID; uint32_t begln = VT_NO_LNO; uint32_t endln = VT_NO_LNO; /* -- register file, if available -- */ if ( d->file_name != NULL ) { fid = vt_def_scl_file(d->file_name); begln = d->linenum; endln = d->endline; } /* -- generate region name, if region is a loop -- */ if ( rtype == VT_LOOP ) { char stname[10]; rname = (char*)malloc(1024 * sizeof(char)); if ( rname == NULL ) vt_error(); switch ( d->subtype ) { case DO_LOOP_SUBTYPE: strncpy(stname, "do_loop", 7+1); break; case WHILE_DO_SUBTYPE: strncpy(stname, "while_do", 8+1); break; case DO_WHILE_SUBTYPE: strncpy(stname, "do_while", 8+1); break; default: vt_assert(0); break; } /* -- add source location to name, if available -- */ if ( d->file_name != NULL ) { snprintf(rname, 1023, "%s @%s:%i-%i", stname, basename(d->file_name), begln, endln); } /* -- otherwise, add the internal compiler id to name -- */ else { snprintf(rname, 1023, "%s%i", stname, d->id); } } /* -- register region -- */ d->data = (uint32_t*)malloc(sizeof(uint32_t)); if ( d->data == NULL ) vt_error(); *((uint32_t*)(d->data)) = vt_def_region(rname, fid, begln, endln, NULL, rtype); /* -- free generated region name -- */ if ( rtype == VT_LOOP ) free( rname ); /* -- add pointer to stored data (region identifier) to list -- */ data = (struct data_list_struct*)malloc(sizeof(struct data_list_struct)); if ( data == NULL ) vt_error(); data->ptr = &(d->data); if ( data_list == NULL ) { data->next = NULL; data_list = data; } else { data->next = data_list->next; data_list->next = data; } }
void vt_esync_app_uctl_data(char** data) { Sync_Map* sync_map_temp; Sync_TsPerRun* sync_tsperrun_temp; Sync_TsPerPhase* sync_tsperphase_temp; size_t size; uint32_t i; vt_assert(*data != NULL); size = strlen(*data); /* the first iteration calculates the size needed for the additional data and the second iteration writes them */ for(i = 0; i < 2; i++) { /* map ids */ sync_map_temp = SyncMapIdFirst; while(sync_map_temp) { if (i == 0) { size += 3 * (16 + 1); } else /* i == 1 */ { sprintf(*data + strlen(*data), "%llx:%llx:%llx:", (long long int)(sync_map_temp->id + 1), (long long int)(sync_map_temp->time), (long long int)(sync_map_temp->duration)); } sync_map_temp = sync_map_temp->next; } if (i == 0) size++; else /* i == 1 */ strcat(*data, "\n"); /* synchronization information for each phase */ sync_tsperrun_temp = SyncTsPerRunFirst; while(sync_tsperrun_temp) { sync_tsperphase_temp = sync_tsperrun_temp->sync_phase; while(sync_tsperphase_temp) { if (i == 0) { size += 6 * (16 + 1); } else /* i == 1 */ { sprintf(*data + strlen(*data), "%llx:%llx:%llx:%llx:%llx:%llx:", (unsigned long long int)(sync_tsperphase_temp->id1), (unsigned long long int)(sync_tsperphase_temp->id2), (unsigned long long int)(sync_tsperphase_temp->t1), (unsigned long long int)(sync_tsperphase_temp->t2), (unsigned long long int)(sync_tsperphase_temp->t3), (unsigned long long int)(sync_tsperphase_temp->t4)); } sync_tsperphase_temp = sync_tsperphase_temp->next; } if (i == 0) size++; else /* i == 1 */ strcat(*data, "\n"); sync_tsperrun_temp = sync_tsperrun_temp->next; } /* enlarge buffer for uctl data at the end of the first iteration */ if (i == 0) { *data = (char*)realloc(*data, size * sizeof(char)); if (*data == NULL) vt_error(); } } }