我试图在CUDA程序中跟踪3个计数器,如下所示:
void *
sampling_func(void *arg)
{
CUptiResult cuptiErr;
CUpti_EventGroup eventGroup;
CUpti_EventID gldrID, gldhitID, gldmissID; //eventId;
size_t bytesRead;
uint64_t eventVal;
cuptiErr = cuptiSetEventCollectionMode(context,
CUPTI_EVENT_COLLECTION_MODE_CONTINUOUS);
CHECK_CUPTI_ERROR(cuptiErr, "cuptiSetEventCollectionMode");
cuptiErr = cuptiEventGroupCreate(context, &eventGroup, 0);
CHECK_CUPTI_ERROR(cuptiErr, "cuptiEventGroupCreate");
cuptiErr = cuptiEventGetIdFromName(device, gld_request, &gldrID); //"gld_request"
CHECK_CUPTI_ERROR(cuptiErr, "cuptiEventGetIdFromName");
cuptiErr = cuptiEventGetIdFromName(device, l1_gld_hit, &gldhitID); //"l1_global_load_hit"
CHECK_CUPTI_ERROR(cuptiErr, "cuptiEventGetIdFromName");
cuptiErr = cuptiEventGetIdFromName(device, l1_gld_miss, &gldmissID); //"l1_global_load_miss"
CHECK_CUPTI_ERROR(cuptiErr, "cuptiEventGetIdFromName");
cuptiErr = cuptiEventGroupAddEvent(eventGroup, gldrID);
CHECK_CUPTI_ERROR(cuptiErr, "cuptiEventGroupAddEvent");
cuptiErr = cuptiEventGroupAddEvent(eventGroup, gldhitID);
CHECK_CUPTI_ERROR(cuptiErr, "cuptiEventGroupAddEvent");
cuptiErr = cuptiEventGroupAddEvent(eventGroup, gldmissID);
CHECK_CUPTI_ERROR(cuptiErr, "cuptiEventGroupAddEvent");
cuptiErr = cuptiEventGroupEnable(eventGroup);
CHECK_CUPTI_ERROR(cuptiErr, "cuptiEventGroupEnable");
虽然在运行时,我收到以下错误:
:Error CUPTI_ERROR_INVALID_EVENT_ID for CUPTI API function 'cuptiEventGroupAddEvent'.
这指向cuptiEventGroupAddEvent
的{{1}}发送电话。我尝试了各种组合,似乎我不能同时添加更多的计数器,我认为不应该是这种情况。此外,所有这些计数器都可以很好地工作。
我正在使用CUDA计算兼容性2.0设备。
有什么建议吗?我做错了什么?
顺便说一句,我正在关注link的代码。
答案 0 :(得分:2)
好的,问题在于我正在研究的配置文件计数器:
“gld_request”和,“l1_global_load_hit”和l1_global_load_miss“属于不同的'域'。不幸的是,CUDA错误并不是非常具体。
无论如何,一旦我为每个域创建了两个单独的eventGroup,问题就消失了。
答案 1 :(得分:2)
CUPTI正是为此提供了cuptiEventGroupSetsCreate()
API。您可以传入一系列事件ID,并将事件组集作为输出。
事件组集是事件组的集合,每个事件组都可以在一次传递中进行分析。这样,您就不必担心手动将事件ID排序到单独的事件组中。
这里有一个简短的片段,可以让您大致了解如何使用事件组集:
CUpti_EventID eventIds[3];
cuptiEventGetIdFromName(device, "name_of_event_0", &eventIds[0]);
cuptiEventGetIdFromName(device, "name_of_event_1", &eventIds[1]);
cuptiEventGetIdFromName(device, "name_of_event_2", &eventIds[2]);
CUpti_EventGroupSets *sets = NULL;
cuptiEventGroupSetsCreate(context, sizeof(eventIds), eventIds, &sets);
// Iterate over each set
for (int i = 0; i < sets->numSets; i++) {
// Iterate over each event group in the set
for (int j = 0; j < sets->sets[i].numEventGroups; j++) {
// Enable the event group
cuptiEventGroupEnable(sets->sets[i].eventGroups[j]);
}
}