diff --git a/hipify-clang/src/CUDA2HIP.cpp b/hipify-clang/src/CUDA2HIP.cpp index c0879c1f98..01b23bf007 100644 --- a/hipify-clang/src/CUDA2HIP.cpp +++ b/hipify-clang/src/CUDA2HIP.cpp @@ -12,6 +12,8 @@ const std::map CUDA_INCLUDE_MAP{ {"cuda_fp16.h", {"hip/hip_fp16.h", CONV_INCLUDE, API_RUNTIME}}, {"cuda_texture_types.h", {"hip/hip_texture_types.h", CONV_INCLUDE, API_RUNTIME}}, {"vector_types.h", {"hip/hip_vector_types.h", CONV_INCLUDE, API_RUNTIME}}, + // cuComplex includes + {"cuComplex.h", {"hip/hip_complex.h", CONV_INCLUDE_CUDA_MAIN_H, API_COMPLEX}}, // cuBLAS includes {"cublas.h", {"hipblas.h", CONV_INCLUDE_CUDA_MAIN_H, API_BLAS}}, {"cublas_v2.h", {"hipblas.h", CONV_INCLUDE_CUDA_MAIN_H, API_BLAS}}, @@ -37,8 +39,9 @@ const std::map CUDA_INCLUDE_MAP{ {"cudnn.h", {"hipDNN.h", CONV_INCLUDE_CUDA_MAIN_H, API_DNN}}, // cuFFT includes {"cufft.h", {"hipfft.h", CONV_INCLUDE_CUDA_MAIN_H, API_FFT}}, - // cuComplex includes - {"cuComplex.h", {"hip/hip_complex.h", CONV_INCLUDE_CUDA_MAIN_H, API_COMPLEX}}, + // cuBLAS includes + {"cusparse.h", {"hipsparse.h", CONV_INCLUDE_CUDA_MAIN_H, API_SPARSE}}, + {"cusparse_v2.h", {"hipsparse.h", CONV_INCLUDE_CUDA_MAIN_H, API_SPARSE}}, }; const std::map& CUDA_RENAMES_MAP() { @@ -61,5 +64,7 @@ const std::map& CUDA_RENAMES_MAP() { ret.insert(CUDA_DNN_FUNCTION_MAP.begin(), CUDA_DNN_FUNCTION_MAP.end()); ret.insert(CUDA_FFT_TYPE_NAME_MAP.begin(), CUDA_FFT_TYPE_NAME_MAP.end()); ret.insert(CUDA_FFT_FUNCTION_MAP.begin(), CUDA_FFT_FUNCTION_MAP.end()); + ret.insert(CUDA_SPARSE_TYPE_NAME_MAP.begin(), CUDA_SPARSE_TYPE_NAME_MAP.end()); + ret.insert(CUDA_SPARSE_FUNCTION_MAP.begin(), CUDA_SPARSE_FUNCTION_MAP.end()); return ret; }; diff --git a/hipify-clang/src/CUDA2HIP.h b/hipify-clang/src/CUDA2HIP.h index 5c3a6fa246..637dbf6998 100644 --- a/hipify-clang/src/CUDA2HIP.h +++ b/hipify-clang/src/CUDA2HIP.h @@ -37,6 +37,10 @@ extern const std::map CUDA_DNN_FUNCTION_MAP; extern const std::map CUDA_FFT_TYPE_NAME_MAP; // Maps the names of CUDA FFT API functions to the corresponding HIP functions extern const std::map CUDA_FFT_FUNCTION_MAP; +// Maps the names of CUDA SPARSE API types to the corresponding HIP types +extern const std::map CUDA_SPARSE_TYPE_NAME_MAP; +// Maps the names of CUDA SPARSE API functions to the corresponding HIP functions +extern const std::map CUDA_SPARSE_FUNCTION_MAP; /** * The union of all the above maps, except includes. diff --git a/hipify-clang/src/CUDA2HIP_Complex_API_functions.cpp b/hipify-clang/src/CUDA2HIP_Complex_API_functions.cpp index 3bc7c4f0a0..1adabc4f5d 100644 --- a/hipify-clang/src/CUDA2HIP_Complex_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_Complex_API_functions.cpp @@ -1,6 +1,6 @@ #include "CUDA2HIP.h" -// Maps the names of CUDA DRIVER API types to the corresponding HIP types +// Maps the names of CUDA Complex API types to the corresponding HIP types const std::map CUDA_COMPLEX_FUNCTION_MAP{ {"cuCrealf", {"hipCrealf", CONV_COMPLEX, API_COMPLEX}}, {"cuCimagf", {"hipCimagf", CONV_COMPLEX, API_COMPLEX}}, diff --git a/hipify-clang/src/CUDA2HIP_Complex_API_types.cpp b/hipify-clang/src/CUDA2HIP_Complex_API_types.cpp index f371cf3b9a..6b7eec96fe 100644 --- a/hipify-clang/src/CUDA2HIP_Complex_API_types.cpp +++ b/hipify-clang/src/CUDA2HIP_Complex_API_types.cpp @@ -1,6 +1,6 @@ #include "CUDA2HIP.h" -// Maps the names of CUDA DRIVER API types to the corresponding HIP types +// Maps the names of CUDA Complex API types to the corresponding HIP types const std::map CUDA_COMPLEX_TYPE_NAME_MAP{ {"cuFloatComplex", {"hipFloatComplex", CONV_TYPE, API_COMPLEX}}, {"cuDoubleComplex", {"hipDoubleComplex", CONV_TYPE, API_COMPLEX}}, diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp new file mode 100644 index 0000000000..9331e297d7 --- /dev/null +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -0,0 +1,5 @@ +#include "CUDA2HIP.h" + +// Maps the names of CUDA SPARSE API types to the corresponding HIP types +const std::map CUDA_SPARSE_FUNCTION_MAP{ +}; diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp new file mode 100644 index 0000000000..7cb252a8e2 --- /dev/null +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp @@ -0,0 +1,5 @@ +#include "CUDA2HIP.h" + +// Maps the names of CUDA SPARSE API types to the corresponding HIP types +const std::map CUDA_SPARSE_TYPE_NAME_MAP{ +}; diff --git a/hipify-clang/src/HipifyAction.cpp b/hipify-clang/src/HipifyAction.cpp index b370df794e..71e7b759ac 100644 --- a/hipify-clang/src/HipifyAction.cpp +++ b/hipify-clang/src/HipifyAction.cpp @@ -155,6 +155,10 @@ bool HipifyAction::Exclude(const hipCounter & hipToken) { if (insertedComplexHeader) { return true; } insertedComplexHeader = true; return false; + case API_SPARSE: + if (insertedSPARSEHeader) { return true; } + insertedSPARSEHeader = true; + return false; default: return false; } diff --git a/hipify-clang/src/HipifyAction.h b/hipify-clang/src/HipifyAction.h index 9d30a72592..99cb52e74c 100644 --- a/hipify-clang/src/HipifyAction.h +++ b/hipify-clang/src/HipifyAction.h @@ -29,6 +29,7 @@ private: bool insertedRAND_kernelHeader = false; bool insertedDNNHeader = false; bool insertedFFTHeader = false; + bool insertedSPARSEHeader = false; bool insertedComplexHeader = false; bool firstHeader = false; bool pragmaOnce = false; diff --git a/hipify-clang/src/Statistics.cpp b/hipify-clang/src/Statistics.cpp index 2d37c3156c..95aa15c5ce 100644 --- a/hipify-clang/src/Statistics.cpp +++ b/hipify-clang/src/Statistics.cpp @@ -43,7 +43,14 @@ const char *counterNames[NUM_CONV_TYPES] = { }; const char *apiNames[NUM_API_TYPES] = { - "CUDA Driver API", "CUDA RT API", "CUBLAS API", "CURAND API", "CUDNN API", "CUFFT API", "cuComplex API" + "CUDA Driver API", + "CUDA RT API", + "cuComplex API", + "cuBLAS API", + "cuRAND API", + "cuDNN API", + "cuFFT API", + "cuSPARSE" }; namespace { diff --git a/hipify-clang/src/Statistics.h b/hipify-clang/src/Statistics.h index 0ce8e0de67..7c81a15e4d 100644 --- a/hipify-clang/src/Statistics.h +++ b/hipify-clang/src/Statistics.h @@ -103,11 +103,12 @@ constexpr int NUM_CONV_TYPES = (int) ConvTypes::CONV_LAST; enum ApiTypes { API_DRIVER = 0, API_RUNTIME, + API_COMPLEX, API_BLAS, API_RAND, API_DNN, API_FFT, - API_COMPLEX, + API_SPARSE, API_LAST }; constexpr int NUM_API_TYPES = (int) ApiTypes::API_LAST; diff --git a/tests/hipify-clang/headers_test_09.cu b/tests/hipify-clang/headers_test_09.cu index 5dbfaffc2d..13d2b688f9 100644 --- a/tests/hipify-clang/headers_test_09.cu +++ b/tests/hipify-clang/headers_test_09.cu @@ -48,6 +48,7 @@ // CHECK: #include // CHECK: #include "hipfft.h" +// CHECK: #include "hipsparse.h" #include @@ -95,3 +96,5 @@ #include #include "cufft.h" + +#include "cusparse.h"