From d146cbf3bcf5cf057f7049aff0182df7a6484130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20H=C3=BCck?= Date: Sun, 20 Apr 2025 18:01:25 +0200 Subject: [PATCH 1/3] MPI requirement optional --- CMakeLists.txt | 10 +- cmake/cusanToolchain.cmake | 2 +- lib/runtime/CMakeLists.txt | 126 +++++++++--------- lib/runtime/TSanInterface.h | 6 +- scripts/CMakeLists.txt | 1 - test/CMakeLists.txt | 23 +++- test/kernel_analysis/03_struct_write.c | 2 + test/kernel_analysis/08_big_struct_write.c | 2 + test/lit.cfg | 2 + test/lit.site.cfg.in | 3 +- test/pass/03_cuda_to_mpi.c | 4 +- test/pass/04_mpi_to_cuda.c | 2 + test/pass/05_cuda_to_mpi_stream.c | 2 + test/pass/06_cuda_to_mpi_event.c | 2 + test/pass/07_cuda_to_mpi_read.c | 2 + test/pass/08_cudamemcpy_to_mpi.c | 2 + test/pass/11_cuda_to_mpi_struct_of_buff.c | 2 + .../18_cuda_to_mpi_event_query_busy_loop.c | 1 + ...pi_send_cudaMemcpyAsyncH2H_implicit_sync.c | 1 + test/pass/20_cuda_to_mpi_send_ds_sync_w_r.c | 2 + test/pass/21_chunked_streams_example.c | 2 + test/pass/22_cuda_to_mpi_partial_buff_write.c | 2 + test/pass/26_malloc_pitch.c | 2 + test/pass/29_tsan_cuda_to_mpi.c | 1 + test/pass/30_tsan_annotate_cuda_to_mpi.c | 2 + test/pass/31_tsan_cuda_event.c | 3 +- test/pass/32_tsan_async_copy.c | 2 +- test/runtime/03_cuda_to_mpi.c | 2 +- test/runtime/04_mpi_to_cuda.c | 2 +- test/runtime/05_cuda_to_mpi_stream.c | 2 +- test/runtime/06_cuda_to_mpi_event.c | 2 +- test/runtime/07_cuda_to_mpi_read.c | 2 +- test/runtime/08_cudamemcpy_to_mpi.c | 2 +- test/runtime/11_cuda_to_mpi_struct_of_buff.c | 2 +- test/runtime/12_struct_ptr.c | 2 +- .../18_cuda_to_mpi_event_query_busy_loop.c | 2 +- ...pi_send_cudaMemcpyAsyncH2H_implicit_sync.c | 2 +- .../runtime/20_cuda_to_mpi_send_ds_sync_w_r.c | 2 +- test/runtime/21_chunked_streams_example.c | 2 +- .../22_cuda_to_mpi_partial_buff_write.c | 2 +- test/runtime/26_malloc_pitch.c | 2 +- test/runtime/29_tsan_cuda_to_mpi.c | 2 +- test/runtime/30_tsan_annotate_cuda_to_mpi.c | 2 +- 43 files changed, 148 insertions(+), 95 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58f070b..69051f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,11 +30,6 @@ add_subdirectory(externals) add_subdirectory(lib) add_subdirectory(scripts) -if(PROJECT_IS_TOP_LEVEL) - enable_testing() - add_subdirectory(test) -endif() - write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/cusanConfigVersion.cmake VERSION ${PROJECT_VERSION} @@ -68,3 +63,8 @@ if(PROJECT_IS_TOP_LEVEL) QUIET_ON_EMPTY ) endif() + +if(PROJECT_IS_TOP_LEVEL) + enable_testing() + add_subdirectory(test) +endif() diff --git a/cmake/cusanToolchain.cmake b/cmake/cusanToolchain.cmake index 449a0ff..cf2a55a 100644 --- a/cmake/cusanToolchain.cmake +++ b/cmake/cusanToolchain.cmake @@ -26,7 +26,7 @@ string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}" ) find_package(CUDAToolkit REQUIRED) -find_package(MPI REQUIRED) +find_package(MPI) option(CUSAN_TEST_CONFIGURE_IDE "Add targets for tests to help the IDE with completion etc." ON) mark_as_advanced(CUSAN_TEST_CONFIGURE_IDE) diff --git a/lib/runtime/CMakeLists.txt b/lib/runtime/CMakeLists.txt index 741bbc2..5397584 100644 --- a/lib/runtime/CMakeLists.txt +++ b/lib/runtime/CMakeLists.txt @@ -1,67 +1,69 @@ -find_package(MPI) -add_library(cusan_mpi_interceptor SHARED MPIInterception.cpp) -target_link_libraries(cusan_mpi_interceptor - PRIVATE MPI::MPI_CXX -) -set_target_properties( - cusan_mpi_interceptor - PROPERTIES - OUTPUT_NAME "CusanMPIInterceptor" - EXPORT_NAME "MPIInterceptor" -) -add_library(cusan::MPI_Interceptor ALIAS cusan_mpi_interceptor) -target_compile_features(cusan_mpi_interceptor PUBLIC cxx_std_17) -target_compile_definitions( - cusan_mpi_interceptor - PRIVATE CUSAN_LOG_LEVEL=${CUSAN_LOG_LEVEL_RT} - LLVM_VERSION_MAJOR=${LLVM_VERSION_MAJOR} - $<$:CUSAN_FIBERPOOL=1> - $<$:CUSAN_TYPEART=1> - $<$:CUSAN_SOFTCOUNTER> -) - -target_include_directories(cusan_mpi_interceptor ${warning_guard} - PUBLIC $ - PRIVATE $ -) - -target_include_directories(cusan_mpi_interceptor - SYSTEM - PRIVATE - ${LLVM_INCLUDE_DIRS} -) - -target_link_libraries(cusan_mpi_interceptor PRIVATE LLVMSupport) - -if(CUSAN_FIBERPOOL) - target_link_libraries(cusan_mpi_interceptor PUBLIC cusan::fiberpool) - set_target_properties(cusan_mpi_interceptor PROPERTIES - BUILD_WITH_INSTALL_RPATH FALSE - LINK_FLAGS "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") +if (MPI_FOUND) + add_library(cusan_mpi_interceptor SHARED MPIInterception.cpp) + target_link_libraries(cusan_mpi_interceptor + PRIVATE MPI::MPI_CXX + ) + set_target_properties( + cusan_mpi_interceptor + PROPERTIES + OUTPUT_NAME "CusanMPIInterceptor" + EXPORT_NAME "MPIInterceptor" + ) + add_library(cusan::MPI_Interceptor ALIAS cusan_mpi_interceptor) + + target_compile_features(cusan_mpi_interceptor PUBLIC cxx_std_17) + target_compile_definitions( + cusan_mpi_interceptor + PRIVATE CUSAN_LOG_LEVEL=${CUSAN_LOG_LEVEL_RT} + LLVM_VERSION_MAJOR=${LLVM_VERSION_MAJOR} + $<$:CUSAN_FIBERPOOL=1> + $<$:CUSAN_TYPEART=1> + $<$:CUSAN_SOFTCOUNTER> + ) + + target_include_directories(cusan_mpi_interceptor ${warning_guard} + PUBLIC $ + PRIVATE $ + ) + + target_include_directories(cusan_mpi_interceptor + SYSTEM + PRIVATE + ${LLVM_INCLUDE_DIRS} + ) + + target_link_libraries(cusan_mpi_interceptor PRIVATE LLVMSupport) + + if(CUSAN_FIBERPOOL) + target_link_libraries(cusan_mpi_interceptor PUBLIC cusan::fiberpool) + set_target_properties(cusan_mpi_interceptor PROPERTIES + BUILD_WITH_INSTALL_RPATH FALSE + LINK_FLAGS "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + endif() + + set(CONFIG_NAME cusanMPIInterceptor) + set(TARGETS_EXPORT_NAME ${CONFIG_NAME}Targets) + + install( + TARGETS cusan_mpi_interceptor + EXPORT ${TARGETS_EXPORT_NAME} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + + install( + EXPORT ${TARGETS_EXPORT_NAME} + NAMESPACE cusan:: + DESTINATION ${CUSAN_INSTALL_CONFIGDIR} + ) + + export( + EXPORT ${TARGETS_EXPORT_NAME} + FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake + NAMESPACE cusan:: + ) endif() -set(CONFIG_NAME cusanMPIInterceptor) -set(TARGETS_EXPORT_NAME ${CONFIG_NAME}Targets) - -install( - TARGETS cusan_mpi_interceptor - EXPORT ${TARGETS_EXPORT_NAME} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} -) - -install( - EXPORT ${TARGETS_EXPORT_NAME} - NAMESPACE cusan:: - DESTINATION ${CUSAN_INSTALL_CONFIGDIR} -) - -export( - EXPORT ${TARGETS_EXPORT_NAME} - FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake - NAMESPACE cusan:: -) - add_library(cusan_Runtime SHARED CusanRuntime.cpp CusanRuntime_cudaSpecific.cpp) set_target_properties( cusan_Runtime diff --git a/lib/runtime/TSanInterface.h b/lib/runtime/TSanInterface.h index 324b688..3bfe367 100644 --- a/lib/runtime/TSanInterface.h +++ b/lib/runtime/TSanInterface.h @@ -1,9 +1,11 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat" -#pragma GCC diagnostic ignored "-Wmacro-redefined" #pragma GCC diagnostic ignored "-Wunused-parameter" -#pragma GCC diagnostic ignored "-Wformat-pedantic" #pragma GCC diagnostic ignored "-Wcast-qual" +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wmacro-redefined" +#pragma clang diagnostic ignored "-Wformat-pedantic" +#endif #include "TSan_External.h" diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 74d956c..b27f7fb 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -175,7 +175,6 @@ if(NOT CUSAN_TYPEART) ) endif() -find_package(MPI) if(MPI_C_FOUND) configure_cusan_script( ${CUSAN_WRAPPER} cusan-mpicc${CMAKE_DEBUG_POSTFIX} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 64266d6..d13fe37 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -36,6 +36,7 @@ function(configure_cusan_lit_site_cfg input output) pythonize_bool(${CUSAN_TEST_WORKAROUNDS} CUSAN_TEST_WORKAROUND) pythonize_bool(${CUSAN_TYPEART} CUSAN_HAS_TYPEART) + pythonize_bool(${MPI_FOUND} CUSAN_HAS_MPI) cusan_target_generate_file(${input} ${output}) endfunction() @@ -90,16 +91,32 @@ function(cusan_add_lit_target) endforeach() endfunction() + +if(NOT MPI_FOUND) + # mock target to make test generation work + add_library(cusan_mpi_interceptor_mock SHARED IMPORTED) + set_target_properties( + cusan_mpi_interceptor_mock + PROPERTIES + OUTPUT_NAME "CusanMPIInterceptorPlaceholder" + IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/lib/runtime" + ) + set(_cusan_interceptor_target cusan_mpi_interceptor_mock) + add_library(cusan::MPI_Interceptor ALIAS cusan_mpi_interceptor_mock) +endif() + set(CUSAN_TEST_DEPENDS cusan::TransformPass - cusan::MPI_Interceptor cusan::Runtime cusan::Analysis - ) +if(FOUND_MPI) + list(APPEND CUSAN_TEST_DEPENDS cusan::MPI_Interceptor) +endif() + if(CUSAN_TYPEART) -list(APPEND CUSAN_TEST_DEPENDS typeart::Runtime typeart::TransformPass) + list(APPEND CUSAN_TEST_DEPENDS typeart::Runtime typeart::TransformPass) endif() set(CUSAN_SUITES diff --git a/test/kernel_analysis/03_struct_write.c b/test/kernel_analysis/03_struct_write.c index c001e03..a6edeef 100644 --- a/test/kernel_analysis/03_struct_write.c +++ b/test/kernel_analysis/03_struct_write.c @@ -22,6 +22,8 @@ // CHECK-NEXT: subarg: {{.*}}ptr: 0, rw: ReadWrite // CHECK-NOT: Handling Arg: +// REQUIRES: mpi + // clang-format on #include "../support/gpu_mpi.h" diff --git a/test/kernel_analysis/08_big_struct_write.c b/test/kernel_analysis/08_big_struct_write.c index 5d34cd5..3df5664 100644 --- a/test/kernel_analysis/08_big_struct_write.c +++ b/test/kernel_analysis/08_big_struct_write.c @@ -22,6 +22,8 @@ // CHECK-NEXT: subarg: {{.*}}ptr: 0, rw: ReadWrite // CHECK-NOT: Handling Arg: +// REQUIRES: mpi + // clang-format on #include "../support/gpu_mpi.h" diff --git a/test/lit.cfg b/test/lit.cfg index cf956ce..909e384 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -45,6 +45,8 @@ if config.cusan_typeart: if config.mpiexec: config.available_features.add('mpiexec') +if config.cusan_mpi: + config.available_features.add('mpi') config.substitutions.append(("%clang-cpp", clang_cpp)) config.substitutions.append(("%clang-cc", clang_cc)) diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 70030c3..8f655dd 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -28,9 +28,10 @@ config.cusan_pass_dir = "@CUSAN_PASS_DIR@" config.cusan_runtime_dir = "@CUSAN_RUNTIME_DIR@" config.cusan_script_dir = "@CUSAN_SCRIPT_DIR@" config.cusan_pass = "$" -config.cusan_mpi_interceptor = "$" +config.cusan_mpi_interceptor = "$" config.cusan_use_workarounds = @CUSAN_TEST_WORKAROUND@ config.cusan_typeart = @CUSAN_HAS_TYPEART@ +config.cusan_mpi = @CUSAN_HAS_MPI@ # Let the main config do the real work. config.loaded_site_config = True diff --git a/test/pass/03_cuda_to_mpi.c b/test/pass/03_cuda_to_mpi.c index 82d6a98..5186403 100644 --- a/test/pass/03_cuda_to_mpi.c +++ b/test/pass/03_cuda_to_mpi.c @@ -2,11 +2,11 @@ // RUN: %rm-file %t.yaml // RUN: %wrapper-mpicc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR - - // CHECK-LLVM-IR: {{call|invoke}} i32 @cudaMemcpy({{i8\*|ptr}} {{.*}}[[target:%[0-9a-z]+]], {{i8\*|ptr}} {{.*}}[[from:%[0-9a-z]+]], // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_memcpy({{i8\*|ptr}} {{.*}}[[target]], {{i8\*|ptr}} {{.*}}[[from]], +// REQUIRES: mpi + // clang-format on #include "../support/gpu_mpi.h" diff --git a/test/pass/04_mpi_to_cuda.c b/test/pass/04_mpi_to_cuda.c index e27f41a..6196dcc 100644 --- a/test/pass/04_mpi_to_cuda.c +++ b/test/pass/04_mpi_to_cuda.c @@ -8,6 +8,8 @@ // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaMemcpy({{i8\*|ptr}} {{.*}}[[target:%[0-9a-z]+]], {{i8\*|ptr}} {{.*}}[[from:%[0-9a-z]+]], // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_memcpy({{i8\*|ptr}} {{.*}}[[target]], {{i8\*|ptr}} {{.*}}[[from]], +// REQUIRES: mpi + // clang-format on #include "../support/gpu_mpi.h" diff --git a/test/pass/05_cuda_to_mpi_stream.c b/test/pass/05_cuda_to_mpi_stream.c index bdb304f..6a22f3e 100644 --- a/test/pass/05_cuda_to_mpi_stream.c +++ b/test/pass/05_cuda_to_mpi_stream.c @@ -10,6 +10,8 @@ // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaStreamSynchronize // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_sync_stream +// REQUIRES: mpi + // clang-format on #include "../support/gpu_mpi.h" diff --git a/test/pass/06_cuda_to_mpi_event.c b/test/pass/06_cuda_to_mpi_event.c index 2253965..50bdd34 100644 --- a/test/pass/06_cuda_to_mpi_event.c +++ b/test/pass/06_cuda_to_mpi_event.c @@ -10,6 +10,8 @@ // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaMemcpy({{i8\*|ptr}} {{.*}}[[target:%[0-9a-z]+]], {{i8\*|ptr}} {{.*}}[[from:%[0-9a-z]+]], // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_memcpy({{i8\*|ptr}} {{.*}}[[target]], {{i8\*|ptr}} {{.*}}[[from]], +// REQUIRES: mpi + // clang-format on #include "../support/gpu_mpi.h" diff --git a/test/pass/07_cuda_to_mpi_read.c b/test/pass/07_cuda_to_mpi_read.c index c1ce739..f379fb7 100644 --- a/test/pass/07_cuda_to_mpi_read.c +++ b/test/pass/07_cuda_to_mpi_read.c @@ -11,6 +11,8 @@ // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaMemcpy({{i8\*|ptr}} {{.*}}[[target:%[0-9a-z]+]], {{i8\*|ptr}} {{.*}}[[from:%[0-9a-z]+]], // CHECK-LLVM-IR: {{(call|invoke)}} void @_cusan_memcpy({{i8\*|ptr}} {{.*}}[[target]], {{i8\*|ptr}} {{.*}}[[from]], +// REQUIRES: mpi + // clang-format on #include "../support/gpu_mpi.h" diff --git a/test/pass/08_cudamemcpy_to_mpi.c b/test/pass/08_cudamemcpy_to_mpi.c index 3d1139c..1d553a2 100644 --- a/test/pass/08_cudamemcpy_to_mpi.c +++ b/test/pass/08_cudamemcpy_to_mpi.c @@ -15,6 +15,8 @@ // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaStreamSynchronize // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_sync_stream +// REQUIRES: mpi + // clang-format on // Tsan sometimes crashes with this test it seems diff --git a/test/pass/11_cuda_to_mpi_struct_of_buff.c b/test/pass/11_cuda_to_mpi_struct_of_buff.c index 2dcea96..3a2001d 100644 --- a/test/pass/11_cuda_to_mpi_struct_of_buff.c +++ b/test/pass/11_cuda_to_mpi_struct_of_buff.c @@ -3,6 +3,8 @@ // RUN: %wrapper-mpicc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR +// REQUIRES: mpi + // CHECK-LLVM-IR: {{call|invoke}} i32 @cudaStreamCreate // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_create_stream // CHECK-LLVM-IR: {{call|invoke}} i32 @cudaStreamCreate diff --git a/test/pass/18_cuda_to_mpi_event_query_busy_loop.c b/test/pass/18_cuda_to_mpi_event_query_busy_loop.c index cd00aae..8c590cc 100644 --- a/test/pass/18_cuda_to_mpi_event_query_busy_loop.c +++ b/test/pass/18_cuda_to_mpi_event_query_busy_loop.c @@ -3,6 +3,7 @@ // RUN: %wrapper-mpicc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR +// REQUIRES: mpi // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaStreamCreate // CHECK-LLVM-IR: {{(call|invoke)}} void @_cusan_create_stream diff --git a/test/pass/19_cuda_to_mpi_send_cudaMemcpyAsyncH2H_implicit_sync.c b/test/pass/19_cuda_to_mpi_send_cudaMemcpyAsyncH2H_implicit_sync.c index 1c5d299..248c3a6 100644 --- a/test/pass/19_cuda_to_mpi_send_cudaMemcpyAsyncH2H_implicit_sync.c +++ b/test/pass/19_cuda_to_mpi_send_cudaMemcpyAsyncH2H_implicit_sync.c @@ -3,6 +3,7 @@ // RUN: %wrapper-mpicc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR +// REQUIRES: mpi // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaStreamCreate // CHECK-LLVM-IR: {{(call|invoke)}} void @_cusan_create_stream diff --git a/test/pass/20_cuda_to_mpi_send_ds_sync_w_r.c b/test/pass/20_cuda_to_mpi_send_ds_sync_w_r.c index f86f3a0..871b3ab 100644 --- a/test/pass/20_cuda_to_mpi_send_ds_sync_w_r.c +++ b/test/pass/20_cuda_to_mpi_send_ds_sync_w_r.c @@ -3,6 +3,8 @@ // RUN: %wrapper-mpicc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR +// REQUIRES: mpi + // CHECK-LLVM-IR: {{call|invoke}} i32 @cudaStreamCreate // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_create_stream // CHECK-LLVM-IR: {{call|invoke}} i32 @cudaMemset diff --git a/test/pass/21_chunked_streams_example.c b/test/pass/21_chunked_streams_example.c index 13562f7..03774ce 100644 --- a/test/pass/21_chunked_streams_example.c +++ b/test/pass/21_chunked_streams_example.c @@ -3,6 +3,8 @@ // RUN: %wrapper-mpicc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR +// REQUIRES: mpi + // CHECK-LLVM-IR: {{call|invoke}} i32 @cudaStreamCreate // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_create_stream // CHECK-LLVM-IR: {{call|invoke}} i32 @cudaStreamCreate diff --git a/test/pass/22_cuda_to_mpi_partial_buff_write.c b/test/pass/22_cuda_to_mpi_partial_buff_write.c index c037c8a..2f23ae8 100644 --- a/test/pass/22_cuda_to_mpi_partial_buff_write.c +++ b/test/pass/22_cuda_to_mpi_partial_buff_write.c @@ -3,6 +3,8 @@ // RUN: %wrapper-mpicc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR +// REQUIRES: mpi + // CHECK-LLVM-IR: {{call|invoke}} i32 @cudaStreamCreate // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_create_stream // CHECK-LLVM-IR: {{call|invoke}} i32 @cudaStreamSynchronize diff --git a/test/pass/26_malloc_pitch.c b/test/pass/26_malloc_pitch.c index b71af1a..7a0a97c 100644 --- a/test/pass/26_malloc_pitch.c +++ b/test/pass/26_malloc_pitch.c @@ -6,6 +6,8 @@ // {{.*}}[[from:%[0-9a-z]+]], CHECK-LLVM-IR: {{call|invoke}} void @_cusan_memcpy({{i8\*|ptr}} {{.*}}[[target]], // {{i8\*|ptr}} {{.*}}[[from]], +// REQUIRES: mpi + // clang-format on #include "../support/gpu_mpi.h" diff --git a/test/pass/29_tsan_cuda_to_mpi.c b/test/pass/29_tsan_cuda_to_mpi.c index 7608db6..9ab6fdc 100644 --- a/test/pass/29_tsan_cuda_to_mpi.c +++ b/test/pass/29_tsan_cuda_to_mpi.c @@ -3,6 +3,7 @@ // RUN: %wrapper-mpicc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR +// REQUIRES: mpi // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaMemcpy // CHECK-LLVM-IR: {{(call|invoke)}} void @_cusan_memcpy diff --git a/test/pass/30_tsan_annotate_cuda_to_mpi.c b/test/pass/30_tsan_annotate_cuda_to_mpi.c index 506eff1..335e372 100644 --- a/test/pass/30_tsan_annotate_cuda_to_mpi.c +++ b/test/pass/30_tsan_annotate_cuda_to_mpi.c @@ -8,6 +8,8 @@ // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaFree // CHECK-LLVM-IR: {{(call|invoke)}} void @_cusan_device_free +// REQUIRES: mpi + // clang-format on #include "../support/gpu_mpi.h" diff --git a/test/pass/31_tsan_cuda_event.c b/test/pass/31_tsan_cuda_event.c index 918ba99..311dc93 100644 --- a/test/pass/31_tsan_cuda_event.c +++ b/test/pass/31_tsan_cuda_event.c @@ -1,8 +1,9 @@ // clang-format off // RUN: %rm-file %t.yaml -// RUN: %wrapper-mpicc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR +// RUN: %wrapper-cc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR +// REQUIRES: mpi // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaEventCreate // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_create_event diff --git a/test/pass/32_tsan_async_copy.c b/test/pass/32_tsan_async_copy.c index cc7c12f..d30220d 100644 --- a/test/pass/32_tsan_async_copy.c +++ b/test/pass/32_tsan_async_copy.c @@ -1,7 +1,7 @@ // clang-format off // RUN: %rm-file %t.yaml -// RUN: %wrapper-mpicc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR +// RUN: %wrapper-cc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaStreamCreate diff --git a/test/runtime/03_cuda_to_mpi.c b/test/runtime/03_cuda_to_mpi.c index d7f11b6..e2dcd9d 100644 --- a/test/runtime/03_cuda_to_mpi.c +++ b/test/runtime/03_cuda_to_mpi.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/04_mpi_to_cuda.c b/test/runtime/04_mpi_to_cuda.c index 370f48f..77f8915 100644 --- a/test/runtime/04_mpi_to_cuda.c +++ b/test/runtime/04_mpi_to_cuda.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/05_cuda_to_mpi_stream.c b/test/runtime/05_cuda_to_mpi_stream.c index af827b9..4ff4400 100644 --- a/test/runtime/05_cuda_to_mpi_stream.c +++ b/test/runtime/05_cuda_to_mpi_stream.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/06_cuda_to_mpi_event.c b/test/runtime/06_cuda_to_mpi_event.c index 0585479..65ef15e 100644 --- a/test/runtime/06_cuda_to_mpi_event.c +++ b/test/runtime/06_cuda_to_mpi_event.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/07_cuda_to_mpi_read.c b/test/runtime/07_cuda_to_mpi_read.c index e367e2a..d1ee1fc 100644 --- a/test/runtime/07_cuda_to_mpi_read.c +++ b/test/runtime/07_cuda_to_mpi_read.c @@ -2,7 +2,7 @@ // RUN: %wrapper-mpicxx %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t.exe 2>&1 | %filecheck --allow-empty %s -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/08_cudamemcpy_to_mpi.c b/test/runtime/08_cudamemcpy_to_mpi.c index b8fa5bf..4aedbcc 100644 --- a/test/runtime/08_cudamemcpy_to_mpi.c +++ b/test/runtime/08_cudamemcpy_to_mpi.c @@ -2,7 +2,7 @@ // RUN: %wrapper-mpicxx %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t.exe // RUN: %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t.exe 2>&1 | %filecheck %s --allow-empty -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/11_cuda_to_mpi_struct_of_buff.c b/test/runtime/11_cuda_to_mpi_struct_of_buff.c index 4a3141d..8455f74 100644 --- a/test/runtime/11_cuda_to_mpi_struct_of_buff.c +++ b/test/runtime/11_cuda_to_mpi_struct_of_buff.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/12_struct_ptr.c b/test/runtime/12_struct_ptr.c index 5a71312..41ab21d 100644 --- a/test/runtime/12_struct_ptr.c +++ b/test/runtime/12_struct_ptr.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // CHECK-DAG: data race diff --git a/test/runtime/18_cuda_to_mpi_event_query_busy_loop.c b/test/runtime/18_cuda_to_mpi_event_query_busy_loop.c index 73674a7..0b82829 100644 --- a/test/runtime/18_cuda_to_mpi_event_query_busy_loop.c +++ b/test/runtime/18_cuda_to_mpi_event_query_busy_loop.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/19_cuda_to_mpi_send_cudaMemcpyAsyncH2H_implicit_sync.c b/test/runtime/19_cuda_to_mpi_send_cudaMemcpyAsyncH2H_implicit_sync.c index 61eee40..23d9a9c 100644 --- a/test/runtime/19_cuda_to_mpi_send_cudaMemcpyAsyncH2H_implicit_sync.c +++ b/test/runtime/19_cuda_to_mpi_send_cudaMemcpyAsyncH2H_implicit_sync.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/20_cuda_to_mpi_send_ds_sync_w_r.c b/test/runtime/20_cuda_to_mpi_send_ds_sync_w_r.c index 820912b..7f88a11 100644 --- a/test/runtime/20_cuda_to_mpi_send_ds_sync_w_r.c +++ b/test/runtime/20_cuda_to_mpi_send_ds_sync_w_r.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/21_chunked_streams_example.c b/test/runtime/21_chunked_streams_example.c index fa4f5d0..6b7dee5 100644 --- a/test/runtime/21_chunked_streams_example.c +++ b/test/runtime/21_chunked_streams_example.c @@ -2,7 +2,7 @@ // RUN: %wrapper-mpicxx %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t.exe 2>&1 | %filecheck %s -DFILENAME=%s -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/22_cuda_to_mpi_partial_buff_write.c b/test/runtime/22_cuda_to_mpi_partial_buff_write.c index 8a29dd9..2639ce8 100644 --- a/test/runtime/22_cuda_to_mpi_partial_buff_write.c +++ b/test/runtime/22_cuda_to_mpi_partial_buff_write.c @@ -2,7 +2,7 @@ // RUN: %wrapper-mpicxx %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t.exe 2>&1 | %filecheck %s --allow-empty -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/26_malloc_pitch.c b/test/runtime/26_malloc_pitch.c index 3d7524f..0dac955 100644 --- a/test/runtime/26_malloc_pitch.c +++ b/test/runtime/26_malloc_pitch.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/29_tsan_cuda_to_mpi.c b/test/runtime/29_tsan_cuda_to_mpi.c index 14ebfa1..2ac700f 100644 --- a/test/runtime/29_tsan_cuda_to_mpi.c +++ b/test/runtime/29_tsan_cuda_to_mpi.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on diff --git a/test/runtime/30_tsan_annotate_cuda_to_mpi.c b/test/runtime/30_tsan_annotate_cuda_to_mpi.c index 24e59ce..19c6d97 100644 --- a/test/runtime/30_tsan_annotate_cuda_to_mpi.c +++ b/test/runtime/30_tsan_annotate_cuda_to_mpi.c @@ -5,7 +5,7 @@ // RUN: %wrapper-mpicxx -DCUSAN_SYNC %clang_args -x cuda -g %s -gencode arch=compute_70,code=sm_70 -o %cusan_test_dir/%basename_t-sync.exe // RUN: %cusan_ldpreload %tsan-options %mpi-exec -n 2 %cusan_test_dir/%basename_t-sync.exe 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-SYNC -// REQUIRES: mpiexec +// REQUIRES: mpi // clang-format on From 850f74accbc2840557b9579899660d09735ff4dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20H=C3=BCck?= Date: Sun, 20 Apr 2025 18:05:46 +0200 Subject: [PATCH 2/3] Revert target gen expression --- test/lit.site.cfg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 8f655dd..d6cde3f 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -28,7 +28,7 @@ config.cusan_pass_dir = "@CUSAN_PASS_DIR@" config.cusan_runtime_dir = "@CUSAN_RUNTIME_DIR@" config.cusan_script_dir = "@CUSAN_SCRIPT_DIR@" config.cusan_pass = "$" -config.cusan_mpi_interceptor = "$" +config.cusan_mpi_interceptor = "$" config.cusan_use_workarounds = @CUSAN_TEST_WORKAROUND@ config.cusan_typeart = @CUSAN_HAS_TYPEART@ config.cusan_mpi = @CUSAN_HAS_MPI@ From 74d4c7a8d0a8e7bc1359827e3fc4a477837e2e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20H=C3=BCck?= Date: Sun, 20 Apr 2025 18:10:10 +0200 Subject: [PATCH 3/3] Fix test --- test/pass/31_tsan_cuda_event.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/pass/31_tsan_cuda_event.c b/test/pass/31_tsan_cuda_event.c index 311dc93..eb819ea 100644 --- a/test/pass/31_tsan_cuda_event.c +++ b/test/pass/31_tsan_cuda_event.c @@ -3,8 +3,6 @@ // RUN: %wrapper-cc %clang-pass-only-args --cusan-kernel-data=%t.yaml -x cuda --cuda-gpu-arch=sm_72 %s 2>&1 | %filecheck %s -DFILENAME=%s --allow-empty --check-prefix CHECK-LLVM-IR -// REQUIRES: mpi - // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaEventCreate // CHECK-LLVM-IR: {{call|invoke}} void @_cusan_create_event // CHECK-LLVM-IR: {{(call|invoke)}} i32 @cudaStreamCreate @@ -16,8 +14,6 @@ // clang-format on -#include "../support/gpu_mpi.h" - #include __global__ void kernel(int* arr, const int N) { // CHECK-DAG: [[FILENAME]]:[[@LINE]] @@ -28,10 +24,6 @@ __global__ void kernel(int* arr, const int N) { // CHECK-DAG: [[FILENAME]]:[[@L } int main(int argc, char* argv[]) { - if (!has_gpu_aware_mpi()) { - printf("This example is designed for CUDA-aware MPI. Exiting.\n"); - return 1; - } cudaEvent_t first_finished_event; cudaEventCreate(&first_finished_event); cudaStream_t stream1;