Comhaid
rocm-systems/src/include/p2p.h
T

70 línte
2.3 KiB
C
Amh Amharc Gnáth Stair

2020-05-12 14:40:18 -07:00
/*************************************************************************
* Copyright (c) 2015-2020, NVIDIA CORPORATION. All rights reserved.
*
* See LICENSE.txt for license information
************************************************************************/
#include <stdlib.h>
#ifndef NCCL_P2P_H_
#define NCCL_P2P_H_
2024-02-05 05:06:02 -08:00
#include <cuda.h>
2024-06-11 01:28:01 -07:00
#include <cuda_runtime.h>
#include "core.h"
2023-04-03 05:32:07 -07:00
2024-02-05 05:06:02 -08:00
#if CUDART_VERSION < 12030
// MNNVL: FABRIC handle support lifted from CUDA 12.3
#define CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_FABRIC_SUPPORTED ((CUdevice_attribute)128)
#define CU_MEM_HANDLE_TYPE_FABRIC ((CUmemAllocationHandleType)0x8ULL)
#define CU_IPC_HANDLE_SIZE 64
typedef struct CUmemFabricHandle_st {
unsigned char data[CU_IPC_HANDLE_SIZE];
} CUmemFabricHandle_v1;
typedef CUmemFabricHandle_v1 CUmemFabricHandle;
#endif
typedef union {
2023-09-26 05:47:28 -07:00
uint64_t data; // Needs to hold a CUmemGenericAllocationHandle for UDS fd support
2024-02-05 05:06:02 -08:00
CUmemFabricHandle handle;
2023-04-03 05:32:07 -07:00
} ncclCuDesc;
typedef union {
// Legacy CUDA IPC
cudaIpcMemHandle_t devIpc;
// cuMem API support
2024-09-10 05:57:10 -07:00
struct {
ncclCuDesc cuDesc;
CUmemGenericAllocationHandle memHandle;
};
2023-04-03 05:32:07 -07:00
} ncclIpcDesc;
2024-09-10 05:57:10 -07:00
enum ncclIpcRegType {
NCCL_IPC_SENDRECV = 0,
NCCL_IPC_COLLECTIVE = 1
};
struct ncclIpcImpInfo {
void* rmtRegAddr;
bool legacyIpcCap;
uintptr_t offset;
};
struct ncclIpcRegInfo {
int peerRank;
void* baseAddr;
struct ncclProxyConnector* ipcProxyconn;
struct ncclIpcImpInfo impInfo;
};
ncclResult_t ncclP2pAllocateShareableBuffer(size_t size, int directMap, ncclIpcDesc *ipcDesc, void **ptr);
2023-04-03 05:32:07 -07:00
ncclResult_t ncclP2pFreeShareableBuffer(ncclIpcDesc *ipcDesc);
2024-09-10 05:57:10 -07:00
ncclResult_t ncclP2pImportShareableBuffer(struct ncclComm *comm, int peer, size_t size, ncclIpcDesc *ipcDesc, void **devMemPtr);
ncclResult_t ncclIpcLocalRegisterBuffer(ncclComm* comm, const void* userbuff, size_t buffSize, int* peerRanks, int nPeers, ncclIpcRegType type, int* regBufFlag, uintptr_t* offsetOut, uintptr_t** peerRmtAddrsOut);
ncclResult_t ncclIpcGraphRegisterBuffer(ncclComm* comm, const void* userbuff, size_t buffSize, int* peerRanks, int nPeers, ncclIpcRegType type, int* regBufFlag, uintptr_t* offsetOut, uintptr_t** peerRmtAddrsOut, void* cleanupQueuePtr, int* nCleanupQueueElts);
ncclResult_t ncclIpcDeregBuffer(struct ncclComm* comm, struct ncclIpcRegInfo* regInfo);
2023-04-03 05:32:07 -07:00
2020-05-12 14:40:18 -07:00
#endif