Skip to content

Commit fcb1ab6

Browse files
committed
Add GpuIpcMem class
1 parent d97d230 commit fcb1ab6

File tree

7 files changed

+605
-239
lines changed

7 files changed

+605
-239
lines changed

include/mscclpp/gpu.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#ifndef MSCCLPP_GPU_HPP_
55
#define MSCCLPP_GPU_HPP_
66

7-
#if defined(__HIP_PLATFORM_AMD__)
7+
#include <mscclpp/device.hpp>
88

9-
#include <hip/hip_runtime.h>
9+
#if defined(MSCCLPP_DEVICE_HIP)
1010

1111
using cudaError_t = hipError_t;
1212
using cudaEvent_t = hipEvent_t;
@@ -62,6 +62,7 @@ constexpr auto CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL = HIP_POINTER_ATTRIBUTE_DEVIC
6262
#define CUDA_ERROR_DEINITIALIZED hipErrorDeinitialized
6363
#define CUDA_ERROR_CONTEXT_IS_DESTROYED hipErrorContextIsDestroyed
6464
#define CUDA_ERROR_LAUNCH_FAILED hipErrorLaunchFailure
65+
#define CUDA_ERROR_NOT_SUPPORTED hipErrorNotSupported
6566
#define CUDA_ERROR_INVALID_VALUE hipErrorInvalidValue
6667

6768
#define cudaEventCreate(...) hipEventCreate(__VA_ARGS__)
@@ -122,29 +123,29 @@ constexpr auto CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL = HIP_POINTER_ATTRIBUTE_DEVIC
122123
#define cuMemGetAllocationGranularity(...) hipMemGetAllocationGranularity(__VA_ARGS__)
123124
#define cuPointerGetAttribute(...) hipPointerGetAttribute(__VA_ARGS__)
124125

125-
#else
126+
#else // !defined(MSCCLPP_DEVICE_HIP)
126127

127128
#include <cuda.h>
128129
#include <cuda_runtime.h>
129130

130-
#endif
131+
#endif // !defined(MSCCLPP_DEVICE_HIP)
131132

132133
// NVLS
133-
#if !defined(__HIP_PLATFORM_AMD__)
134+
#if !defined(MSCCLPP_DEVICE_HIP)
134135
#include <linux/version.h>
135136
#if CUDART_VERSION < 12030
136137
#define CU_MEM_HANDLE_TYPE_FABRIC ((CUmemAllocationHandleType)0x8ULL)
137138
#endif
138139
// We need CUDA 12.3 above and kernel 5.6.0 above for NVLS API
139140
#define CUDA_NVLS_API_AVAILABLE ((CUDART_VERSION >= 12030) && (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)))
140-
#else // defined(__HIP_PLATFORM_AMD__)
141+
#else // defined(MSCCLPP_DEVICE_HIP)
141142
#define CUDA_NVLS_API_AVAILABLE 0
142143
// NVLS is not supported on AMD platform, just to avoid compilation error
143-
#define CU_MEM_HANDLE_TYPE_FABRIC (0x8ULL)
144-
#endif // !defined(__HIP_PLATFORM_AMD__)
144+
#define CU_MEM_HANDLE_TYPE_FABRIC ((hipMemAllocationHandleType)0x8ULL)
145+
#endif // defined(MSCCLPP_DEVICE_HIP)
145146

146147
// GPU sync threads
147-
#if defined(__HIP_PLATFORM_AMD__)
148+
#if defined(MSCCLPP_DEVICE_HIP)
148149
#define __syncshm() asm volatile("s_waitcnt lgkmcnt(0) \n s_barrier");
149150
#else
150151
#define __syncshm() __syncthreads();

0 commit comments

Comments
 (0)