f1308997d0
Device API (Experimental) * Introduces device-side APIs to integrate NCCL communication directly into application kernels. * Supports LSA (Load/Store Access) for CUDA P2P communication over NVLink and some PCIe platforms. * Supports Multimem for hardware multicast using NVLink SHARP. * Adds initial framework for GIN (GPU-Initiated Networking), currently under development. * Introduces device communicators created using ncclDevCommCreate. * Enables device-side communication operations with synchronization (ncclLsaBarrierSession) and memory accessors (ncclGetLsaPointer, ncclGetLsaMultimemPointer). * Experimental APIs - signatures and functionality may evolve in future releases. * No ABI compatibility is guaranteed — applications must be recompiled with each new NCCL release. Symmetric memory improvements * Support for aggregating symmetric operations using ncclGroupStart/End APIs. * Reimplement symmetric kernels using device API. New Host APIs * Introduce new host collective APIs: ncclAlltoAll, ncclScatter, ncclGather. CE (Copy Engine) Collectives * Reduce SM utilization for alltoall, scatter, gather, and allgather within a single (MN)NVL domain. * Free up SM capacity for the application to do computation at the same time. * To enable the feature for ncclAllGather, ncclAlltoAll, ncclGather, ncclScatter, register buffers into symmetric windows and use the NCCL_CTA_POLICY_ZERO flag in the communicator config_t. NCCL Inspector Plugin * Introduces an Inspector plugin for always-on performance monitoring. * Produces structured JSON output with metadata, execution time, bandwidth, and optional event traces for each NCCL operation. * Enables integration with analysis tools such as Performance Exporter to visualize NCCL performance bottlenecks. * Lightweight to enable via environment variables NCCL_PROFILER_PLUGIN and NCCL_INSPECTOR_ENABLE. CMake support (Experiemental) * Adds a CMake build system as an alternative to existing Makefiles. * Known issues: pkg.build and Device API currently do not work with CMake. * The known issues will be addressed in a future release. Decreased max CTA count from 32 to 16 on Blackwell * SM overhead is decreased by 50% with this improvement. * This may cause some perf drop on Blackwell because of the reduced SM usage. * If the extra SM capacity is not desired, two options are available to restore to previous behavior: 1) Setting NCCL_MIN_CTAS=32 NCCL_MAX_CTAS=32 environment variables; 2) setting communicator config to over-write max CTA count to 32. * Based on community feedback, future versions may consider different trade-offs between performance and SM overhead. Plugins * Network * App-aware Network plugin. NCCL passes information about communication operations to be executed on the network end point. This allows for better tuning of network end points and their use in the plugins. * Improve handling of physical and virtual network devices and load/unload. * Network plugin version 11 - add explicit context and communication ID support for per communicator init/finalize. * Add Multi-Request Net API. Using this will help NCCL to anticipate multiple send/recv requests and optimize for it. See maxMultiRequestSize field in ncclNetProperties_v11_t. * Profiler * Add support for API events (group, collective, and p2p) and for tracking kernel launches in the profiler plugin. * Add Inspector Profiler Plugin (see section above). * Add a hook to Google’s CoMMA profiler on github. * Tuner * Expose NCCL tuning constants at tuner initialization via ncclTunerConstants_v5_t. * Add NVL Domain Information API. * Support multiple plugin types from a single shared object. New Parameterization and ncclConfig changes: * Add new option NCCL_MNNVL_CLIQUE_ID=-2 which will use rack serial number to partition the MNNVL clique. This will limit NVLink domains to GPUs within a single rack. * Add NCCL_NETDEVS_POLICY to control how NET devices are assigned to GPUs. The default (AUTO) is the policy used in previous versions. * Add NCCL_SINGLE_PROC_MEM_REG_ENABLE control variable to enable NVLS UB registration in the “one process, multiple ranks” case as opt in. * Move nChannelsPerNetPeer into ncclConfig. NCCL_NCHANNELS_PER_NET_PEER can override the value in ncclConfig. * Enable PxN over C2C by default * PxN over C2C will improve performance for Grace-Blackwell platforms by allowing NCCL to leverage the NIC attached to a peer GPU over NVLINK, C2C, and PCIe. * This behavior can be overridden by setting NCCL_PXN_C2C=0. Other Improvements: * Allow FP8 support for non-reductive operations on pre sm90 devices. (See https://github.com/pytorch/pytorch/pull/151594#discussion_r2135777776) * Fix NVLS+CollNet and temporarily disables COLLNET_CHAIN for >8 GPUs. * Only consider running interfaces for socket traffic. NCCL will not attempt to use interfaces that do not have the IFF_RUNNING bit. (https://github.com/NVIDIA/nccl/issues/1798) * Modernize mutex management. Convert to std::mutex and std::lock_guard. * Remove sm35 and sm50 GENCODE targets which have long been deprecated and were causing issues with the latest NCCL release builds. * Improved NVLS/NVLSTree tuning prediction to improve algorithm and protocol selection. * NVLSTree Tuning Fixes. Update tuning data for H100, GB200-NV72. * Respond better to RoCE link flaps. Instead of reporting an “unknown event” it will now report “GID table changed”. * Move libvirt bridge interface to the end of possible interfaces so that they are considered last. These interfaces are usually virtual bridges to relay traffic to containers running on the host and cannot be used for traffic to a remote node and are therefore unsuitable.
382 sor
22 KiB
C++
382 sor
22 KiB
C++
/*************************************************************************
|
|
* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
|
|
*
|
|
* See LICENSE.txt for license information
|
|
************************************************************************/
|
|
|
|
#include <stdio.h>
|
|
#include "err.h"
|
|
#include "profiler.h"
|
|
#include "event.h"
|
|
#include "print_event.h"
|
|
#include <cuda_runtime.h>
|
|
|
|
#define __hidden __attribute__ ((visibility("hidden")))
|
|
|
|
// FIXME: chrome tracing asynchronous events (following used) allow event nesting for events that have same id and category
|
|
// It appears that nesting more than three events causes issues. Therefore, every event is given an increasing id and a
|
|
// category that matches the type of event (GROUP API, COLL API, P2P API, GROUP, COLL, P2P, PROXY, NET)
|
|
static __thread int groupApiId;
|
|
__hidden void printGroupApiEventHeader(FILE* fh, struct groupApi* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"GROUP_API\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"groupApiId\": %d, \"groupDepth\":%d}},\n",
|
|
"Group API", groupApiId, getpid(), 1, event->startTs, event->groupApiId, event->groupDepth);
|
|
}
|
|
|
|
__hidden void printGroupApiEventTrailer(FILE* fh, struct groupApi* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"GROUP_API\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"Group API", groupApiId++, getpid(), 1, event->stopTs);
|
|
}
|
|
|
|
static __thread int p2pApiId;
|
|
__hidden void printP2pApiEventHeader(FILE* fh, struct p2pApi* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"P2P_API\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"count\": %lu, \"datatype\": %s, \"GraphCaptured\":%d, \"Stream\": %p}},\n",
|
|
event->func, p2pApiId, getpid(), 1, event->startTs, event->count, event->datatype, event->graphCaptured, event->stream);
|
|
}
|
|
|
|
__hidden void printP2pApiEventTrailer(FILE* fh, struct p2pApi* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"P2P_API\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
event->func, p2pApiId++, getpid(), 1, event->stopTs);
|
|
}
|
|
|
|
static __thread int collApiId;
|
|
__hidden void printCollApiEventHeader(FILE* fh, struct collApi* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"COLL_API\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"count\": %lu, \"datatype\": %s, \"root\": %d, \"GraphCaptured\":%d, \"Stream\": %p}},\n",
|
|
event->func, collApiId, getpid(), 1, event->startTs, event->count, event->datatype, event->root, event->graphCaptured, event->stream);
|
|
}
|
|
|
|
__hidden void printCollApiEventTrailer(FILE* fh, struct collApi* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"COLL_API\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
event->func, collApiId++, getpid(), 1, event->stopTs);
|
|
}
|
|
|
|
static __thread int kernelLaunchId;
|
|
__hidden void printKernelLaunchEventHeader(FILE* fh, struct kernelLaunch* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"KERNEL_LAUNCH\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"groupId\": %d, \"Stream\": %p}},\n", "KernelLaunch", kernelLaunchId, getpid(), 1, event->startTs, event->kernelLaunchId, event->stream);
|
|
}
|
|
|
|
__hidden void printKernelLaunchEventTrailer(FILE* fh, struct kernelLaunch* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"KERNEL_LAUNCH\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n", "KernelLaunch", kernelLaunchId++, getpid(), 1, event->stopTs);
|
|
}
|
|
|
|
static __thread int groupId;
|
|
__hidden void printGroupEventHeader(FILE* fh, struct group* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"GROUP\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"groupId\": %d}},\n",
|
|
"Group", groupId, getpid(), 1, event->startTs, event->groupId);
|
|
}
|
|
|
|
__hidden void printGroupEventTrailer(FILE* fh, struct group* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"GROUP\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"Group", groupId++, getpid(), 1, event->stopTs);
|
|
}
|
|
|
|
static __thread int collId;
|
|
__hidden void printCollEventHeader(FILE* fh, struct collective* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"COLL\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"SeqNum\": %lu, \"CommHash\": %lu, \"Rank\": %d, \"Count\": %lu, \"Datatype\": \"%s\", \"Algorithm\": \"%s\", \"Protocol\": \"%s\", \"nChannels\": %d}},\n",
|
|
event->base.func, collId, getpid(), 1, event->base.startTs, event->seqNumber, ((struct collApi*)event->base.parent)->ctx->commHash, event->base.rank, event->count, event->datatype, event->algo, event->proto, event->nChannels);
|
|
}
|
|
|
|
__hidden void printCollEventTrailer(FILE* fh, struct collective* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"COLL\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
event->base.func, collId++, getpid(), 1, event->base.stopTs);
|
|
}
|
|
|
|
static __thread int p2pId;
|
|
__hidden void printP2pEventHeader(FILE* fh, struct p2p* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"P2P\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"CommHash\": %lu, \"Rank\": %d, \"Peer\": %d, \"Count\": %lu, \"Datatype\": \"%s\", \"nChannels\": %d}},\n",
|
|
event->base.func, p2pId, getpid(), 1, event->base.startTs, ((struct p2pApi*)event->base.parent)->ctx->commHash, event->base.rank, event->peer, event->count, event->datatype, event->nChannels);
|
|
}
|
|
|
|
__hidden void printP2pEventTrailer(FILE* fh, struct p2p* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"P2P\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
event->base.func, p2pId++, getpid(), 1, event->base.stopTs);
|
|
}
|
|
|
|
static __thread int proxyOpId;
|
|
__hidden void printProxyOpEventHeader(FILE* fh, struct proxyOp* event) {
|
|
if (event->isSend) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"PROXY\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Channel\": %d, \"Peer\": %d, \"Steps\": %d, \"ChunkSize\": %d, \"transSize\": %lu}},\n",
|
|
"ScheduleSend", proxyOpId, getpid(), 1, event->startTs, event->channelId, event->peer, event->nSteps, event->chunkSize, event->transSize);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"PROXY\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"ScheduleSend", proxyOpId, getpid(), 1, event->progrTs);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"PROXY\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Channel\": %d, \"Peer\": %d, \"Steps\": %d, \"ChunkSize\": %d, \"transSize\": %lu}},\n",
|
|
"ProgressSend", proxyOpId, getpid(), 1, event->progrTs, event->channelId, event->peer, event->nSteps, event->chunkSize, event->transSize);
|
|
} else {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"PROXY\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Channel\": %d, \"Peer\": %d, \"Steps\": %d, \"ChunkSize\": %d, \"transSize\": %lu}},\n",
|
|
"ScheduleRecv", proxyOpId, getpid(), 1, event->startTs, event->channelId, event->peer, event->nSteps, event->chunkSize, event->transSize);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"PROXY\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"ScheduleRecv", proxyOpId, getpid(), 1, event->progrTs);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"PROXY\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Channel\": %d, \"Peer\": %d, \"Steps\": %d, \"ChunkSize\": %d, \"transSize\": %lu}},\n",
|
|
"ProgressRecv", proxyOpId, getpid(), 1, event->progrTs, event->channelId, event->peer, event->nSteps, event->chunkSize, event->transSize);
|
|
}
|
|
}
|
|
|
|
__hidden void printProxyOpEventTrailer(FILE* fh, struct proxyOp* event) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"PROXY\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
event->isSend ? "ProgressSend" : "ProgressRecv", proxyOpId++, getpid(), 1, event->stopTs);
|
|
}
|
|
|
|
static __thread int proxyStepId;
|
|
__hidden void printProxyStepEventHeader(FILE* fh, struct proxyStep* event) {
|
|
if (event->isSend) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Step\": %d}},\n",
|
|
"SendGpuWait", proxyStepId, getpid(), 1, event->timestamp[PROXY_STEP_SEND_GPU_WAIT], event->step);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"SendGpuWait", proxyStepId, getpid(), 1, event->timestamp[PROXY_STEP_SEND_PEER_WAIT]);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Step\": %d}},\n",
|
|
"SendPeerWait", proxyStepId, getpid(), 1, event->timestamp[PROXY_STEP_SEND_PEER_WAIT], event->step);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"SendPeerWait", proxyStepId, getpid(), 1, event->timestamp[PROXY_STEP_SEND_WAIT]);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Step\": %d}},\n",
|
|
"SendWait", proxyStepId, getpid(), 1, event->timestamp[PROXY_STEP_SEND_WAIT], event->step);
|
|
} else {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Step\": %d}},\n",
|
|
"RecvWait", proxyStepId, getpid(), 1, event->timestamp[PROXY_STEP_RECV_WAIT], event->step);
|
|
}
|
|
}
|
|
|
|
__hidden void printProxyStepEventTrailer(FILE* fh, struct proxyStep* event) {
|
|
if (event->isSend) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"SendWait", proxyStepId++, getpid(), 1, event->stopTs);
|
|
} else {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"RecvWait", proxyStepId, getpid(), 1, event->timestamp[PROXY_STEP_RECV_FLUSH_WAIT]);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Step\": %d}},\n",
|
|
"RecvFlushWait", proxyStepId, getpid(), 1, event->timestamp[PROXY_STEP_RECV_FLUSH_WAIT], event->step);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"RecvFlushWait", proxyStepId, getpid(), 1, event->timestamp[PROXY_STEP_RECV_GPU_WAIT]);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Step\": %d}},\n",
|
|
"RecvGpuWait", proxyStepId, getpid(), 1, event->timestamp[PROXY_STEP_RECV_GPU_WAIT], event->step);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"RecvGpuWait", proxyStepId++, getpid(), 1, event->stopTs);
|
|
}
|
|
}
|
|
|
|
static __thread int kernelId;
|
|
__hidden void printKernelChEventHeader(FILE* fh, struct kernelCh* event) {
|
|
if (event->type != ncclProfileKernelCh) return;
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"GPU\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"Channel\": %d, \"StartGpuClk\": %lu, \"StopGpuClk\": %lu}},\n",
|
|
"KernelCh", kernelId, getpid(), 1, event->startTs, event->channelId, event->startGpuClk, event->stopGpuClk);
|
|
}
|
|
|
|
__hidden void printKernelChEventTrailer(FILE* fh, struct kernelCh* event) {
|
|
if (event->type != ncclProfileKernelCh) return;
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"GPU\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"KernelCh", kernelId, getpid(), 1, event->stopTs);
|
|
}
|
|
|
|
static __thread int proxyCtrlId;
|
|
__hidden void printProxyCtrlEvent(FILE* fh, struct proxyCtrl* event) {
|
|
const char* str;
|
|
if (event->state == ncclProfilerProxyCtrlIdle || event->state == ncclProfilerProxyCtrlActive) {
|
|
str = "Idle";
|
|
} else if (event->state == ncclProfilerProxyCtrlSleep || event->state == ncclProfilerProxyCtrlWakeup) {
|
|
str = "Sleep";
|
|
} else if (event->state == ncclProfilerProxyCtrlAppend || event->state == ncclProfilerProxyCtrlAppendEnd) {
|
|
str = "Append";
|
|
} else {
|
|
return;
|
|
}
|
|
if (event->state == ncclProfilerProxyCtrlAppendEnd) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"PROXY\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"appended\": %d}},\n",
|
|
str, proxyCtrlId, getpid(), 1, event->startTs, event->appended);
|
|
} else {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"PROXY\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
str, proxyCtrlId, getpid(), 1, event->startTs);
|
|
}
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"PROXY\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
str, proxyCtrlId++, getpid(), 1, event->stopTs);
|
|
}
|
|
|
|
static __thread int ibQpId, sockId;
|
|
__hidden void printNetPluginEvent(FILE* fh, struct netPlugin* event) {
|
|
if (event->pluginType == NCCL_PROFILER_NET_TYPE_IB) {
|
|
if (event->pluginVer == 1) {
|
|
if (event->pluginEvent == ncclProfileQp) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET_IB\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"device\": %d, \"qp_num\": %d, \"opcode\": %d, \"wr_id\": %lu, \"size\": %lu}},\n",
|
|
"Qp", ibQpId, getpid(), 1, event->startTs, event->qp.device, event->qp.qpNum, event->qp.opcode, event->qp.wr_id, event->qp.length);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET_IB\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"Qp", ibQpId++, getpid(), 1, event->stopTs);
|
|
}
|
|
}
|
|
} else if (event->pluginType == NCCL_PROFILER_NET_TYPE_SOCK) {
|
|
if (event->pluginVer == 1) {
|
|
if (event->pluginEvent == ncclProfileSocket) {
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET_SOCK\", \"ph\": \"b\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f, \"args\": {\"sock\": %d, \"op\": %d, \"size\": %lu}},\n",
|
|
"Sock", sockId, getpid(), 1, event->startTs, event->sock.fd, event->sock.op, event->sock.length);
|
|
fprintf(fh, "{\"name\": \"%s\", \"cat\": \"NET_SOCK\", \"ph\": \"e\", \"id\": %d, \"pid\": %d, \"tid\": %d, \"ts\": %f},\n",
|
|
"Sock", sockId++, getpid(), 1, event->stopTs);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//#define DEBUG_EVENTS
|
|
void debugEvent(void* eHandle, const char* tag) {
|
|
#ifdef DEBUG_EVENTS
|
|
char filename[64] = { 0 };
|
|
sprintf(filename, "EventDebug-%d", getpid());
|
|
FILE* fh = fopen(filename, "a+");
|
|
uint64_t type = *(uint64_t *)eHandle;
|
|
if (type == ncclProfileGroup) {
|
|
struct group* event = (struct group *)eHandle;
|
|
fprintf(fh, "Group event %p tag = %s {\n", event, tag);
|
|
fprintf(fh, " refCount = %d\n", __atomic_load_n(&event->refCount, __ATOMIC_RELAXED));
|
|
fprintf(fh, " startTs = %f\n", event->startTs);
|
|
fprintf(fh, " stopTs = %f\n", event->stopTs);
|
|
fprintf(fh, "}\n");
|
|
} else if (type == ncclProfileColl) {
|
|
struct collective* event = (struct collective *)eHandle;
|
|
fprintf(fh, "Collective event %p tag = %s {\n", event, tag);
|
|
fprintf(fh, " refCount = %d\n", __atomic_load_n(&event->base.refCount, __ATOMIC_RELAXED));
|
|
fprintf(fh, " parent = %p\n", event->base.parent);
|
|
for (int j = 0; j < 2*MAX_OPS; j++) {
|
|
for (int i = 0; i < MAX_CHANNELS; i++) if (event->op[i][j].type == ncclProfileProxyOp) fprintf(fh, " op[%d] = %p\n", i, &event->op[i]);
|
|
}
|
|
fprintf(fh, " startTs = %f\n", event->base.startTs);
|
|
fprintf(fh, " stopTs = %f\n", event->base.stopTs);
|
|
fprintf(fh, "}\n");
|
|
} else if (type == ncclProfileP2p) {
|
|
struct p2p* event = (struct p2p *)eHandle;
|
|
fprintf(fh, "P2p event %p tag = %s {\n", event, tag);
|
|
fprintf(fh, " refCount = %d\n", __atomic_load_n(&event->base.refCount, __ATOMIC_RELAXED));
|
|
fprintf(fh, " parent = %p\n", event->base.parent);
|
|
fprintf(fh, " op = %p\n", &event->op);
|
|
fprintf(fh, " startTs = %f\n", event->base.startTs);
|
|
fprintf(fh, " stopTs = %f\n", event->base.stopTs);
|
|
fprintf(fh, "}\n");
|
|
} else if (type == ncclProfileProxyOp) {
|
|
struct proxyOp* event = (struct proxyOp *)eHandle;
|
|
fprintf(fh, "ProxyOp event %p tag = %s {\n", event, tag);
|
|
fprintf(fh, " type = %s\n", event->isSend < 0 ? "Unknown" : event->isSend ? "Send" : "Recv");
|
|
fprintf(fh, " channel = %d\n", event->channelId);
|
|
fprintf(fh, " parent = %p\n", event->parent);
|
|
fprintf(fh, " rank = %d\n", event->rank);
|
|
fprintf(fh, " startTs = %f\n", event->startTs);
|
|
fprintf(fh, " progrTs = %f\n", event->progrTs);
|
|
fprintf(fh, " stopTs = %f\n", event->stopTs);
|
|
fprintf(fh, "}\n");
|
|
} else if (type == ncclProfileProxyStep) {
|
|
struct proxyStep* event = (struct proxyStep *)eHandle;
|
|
fprintf(fh, "ProxyStep event %p tag = %s {\n", event, tag);
|
|
fprintf(fh, " type = %s\n", event->isSend < 0 ? "Unknown" : event->isSend ? "Send" : "Recv");
|
|
fprintf(fh, " parent = %p\n", event->parent);
|
|
fprintf(fh, " startTs = %f\n", event->startTs);
|
|
fprintf(fh, " stopTs = %f\n", event->stopTs);
|
|
fprintf(fh, "}\n");
|
|
} else if (type == ncclProfileKernelCh) {
|
|
struct kernelCh* event = (struct kernelCh *)eHandle;
|
|
fprintf(fh, "KernelCh event %p tag = %s {\n", event, tag);
|
|
fprintf(fh, " parent = %p\n", event->parent);
|
|
fprintf(fh, " channel = %d\n", event->channelId);
|
|
} else if (type == ncclProfileNetPlugin) {
|
|
struct netPlugin* event = (struct netPlugin *)eHandle;
|
|
fprintf(fh, "NetPlugin event %p tag = %s {\n", event, tag);
|
|
fprintf(fh, " pluginType = %d\n", event->pluginType);
|
|
fprintf(fh, " pluginVer = %d\n", event->pluginVer);
|
|
fprintf(fh, " pluginEvent = %d\n", event->pluginEvent);
|
|
fprintf(fh, " startTs = %f\n", event->startTs);
|
|
fprintf(fh, " stopTs = %f\n", event->stopTs);
|
|
fprintf(fh, "}\n");
|
|
}
|
|
fclose(fh);
|
|
#endif
|
|
}
|
|
|
|
void printEvent(FILE* fh, void* handle) {
|
|
if (handle == NULL || fh == NULL) return;
|
|
uint64_t type = *(uint64_t *)handle;
|
|
if (type == ncclProfileGroupApi) {
|
|
struct groupApi* g = (struct groupApi*) handle;
|
|
printGroupApiEventHeader(fh, g);
|
|
struct kernelLaunch* kernelLaunchHead = profilerQueueHead(&g->kernelLaunchEvents);
|
|
while (kernelLaunchHead != NULL) {
|
|
printEvent(fh, kernelLaunchHead);
|
|
kernelLaunchHead = kernelLaunchHead->next;
|
|
}
|
|
struct collApi* collApiHead = profilerQueueHead(&g->collApiEvents);
|
|
while (collApiHead != NULL) {
|
|
printEvent(fh, collApiHead);
|
|
collApiHead = collApiHead->next;
|
|
}
|
|
struct p2pApi* p2pApiHead = profilerQueueHead(&g->p2pApiEvents);
|
|
while (p2pApiHead != NULL) {
|
|
printEvent(fh, p2pApiHead);
|
|
p2pApiHead = p2pApiHead->next;
|
|
}
|
|
printGroupApiEventTrailer(fh, g);
|
|
} else if (type == ncclProfileCollApi) {
|
|
struct collApi* collApiEvent = (struct collApi *) handle;
|
|
printCollApiEventHeader(fh, collApiEvent);
|
|
struct taskEventBase* base = taskEventQueueHead(collApiEvent);
|
|
while (base) {
|
|
struct taskEventBase* next = base->next;
|
|
printEvent(fh, base);
|
|
base = next;
|
|
}
|
|
printCollApiEventTrailer(fh, collApiEvent);
|
|
} else if (type == ncclProfileP2pApi) {
|
|
struct p2pApi* p2pApiEvent = (struct p2pApi *) handle;
|
|
printP2pApiEventHeader(fh, p2pApiEvent);
|
|
struct taskEventBase* base = taskEventQueueHead(p2pApiEvent);
|
|
while (base) {
|
|
struct taskEventBase* next = base->next;
|
|
printEvent(fh, base);
|
|
base = next;
|
|
}
|
|
printP2pApiEventTrailer(fh, p2pApiEvent);
|
|
} else if (type == ncclProfileKernelLaunch) {
|
|
struct kernelLaunch* kernelLaunchEvent = (struct kernelLaunch *) handle;
|
|
printKernelLaunchEventHeader(fh, kernelLaunchEvent);
|
|
printKernelLaunchEventTrailer(fh, kernelLaunchEvent);
|
|
} else if (type == ncclProfileGroup) {
|
|
struct group* g = (struct group *)handle;
|
|
printGroupEventHeader(fh, g);
|
|
struct taskEventBase* base = taskEventQueueHead(g);
|
|
while (base) {
|
|
struct taskEventBase* next = base->next;
|
|
printEvent(fh, base);
|
|
base = next;
|
|
}
|
|
printGroupEventTrailer(fh, g);
|
|
} else if (type == ncclProfileColl) {
|
|
struct collective* c = (struct collective *)handle;
|
|
printCollEventHeader(fh, c);
|
|
for (int i = 0; i < MAX_CHANNELS; i++) {
|
|
printKernelChEventHeader(fh, &c->kernel[i]);
|
|
for (int j = 0; j < c->nProxyOps[i]; j++) {
|
|
printEvent(fh, &c->op[i][j]);
|
|
}
|
|
printKernelChEventTrailer(fh, &c->kernel[i]);
|
|
}
|
|
printCollEventTrailer(fh, c);
|
|
} else if (type == ncclProfileP2p) {
|
|
struct p2p* p = (struct p2p *)handle;
|
|
printP2pEventHeader(fh, p);
|
|
for (int i = 0; i < MAX_CHANNELS; i++) {
|
|
printKernelChEventHeader(fh, &p->kernel[i]);
|
|
printEvent(fh, &p->op[i]);
|
|
printKernelChEventTrailer(fh, &p->kernel[i]);
|
|
}
|
|
printP2pEventTrailer(fh, p);
|
|
} else if (type == ncclProfileProxyOp) {
|
|
struct proxyOp* p = (struct proxyOp *)handle;
|
|
printProxyOpEventHeader(fh, p);
|
|
for (int i = 0; i < MAX_STEPS; i++) {
|
|
printEvent(fh, &p->step[i]);
|
|
}
|
|
printProxyOpEventTrailer(fh, p);
|
|
} else if (type == ncclProfileProxyStep) {
|
|
struct proxyStep* p = (struct proxyStep *)handle;
|
|
printProxyStepEventHeader(fh, p);
|
|
for (int q = 0; q < p->nNetEvents; q++) {
|
|
printNetPluginEvent(fh, &p->net[q]);
|
|
}
|
|
printProxyStepEventTrailer(fh, p);
|
|
} else if (type == ncclProfileProxyCtrl) {
|
|
struct proxyCtrl* p = (struct proxyCtrl *)handle;
|
|
printProxyCtrlEvent(fh, p);
|
|
}
|
|
return;
|
|
}
|