//! Return a delta from the start of the timers cl_time EventList::getEventDelta(cl_event input_event, cl_profiling_info param_name ) { cl_time diff; diff = getEventValue(input_event,param_name) - this->gpu_timer_start; return diff; }
// Print the event information to the screen void EventList::printEvents() { for(int i = 0; i < (int)this->event_list.size(); i++) { printf("%s (%s)\ \n\tQueued: %lu\ \n\tSubmitted: %lu\ \n\tStarted: %lu\ \n\tCompleted: %lu\n", this->event_list[i]->name, this->event_list[i]->type, ulong( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_QUEUED) - this->gpu_timer_start ), ulong( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_SUBMIT) - this->gpu_timer_start ), ulong( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_START) - this->gpu_timer_start ), ulong( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_END) - this->gpu_timer_start ) ); } for(int i = 0; i < (int)this->user_event_list.size(); i++) { printf("%s (%s)\ \n\tQueued: %lu\ \n\tSubmitted: %lu\ \n\tStarted: %lu\ \n\tCompleted: %lu\n", this->user_event_list[i]->name, this->user_event_list[i]->type, ulong( getUserEventValue(this->user_event_list[i]->event, CL_PROFILING_COMMAND_QUEUED) - this->cpu_timer_start ), ulong( getUserEventValue(this->user_event_list[i]->event, CL_PROFILING_COMMAND_SUBMIT) - this->cpu_timer_start ), ulong( getUserEventValue(this->user_event_list[i]->event, CL_PROFILING_COMMAND_START) - this->cpu_timer_start ), ulong( getUserEventValue(this->user_event_list[i]->event, CL_PROFILING_COMMAND_END) - this->cpu_timer_start) ) ; } }
int CUDA_read( hwd_context_t * ctx, hwd_control_state_t * ctrl, long_long ** events, int flags ) { ( void ) ctx; ( void ) flags; CUDA_control_state_t * CUDA_ctrl = ( CUDA_control_state_t * ) ctrl; if ( 0 != getEventValue( CUDA_ctrl->counts, CUDA_ctrl->eventGroup, CUDA_ctrl->addedEvents ) ) return ( PAPI_ENOSUPP ); *events = CUDA_ctrl->counts; return ( PAPI_OK ); }
inline nanos_event_value_t InstrumentationDictionary::getEventValue ( const std::string &key, const std::string &value ) { return getEventValue ( key.c_str(), value.c_str() ); }
// Create a file and dump the event information void EventList::dumpEvents(char* path, char * ip_filename) { FILE* fp = NULL; char * filename; // Construct a filename based on the current time if (ip_filename == NULL) filename = this->createFilenameWithTimestamp(); else { filename = (char *)malloc(strlen(ip_filename)*sizeof(char)); strcpy(filename, ip_filename); } // Create string to hold the path + filename char* fullpath = new char[strlen(path)+strlen(filename)+1]; // Concat the path and filename into the destination string strcpy(fullpath, path); strcat(fullpath, filename); // Try to open the file for writing fp = fopen(fullpath, "w"); if(fp == NULL) { printf("Error opening %s\n", fullpath); exit(-1); } // Write some information out about the environment cl_int status; size_t devInfoSize; char* devInfoStr = NULL; // Get the device name status = clGetDeviceInfo(this->device, CL_DEVICE_NAME, 0, NULL, &devInfoSize); if(status != CL_SUCCESS) { printf("Device info failed\n"); exit(-1); } devInfoStr = new char[devInfoSize]; status = clGetDeviceInfo(this->device, CL_DEVICE_NAME, devInfoSize, devInfoStr, NULL); if(status != CL_SUCCESS) { printf("Device info failed\n"); exit(-1); } // Write the device name fprintf(fp, "Info;\t%s\n", devInfoStr); delete devInfoStr; devInfoStr = NULL; // Get the device driver version status = clGetDeviceInfo(this->device, CL_DRIVER_VERSION, 0, NULL, &devInfoSize); if(status != CL_SUCCESS) { printf("Device info failed\n"); exit(-1); } devInfoStr = new char[devInfoSize]; status = clGetDeviceInfo(this->device, CL_DRIVER_VERSION, devInfoSize, devInfoStr, NULL); if(status != CL_SUCCESS) { printf("Device info failed\n"); exit(-1); } // Write the device driver version fprintf(fp, "Info;\tDriver version %s\n", devInfoStr); delete devInfoStr; // Write the hostname #ifndef _WIN32 char hostname[50]; if(gethostname(hostname, 50) != 0) { printf("Error getting hostname\n"); } else { fprintf(fp, "Info;\tHost %s\n", hostname); } #endif printf("Timer start %lu \n",this->gpu_timer_start) ; // Write the events to file with each field separated by semicolons for(int i = 0; i < (int)this->event_list.size(); i++) { // fprintf(fp, "%s;\t%s;\t%f;\t%f;\t%f;\t%f\n", fprintf(fp, "%s;\t%s;\t%llu;\t%llu;\t%llu;\t%llu\n", this->event_list[i]->type, this->event_list[i]->name, long( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_QUEUED) - this->gpu_timer_start ), long( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_SUBMIT) - this->gpu_timer_start ), long( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_START) - this->gpu_timer_start ), long( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_END) - this->gpu_timer_start ) ); /* printf("%s;\t%s;\t%lu;\t%lu;\t%lu;\t%lu\n", this->event_list[i]->type, this->event_list[i]->name, ulong( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_QUEUED) - this->gpu_timer_start ), ulong( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_SUBMIT) - this->gpu_timer_start ), ulong( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_START) - this->gpu_timer_start ), ulong( getEventValue(this->event_list[i]->event, CL_PROFILING_COMMAND_END) - this->gpu_timer_start) ); */ } for(int i = 0; i < (int)this->user_event_list.size(); i++) { fprintf(fp, "%s;\t%s;\t%lu;\t%lu;\t%lu;\t%lu\n", this->user_event_list[i]->type, this->user_event_list[i]->name, ulong( getUserEventValue(this->user_event_list[i]->event, CL_PROFILING_COMMAND_QUEUED) - this->cpu_timer_start ), ulong( getUserEventValue(this->user_event_list[i]->event, CL_PROFILING_COMMAND_SUBMIT) - this->cpu_timer_start ), ulong( getUserEventValue(this->user_event_list[i]->event, CL_PROFILING_COMMAND_START) - this->cpu_timer_start ), ulong( getUserEventValue(this->user_event_list[i]->event, CL_PROFILING_COMMAND_END) - this->cpu_timer_start ) ); } //!Bound check if(event_list.size() > 0) { long long start_t = getEventValue(this->event_list[0]->event, CL_PROFILING_COMMAND_QUEUED) - this->gpu_timer_start ; long long end_t = getEventValue(this->event_list[event_list.size() - 1]->event,CL_PROFILING_COMMAND_END) - this->gpu_timer_start; printf("Time first %llu \t last %llu \t Diff %f \n",start_t, end_t, float((end_t - start_t))/(1000.0f*1000.0f) ); } else printf("WARNING - No events Detected\n "); fclose(fp); delete filename; delete fullpath; }