-
Notifications
You must be signed in to change notification settings - Fork 4
add CUDABlas related API tests #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -76,6 +76,21 @@ list(REMOVE_ITEM TEST_SRC_FILES ${UNMATCH_FILES}) | |||||||||||||||||||||||||
| file(GLOB_RECURSE TEST_BASE_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp) | ||||||||||||||||||||||||||
| set(PADDLE_TARGET_FOLDER ${CMAKE_BINARY_DIR}/paddle) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| # CUDA Toolkit (needed for CUDA-specific test headers in the Torch build) | ||||||||||||||||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| find_package(CUDAToolkit QUIET) | ||||||||||||||||||||||||||
| if(CUDAToolkit_FOUND) | ||||||||||||||||||||||||||
| message(STATUS "Found CUDA Toolkit: ${CUDAToolkit_INCLUDE_DIRS}") | ||||||||||||||||||||||||||
| set(CUDA_INCLUDE_DIRS "${CUDAToolkit_INCLUDE_DIRS}") | ||||||||||||||||||||||||||
| elseif(EXISTS "/usr/local/cuda/include") | ||||||||||||||||||||||||||
| set(CUDA_INCLUDE_DIRS "/usr/local/cuda/include") | ||||||||||||||||||||||||||
| message(STATUS "Using default CUDA include dir: ${CUDA_INCLUDE_DIRS}") | ||||||||||||||||||||||||||
| else() | ||||||||||||||||||||||||||
| message(WARNING "CUDA headers not found; CUDA tests may not compile.") | ||||||||||||||||||||||||||
| set(CUDA_INCLUDE_DIRS "") | ||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| # Build Torch test case | ||||||||||||||||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||||||||||||||||
|
|
@@ -87,8 +102,9 @@ set(TORCH_LIBRARIES "") | |||||||||||||||||||||||||
| file(GLOB_RECURSE TORCH_LIBRARIES "${TORCH_DIR}/lib/*.so" | ||||||||||||||||||||||||||
| "${TORCH_DIR}/lib/*.a") | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| set(TORCH_INCLUDE_DIR "${TORCH_DIR}/include" | ||||||||||||||||||||||||||
| "${TORCH_DIR}/include/torch/csrc/api/include/") | ||||||||||||||||||||||||||
| set(TORCH_INCLUDE_DIR | ||||||||||||||||||||||||||
| "${TORCH_DIR}/include" "${TORCH_DIR}/include/torch/csrc/api/include/" | ||||||||||||||||||||||||||
| "${CUDA_INCLUDE_DIRS}") | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| set(TORCH_TARGET_FOLDER ${CMAKE_BINARY_DIR}/torch) | ||||||||||||||||||||||||||
| set(BIN_PREFIX "torch_") | ||||||||||||||||||||||||||
|
|
@@ -119,7 +135,8 @@ set(PADDLE_INCLUDE_DIR | |||||||||||||||||||||||||
| "${PADDLE_DIR}/include/third_party" | ||||||||||||||||||||||||||
| "${PADDLE_DIR}/include/paddle/phi/api/include/compat/" | ||||||||||||||||||||||||||
| "${PADDLE_DIR}/include/paddle/phi/api/include/compat/torch/csrc/api/include/" | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| "${CUDA_INCLUDE_DIRS}" | ||||||||||||||||||||||||||
| "${CUDA_INCLUDE_DIRS}/cccl") | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Comment on lines
+138
to
140
|
||||||||||||||||||||||||||
| "${CUDA_INCLUDE_DIRS}" | |
| "${CUDA_INCLUDE_DIRS}/cccl") | |
| "${CUDA_INCLUDE_DIRS}") | |
| # Append CUDA cccl include directory if available. | |
| if(CUDA_INCLUDE_DIRS) | |
| # CUDA_INCLUDE_DIRS may be a list; use the first element as the base path. | |
| list(GET CUDA_INCLUDE_DIRS 0 CUDA_INCLUDE_DIRS_FIRST) | |
| if(CUDA_INCLUDE_DIRS_FIRST AND EXISTS "${CUDA_INCLUDE_DIRS_FIRST}") | |
| list(APPEND PADDLE_INCLUDE_DIR "${CUDA_INCLUDE_DIRS_FIRST}/cccl") | |
| endif() | |
| endif() |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,20 @@ function( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message(STATUS "include dir: ${INCLUDE_DIR}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target_compile_definitions(${_test_name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PRIVATE USE_PADDLE_API=${USE_PADDLE_API}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(${USE_PADDLE_API}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Paddle's CUDA compat headers (CUDAContextLight.h, CUDAFunctions.h) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # require PADDLE_WITH_CUDA to be defined so that GPU type aliases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # (gpuStream_t, cudaDeviceProp) are resolved via cuda_runtime.h. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target_compile_definitions(${_test_name} PRIVATE PADDLE_WITH_CUDA) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Link libcudart for CUDA runtime symbols used by the Paddle CUDA compat | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # layer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(TARGET CUDA::cudart) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target_link_libraries(${_test_name} CUDA::cudart) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elseif(EXISTS "/usr/local/cuda/lib64/libcudart.so") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| target_link_libraries(${_test_name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "/usr/local/cuda/lib64/libcudart.so") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+27
to
+38
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Paddle's CUDA compat headers (CUDAContextLight.h, CUDAFunctions.h) | |
| # require PADDLE_WITH_CUDA to be defined so that GPU type aliases | |
| # (gpuStream_t, cudaDeviceProp) are resolved via cuda_runtime.h. | |
| target_compile_definitions(${_test_name} PRIVATE PADDLE_WITH_CUDA) | |
| # Link libcudart for CUDA runtime symbols used by the Paddle CUDA compat | |
| # layer. | |
| if(TARGET CUDA::cudart) | |
| target_link_libraries(${_test_name} CUDA::cudart) | |
| elseif(EXISTS "/usr/local/cuda/lib64/libcudart.so") | |
| target_link_libraries(${_test_name} | |
| "/usr/local/cuda/lib64/libcudart.so") | |
| endif() | |
| # Only enable Paddle's CUDA pathways when CUDA is actually available. | |
| # This prevents defining PADDLE_WITH_CUDA for CPU-only or ROCm builds, | |
| # which would otherwise pull in CUDA-only headers/types and break | |
| # compilation. | |
| set(_paddle_cuda_available OFF) | |
| if(CUDAToolkit_FOUND) | |
| set(_paddle_cuda_available ON) | |
| elseif(TARGET CUDA::cudart) | |
| set(_paddle_cuda_available ON) | |
| elseif(EXISTS "/usr/local/cuda/include/cuda.h" | |
| AND EXISTS "/usr/local/cuda/lib64/libcudart.so") | |
| set(_paddle_cuda_available ON) | |
| endif() | |
| if(_paddle_cuda_available) | |
| # Paddle's CUDA compat headers (CUDAContextLight.h, CUDAFunctions.h) | |
| # require PADDLE_WITH_CUDA to be defined so that GPU type aliases | |
| # (gpuStream_t, cudaDeviceProp) are resolved via cuda_runtime.h. | |
| target_compile_definitions(${_test_name} PRIVATE PADDLE_WITH_CUDA) | |
| # Link libcudart for CUDA runtime symbols used by the Paddle CUDA | |
| # compat layer. | |
| if(TARGET CUDA::cudart) | |
| target_link_libraries(${_test_name} CUDA::cudart) | |
| elseif(EXISTS "/usr/local/cuda/lib64/libcudart.so") | |
| target_link_libraries(${_test_name} | |
| "/usr/local/cuda/lib64/libcudart.so") | |
| endif() | |
| else() | |
| message(WARNING | |
| "USE_PADDLE_API is enabled, but CUDA toolkit was not detected; " | |
| "skipping PADDLE_WITH_CUDA definition and cudart linkage for " | |
| "test target ${_test_name}.") | |
| endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find_package(CUDAToolkit QUIET)falls back to a warning and continues even when CUDA headers aren’t present, buttest/ops/CUDABlasTest.cppincludes CUDA-specific headers and is always part ofTEST_SRC_FILES, so the build can still hard-fail at compile time. Consider either making CUDA headers a hard requirement for building this test (useREQUIREDor a dedicated option) or conditionally excludingCUDABlasTest.cppfromTEST_SRC_FILESwhen CUDA isn’t found.