CMakeLists.txt 2.8 KB
Newer Older
1
# Copyright (c) 2022-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Przemek Tredak's avatar
Przemek Tredak committed
2
3
4
#
# See LICENSE for license information.

yuguo's avatar
yuguo committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
list(APPEND test_cuda_sources
            test_cast.cu
            test_cast_current_scaling.cu
            test_cast_dbias.cu
            test_cast_dbias_dgelu.cu
            test_cast_gated_swiglu.cu
            test_cast_mxfp8_gated_swiglu.cu
            test_qdq.cu
            test_cast_mxfp8.cu
            test_dequantize_mxfp8.cu
            test_transpose.cu
            test_cast_transpose.cu
            test_cast_transpose_current_scaling.cu
            test_cast_transpose_dbias.cu
            test_cast_transpose_dbias_dgelu.cu
            test_cast_transpose_dgeglu.cu
            test_act.cu
            test_normalization.cu
            test_normalization_mxfp8.cu
            test_multi_cast_transpose.cu
            test_multi_padding.cu
            test_causal_softmax.cu
            test_swizzle.cu
            ../test_common.cu)
if(USE_ROCM)
  list(APPEND test_cuda_sources
              test_cublaslt_gemm.cu)
endif()
Przemek Tredak's avatar
Przemek Tredak committed
33

yuguo's avatar
yuguo committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
if(USE_CUDA)
  add_executable(test_operator ${test_cuda_sources})
else()
  message("${message_line}")
  message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
  message(STATUS "PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}")

  set(TE ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
  set(THIRDPARTY ${TE}/3rdparty)
  list(APPEND CMAKE_MODULE_PATH "${THIRDPARTY}/hipify_torch/cmake")
  include(Hipify)
  message(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")

  file(REAL_PATH ../../../transformer_engine/common/include header_include_dir1)
  file(REAL_PATH ../../../transformer_engine/common header_include_dir2)
  set(header_include_dir ${header_include_dir1} ${header_include_dir2})
50

yuguo's avatar
yuguo committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  message(STATUS "CUDA_SOURCE_DIR: ${PROJECT_SOURCE_DIR}")
  message(STATUS "HEADER_INCLUDE_DIR: ${header_include_dir}")
  set(cuda_source_dir ${PROJECT_SOURCE_DIR} )
  hipify(CUDA_SOURCE_DIR ${cuda_source_dir} 
    HEADER_INCLUDE_DIR ${header_include_dir}
    CUSTOM_MAP_FILE "${TE}/hipify_custom_map.json"
  )
  get_hipified_list("${test_cuda_sources}" test_hip_sources)
  message("${message_line}")
  message(STATUS "nvte tests hipified sources: ${test_hip_sources}")

  add_executable(test_operator ${test_hip_sources})
endif()

find_package(OpenMP REQUIRED)
if(USE_CUDA)
  list(APPEND test_operator_LINKER_LIBS CUDA::cudart GTest::gtest_main ${TE_LIB} CUDA::nvrtc CUDNN::cudnn)
  
  target_link_libraries(test_operator PUBLIC ${test_operator_LINKER_LIBS} OpenMP::OpenMP_CXX)
  target_compile_options(test_operator PRIVATE -O2 -fopenmp)
else()
  target_link_libraries(test_operator PUBLIC hip::host hip::device GTest::gtest_main ${TE_LIB} OpenMP::OpenMP_CXX)
  target_compile_options(test_operator PRIVATE -O2 -fopenmp)
endif()
Przemek Tredak's avatar
Przemek Tredak committed
75
76

include(GoogleTest)
77
gtest_discover_tests(test_operator DISCOVERY_TIMEOUT 600)