2020#include "hl_memory.h"
2121#include "mlu_memory.h"
2222#include "opencl_memory.h"
23+ #include "dm_memory.h"
2324#include <math.h>
2425#ifdef HAVE_RO
2526#include <stdbool.h>
@@ -700,6 +701,11 @@ static void usage(const char *argv0, VerbType verb, TestType tst, int connection
700701 printf (" Use OpenCl specific platform ID\n" );
701702 }
702703
704+ if (dm_memory_dmabuf_supported ()) {
705+ printf (" --use_ib_dm_dmabuf=<ib_device>" );
706+ printf (" Use device memory with DMA-BUF export for RDMA testing\n" );
707+ }
708+
703709 if (cuda_memory_supported () ||
704710 opencl_memory_supported ()) {
705711 printf (" --gpu_touch=<once\\infinite> " );
@@ -947,6 +953,8 @@ static void init_perftest_params(struct perftest_parameters *user_param)
947953 user_param -> use_mlu_dmabuf = 0 ;
948954 user_param -> opencl_platform_id = 0 ;
949955 user_param -> opencl_device_id = 0 ;
956+ user_param -> dm_ib_devname = NULL ;
957+ user_param -> use_ib_dm_dmabuf = 0 ;
950958 user_param -> gpu_touch = GPU_NO_TOUCH ;
951959 user_param -> mmap_file = NULL ;
952960 user_param -> mmap_offset = 0 ;
@@ -1987,9 +1995,10 @@ static void force_dependecies(struct perftest_parameters *user_param)
19871995 exit (1 );
19881996 }
19891997
1990- if (user_param -> memory_type == MEMORY_CUDA && user_param -> verb == SEND && (user_param -> size <= 64 || user_param -> test_method == RUN_ALL )) {
1998+ if ((user_param -> memory_type == MEMORY_CUDA || user_param -> memory_type == MEMORY_DM ) &&
1999+ user_param -> verb == SEND && (user_param -> size <= 64 || user_param -> test_method == RUN_ALL )) {
19912000 printf (RESULT_LINE );
1992- printf ("Scatter2CQE (size <= 64) is not supported with GPUDirect send tests: setting MLX5_SCATTER_TO_CQE=0\n" );
2001+ printf ("Scatter2CQE (size <= 64) is not supported with device memory send tests: setting MLX5_SCATTER_TO_CQE=0\n" );
19932002 if (disable_mlx5_scatter_to_cqe ())
19942003 exit (1 );
19952004 }
@@ -2012,6 +2021,12 @@ static void force_dependecies(struct perftest_parameters *user_param)
20122021 exit (1 );
20132022 }
20142023
2024+ if (user_param -> memory_type == MEMORY_DM && user_param -> tst == LAT && (user_param -> verb == WRITE || user_param -> verb == WRITE_IMM )) {
2025+ printf (RESULT_LINE );
2026+ fprintf (stderr ,"Perftest doesn't support device memory latency test with write verb\n" );
2027+ exit (1 );
2028+ }
2029+
20152030 if (user_param -> use_data_direct ) {
20162031 user_param -> use_cuda_pcie_mapping = 1 ;
20172032 }
@@ -2517,6 +2532,11 @@ static void ctx_set_max_inline(struct ibv_context *context,struct perftest_param
25172532 return ;
25182533 }
25192534
2535+ if (user_param -> memory_type == MEMORY_DM ){
2536+ user_param -> inline_size = 0 ;
2537+ return ;
2538+ }
2539+
25202540 if (user_param -> tst == LAT ) {
25212541 switch (user_param -> verb ) {
25222542 case WRITE_IMM :
@@ -2633,6 +2653,7 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
26332653 static int use_mlu_dmabuf_flag = 0 ;
26342654 static int use_opencl_flag = 0 ;
26352655 static int opencl_platform_id_flag = 0 ;
2656+ static int use_ib_dm_dmabuf_flag = 0 ;
26362657 static int gpu_touch_flag = 0 ;
26372658 static int disable_pcir_flag = 0 ;
26382659 static int mmap_file_flag = 0 ;
@@ -2825,6 +2846,7 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
28252846 { .name = "use_mlu_dmabuf" , .has_arg = 0 , .flag = & use_mlu_dmabuf_flag , .val = 1 },
28262847 { .name = "use_opencl" , .has_arg = 1 , .flag = & use_opencl_flag , .val = 1 },
28272848 { .name = "opencl_platform_id" , .has_arg = 1 , .flag = & opencl_platform_id_flag , .val = 1 },
2849+ { .name = "use_ib_dm_dmabuf" , .has_arg = 1 , .flag = & use_ib_dm_dmabuf_flag , .val = 1 },
28282850 { .name = "gpu_touch" , .has_arg = 1 , .flag = & gpu_touch_flag , .val = 1 },
28292851 { .name = "mmap" , .has_arg = 1 , .flag = & mmap_file_flag , .val = 1 },
28302852 { .name = "mmap-offset" , .has_arg = 1 , .flag = & mmap_offset_flag , .val = 1 },
@@ -3278,7 +3300,8 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
32783300 (use_hl_flag && !hl_memory_supported ()) ||
32793301 (use_mlu_flag && !mlu_memory_supported ()) ||
32803302 (use_mlu_dmabuf_flag && !mlu_memory_dmabuf_supported ()) ||
3281- (use_opencl_flag && !opencl_memory_supported ())) {
3303+ (use_opencl_flag && !opencl_memory_supported ()) ||
3304+ (use_ib_dm_dmabuf_flag && !dm_memory_dmabuf_supported ())) {
32823305 printf (" Unsupported memory type\n" );
32833306 return FAILURE ;
32843307 }
@@ -3289,6 +3312,7 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
32893312 /* Memory types are mutually exclucive, make sure we were not already asked to use a different memory type. */
32903313 if (user_param -> memory_type != MEMORY_HOST &&
32913314 (mmap_file_flag || use_mlu_flag || use_neuron_flag || use_hl_flag ||
3315+ use_ib_dm_dmabuf_flag ||
32923316 (use_rocm_flag && user_param -> memory_type != MEMORY_ROCM ) ||
32933317 ((use_cuda_flag || use_cuda_bus_id_flag ) && user_param -> memory_type != MEMORY_CUDA ))) {
32943318 fprintf (stderr , " Can't use multiple memory types\n" );
@@ -3422,6 +3446,13 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
34223446 }
34233447 opencl_platform_id_flag = 0 ;
34243448 }
3449+ if (use_ib_dm_dmabuf_flag ) {
3450+ user_param -> dm_ib_devname = strdup (optarg );
3451+ user_param -> use_ib_dm_dmabuf = 1 ;
3452+ user_param -> memory_type = MEMORY_DM ;
3453+ user_param -> memory_create = dm_memory_create ;
3454+ use_ib_dm_dmabuf_flag = 0 ;
3455+ }
34253456 if (gpu_touch_flag ) {
34263457 if (!cuda_gpu_touch_supported ()) {
34273458 fprintf (stderr , "GPU touch is not supported\n" );
0 commit comments