Skip to content

[Question]: Why is collApiPoolBase incremented twice for the same event in profiler code? #1908

@xxxxx-ctrl

Description

@xxxxx-ctrl

Question

In the profiler, collApiPoolBase and p2pApiPoolBase are incremented both in updateEvent() (on finalization) and in exampleProfilerStartEvent() (when reusing a groupApi).

What is the purpose of incrementing them during reuse? Could this lead to double-incrementing the same event’s pool base?

code:nccl/ext-profiler/example/plugin.cc
exampleProfilerStartEvent:

 while (!profilerQueueEmpty(&event->collApiEvents)) {
        struct collApi *collApiEvent = profilerQueueDequeue(&event->collApiEvents);
        resetTaskEvents(collApiEvent, ctx);
        __atomic_fetch_add(&ctx->collApiPoolBase, 1, __ATOMIC_RELAXED);
}

updateEvent:

else if (type == ncclProfileCollApi) {
    struct collApi* event = (struct collApi*) handle;
    if (__atomic_sub_fetch(&event->refCount, 1, __ATOMIC_RELAXED) == 0) {
      event->stopTs = gettime() - startTime;
      __atomic_fetch_add(&event->ctx->collApiPoolBase, 1, __ATOMIC_RELAXED);
    }
    updateEvent(event->parent);
    return;
  }

If I’m misunderstanding the lifecycle, please let me know. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions