Skip to content

Commit 6730e97

Browse files
committed
Perftest: enable pcie mapping type only if supported by cuda
Enable data direct pcie mapping type only if supported by CUDA by checking if CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE exist. Signed-off-by: Shmuel Shaul <sshaul@nvidia.com>
1 parent d125f1e commit 6730e97

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

configure.ac

+8
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,16 @@ if [test "$CUDA_H_PATH" ]; then
290290
if [test "x$HAVE_REG_DMABUF_MR" = "xyes"] && [test "x$HAVE_CUDA_CUMEMGETHANDLEFORADDRESSRANGE" = "xyes"] && [test "x$CUDA_DMA_BUF_PARAMETERS_SUPPORT" = "xyes"]; then
291291
AC_DEFINE([HAVE_CUDA_DMABUF], [1], [Enable CUDA DMABUF feature])
292292
fi
293+
AC_TRY_LINK([
294+
#include <$CUDA_H_PATH>],
295+
[int x = CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE;],
296+
[CUDA_DMA_BUF_MAPPING_TYPE_PCIE_SUPPORT=yes], [CUDA_DMA_BUF_MAPPING_TYPE_PCIE_SUPPORT=no])
297+
if [test "x$CUDA_DMA_BUF_MAPPING_TYPE_PCIE_SUPPORT" = "xyes"] && [test "x$HAVE_CUDA_DMABUF" = "xyes"]; then
298+
AC_DEFINE([HAVE_DMABUF_MAPPING_TYPE_PCIE], [1], [Enable CUDA DMABUF handle mapping via PCIe BAR1])
299+
fi
293300
fi
294301
AM_CONDITIONAL([CUDA_DMA_BUF_PARAMETERS_SUPPORT],[test "x$CUDA_DMA_BUF_PARAMETERS_SUPPORT" = "xyes"])
302+
AM_CONDITIONAL([CUDA_DMA_BUF_MAPPING_TYPE_PCIE_SUPPORT],[test "x$CUDA_DMA_BUF_MAPPING_TYPE_PCIE_SUPPORT" = "xyes"])
295303

296304
AM_CONDITIONAL([CUDA], [test "$CUDA_H_PATH"])
297305

src/cuda_memory.c

+4
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,12 @@ int cuda_memory_allocate_buffer(struct memory_ctx *ctx, int alignment, uint64_t
206206
printf("using DMA-BUF for GPU buffer address at %#llx aligned at %#llx with aligned size %zu\n", d_A, aligned_ptr, aligned_size);
207207
*dmabuf_fd = 0;
208208
CUmemRangeHandleType cuda_handle_type = CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD;
209+
210+
#ifdef HAVE_DMABUF_MAPPING_TYPE_PCIE
209211
if (cuda_ctx->use_data_direct)
210212
cu_flags = CU_MEM_RANGE_FLAG_DMA_BUF_MAPPING_TYPE_PCIE;
213+
#endif
214+
211215
error = cuMemGetHandleForAddressRange((void *)dmabuf_fd, aligned_ptr, aligned_size, cuda_handle_type, cu_flags);
212216
if (error != CUDA_SUCCESS) {
213217
printf("cuMemGetHandleForAddressRange error=%d\n", error);

0 commit comments

Comments
 (0)