Add fault injection of starting warps with random variations (#1593)
* Add fault injection of starting warps with random variations
This is done by inserting randomly delays after __syncthreads().
The feature can be turned off by FAULT_INJECTION=OFF in cmake.
* Remove manually introduced bug for demo purpose
* Use only one thread per warp for checking wall clock
[ROCm/rccl commit: 90ad586d94]
This commit is contained in:
@@ -44,15 +44,15 @@
|
||||
// TODO: switch to atomicInc after llvm crash is fixed
|
||||
// uint32_t pos = atomicInc(&ncclShmem.collTraceTail->tail, COLLTRACE_NUM_ITEMS)
|
||||
|
||||
#define traceKernelLaunch(launch_type) { \
|
||||
#define traceKernelLaunch(launch_type, ix) { \
|
||||
INC_COLL_TRACE \
|
||||
collTrace->funcIndex = ncclShmem.funcId; \
|
||||
__trace_hwreg()\
|
||||
collTrace->batchIx = ix; \
|
||||
if (ncclShmem.workType == ncclDevWorkTypeP2p) { \
|
||||
struct ncclDevWorkP2p *p2pWork = (struct ncclDevWorkP2p*)ncclShmem.workStorage; \
|
||||
collTrace->p2p.sendRank = p2pWork->sendRank; \
|
||||
collTrace->p2p.recvRank = p2pWork->recvRank; \
|
||||
collTrace->p2p.nP2pChannels = p2pWork->nP2pChannels; \
|
||||
collTrace->p2p.nSendChannels = p2pWork->nSendChannels; \
|
||||
collTrace->p2p.nRecvChannels = p2pWork->nRecvChannels; \
|
||||
collTrace->p2p.channelBase = p2pWork->channelBase; \
|
||||
@@ -60,6 +60,8 @@
|
||||
collTrace->p2p.recvConnIndex = p2pWork->recvConnIndex; \
|
||||
collTrace->p2p.sendProtoLL = p2pWork->sendProtoLL; \
|
||||
collTrace->p2p.recvProtoLL = p2pWork->recvProtoLL; \
|
||||
collTrace->p2p.sendRegistered = p2pWork->sendRegistered; \
|
||||
collTrace->p2p.recvRegistered = p2pWork->recvRegistered; \
|
||||
collTrace->p2pOpCount[0] = p2pWork->sendOpCount; \
|
||||
collTrace->p2pOpCount[1] = p2pWork->recvOpCount; \
|
||||
collTrace->type = (launch_type) | ncclCollTraceP2pElemType; \
|
||||
@@ -95,7 +97,7 @@
|
||||
collTrace->type = ncclCollTraceDataType; \
|
||||
}
|
||||
#else
|
||||
#define traceKernelLaunch(launch_type)
|
||||
#define traceKernelLaunch(launch_type, batchIx)
|
||||
#define traceKernelEnd(end_type)
|
||||
#define traceData(data2, data4, data8_0, data8_1)
|
||||
#endif
|
||||
@@ -151,6 +153,9 @@ struct ncclShmemData {
|
||||
#ifdef ENABLE_PROFILING
|
||||
struct ncclProf prof;
|
||||
#endif
|
||||
#ifdef ENABLE_FAULT_INJECTION
|
||||
uint64_t faults;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern __shared__ ncclShmemData ncclShmem;
|
||||
@@ -160,6 +165,28 @@ extern __shared__ ncclShmemData ncclShmem;
|
||||
extern __shared__ ulong2 ncclShmemPerWarp[ncclShmemScratchWarpSize()*(NCCL_MAX_NTHREADS/WARP_SIZE)/sizeof(ulong2)];
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FAULT_INJECTION
|
||||
__device__ inline void insert_random_delay_per_warp() {
|
||||
if ((ncclShmem.faults & RANDOM_DELAY_ON_WARP_START) && (threadIdx.x%WARP_SIZE == 0)) {
|
||||
switch ((wall_clock64()>>(threadIdx.x/WARP_SIZE*2))&0x3) {
|
||||
case 0:
|
||||
__builtin_amdgcn_s_sleep(0);
|
||||
break;
|
||||
case 1:
|
||||
__builtin_amdgcn_s_sleep(8);
|
||||
break;
|
||||
case 2:
|
||||
__builtin_amdgcn_s_sleep(16);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
__builtin_amdgcn_s_sleep(32);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
__device__ inline void* ncclScratchForWarp(int warp) {
|
||||
return (char*)ncclShmemPerWarp + warp*ncclShmemScratchWarpSize();
|
||||
}
|
||||
@@ -468,6 +495,10 @@ __device__ __forceinline__ void ncclKernelMain(struct ncclDevKernelArgs const* a
|
||||
ncclShmem.groups[tid-WARP_SIZE].barrier = 0;
|
||||
break;
|
||||
case 2:
|
||||
#ifdef ENABLE_FAULT_INJECTION
|
||||
/* load faults injection before first sync threads */
|
||||
if (tid == 2*WARP_SIZE) ncclShmem.faults = args->comm->faults;
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
/* set abort flag to 0 */
|
||||
@@ -508,6 +539,7 @@ __device__ __forceinline__ void ncclKernelMain(struct ncclDevKernelArgs const* a
|
||||
}
|
||||
#endif
|
||||
__syncthreads(); // publish shmem
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
if (tid == 0) {
|
||||
ncclShmem.prof.count = 0;
|
||||
@@ -515,7 +547,7 @@ __device__ __forceinline__ void ncclKernelMain(struct ncclDevKernelArgs const* a
|
||||
}
|
||||
#endif
|
||||
if (tid == 0) __insert_timestamp(__LINE__);
|
||||
if (COLLTRACE && tid%WARP_SIZE == 0) traceKernelLaunch(ncclCollTraceKernelLaunchType);
|
||||
if (COLLTRACE && tid%WARP_SIZE == 0) traceKernelLaunch(ncclCollTraceKernelLaunchType, 0);
|
||||
|
||||
if (tid == 0 && ncclShmem.args.workStorageType == ncclDevWorkStorageTypeFifo) {
|
||||
// ncclShmem.workConsumed written by loadWorkBatchToShmem before __syncthreads()
|
||||
@@ -565,7 +597,7 @@ __device__ __forceinline__ void ncclKernelMain(struct ncclDevKernelArgs const* a
|
||||
}
|
||||
if (aborted) break;
|
||||
|
||||
if (COLLTRACE && tid%WARP_SIZE == 0) traceKernelLaunch(ncclCollTraceCollLaunchType);
|
||||
if (COLLTRACE && tid%WARP_SIZE == 0) traceKernelLaunch(ncclCollTraceCollLaunchType, batchIx);
|
||||
}
|
||||
if (COLLTRACE && tid%WARP_SIZE == 0) traceKernelEnd(ncclCollTraceKernelEndType);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user