From fe1e963299c1f4b63652e91a3f156d8a043d317b Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Sun, 28 Oct 2018 17:01:00 +0000 Subject: [PATCH 01/55] Rely on code object metadat for kernarg arguments alignof and sizeof. --- .../hip/hcc_detail/functional_grid_launch.hpp | 37 +++++-- include/hip/hcc_detail/program_state.hpp | 2 + src/program_state.cpp | 102 +++++++++++++++++- 3 files changed, 132 insertions(+), 9 deletions(-) diff --git a/include/hip/hcc_detail/functional_grid_launch.hpp b/include/hip/hcc_detail/functional_grid_launch.hpp index 66e5873f3a..3a19965974 100644 --- a/include/hip/hcc_detail/functional_grid_launch.hpp +++ b/include/hip/hcc_detail/functional_grid_launch.hpp @@ -33,6 +33,7 @@ THE SOFTWARE. #include #include +#include #include #include #include @@ -56,7 +57,9 @@ template < typename... Ts, typename std::enable_if::type* = nullptr> inline std::vector make_kernarg( - std::vector kernarg, const std::tuple&) { + const std::tuple&, + const std::vector>&, + std::vector kernarg) { return kernarg; } @@ -65,7 +68,9 @@ template < typename... Ts, typename std::enable_if::type* = nullptr> inline std::vector make_kernarg( - std::vector kernarg, const std::tuple& formals) { + const std::tuple& formals, + const std::vector>& size_align, + std::vector kernarg) { using T = typename std::tuple_element>::type; static_assert( @@ -80,24 +85,42 @@ inline std::vector make_kernarg( #endif kernarg.resize(round_up_to_next_multiple_nonnegative( - kernarg.size(), alignof(T)) + sizeof(T)); + kernarg.size(), size_align[n].second) + + size_align[n].first); - new (kernarg.data() + kernarg.size() - sizeof(T)) T{std::get(formals)}; + std::memcpy( + kernarg.data() + kernarg.size() - size_align[n].first, + &std::get(formals), + size_align[n].first); - return make_kernarg(std::move(kernarg), formals); + return make_kernarg(formals, size_align, std::move(kernarg)); } template inline std::vector make_kernarg( - void (*)(Formals...), std::tuple actuals) { + void (*kernel)(Formals...), std::tuple actuals) { static_assert(sizeof...(Formals) == sizeof...(Actuals), "The count of formal arguments must match the count of actuals."); + const auto it = function_names().find( + reinterpret_cast(kernel)); + + if (it == function_names().cend()) { + throw std::runtime_error{"Undefined __global__ function."}; + } + + const auto it1 = kernargs().find(it->second); + + if (it1 == kernargs().end()) { + throw std::runtime_error{ + "Missing metadata for __global__ function: " + it->second}; + } + std::tuple to_formals{std::move(actuals)}; std::vector kernarg; kernarg.reserve(sizeof(to_formals)); - return make_kernarg<0>(std::move(kernarg), to_formals); + return make_kernarg<0>(to_formals, it1->second, std::move(kernarg)); } void hipLaunchKernelGGLImpl(std::uintptr_t function_address, const dim3& numBlocks, diff --git a/include/hip/hcc_detail/program_state.hpp b/include/hip/hcc_detail/program_state.hpp index bdb87b3509..92bef22172 100644 --- a/include/hip/hcc_detail/program_state.hpp +++ b/include/hip/hcc_detail/program_state.hpp @@ -99,6 +99,8 @@ const std::unordered_map& function_names(bool rebuild = false); std::unordered_map& globals(bool rebuild = false); +std::unordered_map< + std::string, std::vector>>& kernargs(); hsa_executable_t load_executable(const std::string& file, hsa_executable_t executable, hsa_agent_t agent); diff --git a/src/program_state.cpp b/src/program_state.cpp index 8766134582..43ceedee7b 100644 --- a/src/program_state.cpp +++ b/src/program_state.cpp @@ -306,8 +306,8 @@ const unordered_map>& kernels(bool rebui void load_code_object_and_freeze_executable( const string& file, hsa_agent_t agent, - hsa_executable_t - executable) { // TODO: the following sequence is inefficient, should be refactored + hsa_executable_t executable) { + // TODO: the following sequence is inefficient, should be refactored // into a single load of the file and subsequent ELFIO // processing. static const auto cor_deleter = [](hsa_code_object_reader_t* p) { @@ -334,6 +334,85 @@ void load_code_object_and_freeze_executable( code_readers.push_back(move(tmp)); } } + +size_t parse_args( + const string& metadata, + size_t f, + size_t l, + vector>& size_align) { + if (f == l) return f; + + do { + static constexpr size_t size_sz{5}; + f = metadata.find("Size:", f) + size_sz; + + if (l <= f) return f; + + auto size = strtoul(&metadata[f], nullptr, 10); + + static constexpr size_t align_sz{6}; + f = metadata.find("Align:", f) + align_sz; + + char* l{}; + auto align = strtoul(&metadata[f], &l, 10); + + f += (l - &metadata[f]) + 1; + + size_align.emplace_back(size, align); + } while (true); +} + +void read_kernarg_metadata( + elfio& reader, + unordered_map>>& kernargs) +{ // TODO: this is inefficient. + auto it = find_section_if( + reader, [](const section* x) { return x->get_type() == SHT_NOTE; }); + + if (!it) return; + + const note_section_accessor acc{reader, it}; + for (decltype(acc.get_notes_num()) i = 0; i != acc.get_notes_num(); ++i) { + ELFIO::Elf_Word type{}; + string name{}; + void* desc{}; + Elf_Word desc_size{}; + + acc.get_note(i, type, name, desc, desc_size); + + if (name != "AMD") continue; // TODO: switch to using NT_AMD_AMDGPU_HSA_METADATA. + + string tmp{ + static_cast(desc), static_cast(desc) + desc_size}; + + auto dx = tmp.find("Kernels:"); + + if (dx == string::npos) continue; + + static constexpr decltype(tmp.size()) kernels_sz{8}; + dx += kernels_sz; + + do { + dx = tmp.find("Name:", dx); + + if (dx == string::npos) break; + + static constexpr decltype(tmp.size()) name_sz{5}; + dx = tmp.find_first_not_of(' ', dx + name_sz); + + auto fn = tmp.substr(dx, tmp.find('\n', dx) - dx); + dx += fn.size(); + + dx = tmp.find("Args:", dx); + + if (dx == string::npos) break; + + static constexpr decltype(tmp.size()) args_sz{5}; + dx = parse_args( + tmp, dx + args_sz, tmp.find("CodeProps", dx), kernargs[fn]); + } while (true); + } +} } // namespace namespace hip_impl { @@ -495,6 +574,25 @@ unordered_map& globals(bool rebuild) { return r; } +unordered_map>>& kernargs() { + static unordered_map>> r; + static once_flag f; + + call_once(f, []() { + for (auto&& blob : code_object_blobs()) { + stringstream tmp{std::string{ + blob.second.front().cbegin(), blob.second.front().cend()}}; + + elfio reader; + if (!reader.load(tmp)) continue; + + read_kernarg_metadata(reader, r); + } + }); + + return r; +} + hsa_executable_t load_executable(const string& file, hsa_executable_t executable, hsa_agent_t agent) { elfio reader; From bce3de81624d9b3d114074d87cb6defc353bd2cb Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 30 Oct 2018 01:55:09 +0000 Subject: [PATCH 02/55] Handle the very confusing dual encoding of the symbol name. --- src/program_state.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/program_state.cpp b/src/program_state.cpp index 43ceedee7b..4cee70c8f2 100644 --- a/src/program_state.cpp +++ b/src/program_state.cpp @@ -398,11 +398,10 @@ void read_kernarg_metadata( if (dx == string::npos) break; static constexpr decltype(tmp.size()) name_sz{5}; - dx = tmp.find_first_not_of(' ', dx + name_sz); + dx = tmp.find_first_not_of(" '", dx + name_sz); - auto fn = tmp.substr(dx, tmp.find('\n', dx) - dx); + auto fn = tmp.substr(dx, tmp.find_first_of("'\n", dx) - dx); dx += fn.size(); - dx = tmp.find("Args:", dx); if (dx == string::npos) break; @@ -590,6 +589,7 @@ unordered_map>>& kernargs() { } }); + for (auto&& x : r) std::cerr << x.first << std::endl; return r; } From f7ba987038cafd7799c5ea5f5e347b7098a39d85 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Tue, 30 Oct 2018 23:34:27 +0000 Subject: [PATCH 03/55] If we've already seen a `__global__` function we do not need to re-parse --- src/program_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/program_state.cpp b/src/program_state.cpp index 4cee70c8f2..00d8e3a0b2 100644 --- a/src/program_state.cpp +++ b/src/program_state.cpp @@ -341,6 +341,7 @@ size_t parse_args( size_t l, vector>& size_align) { if (f == l) return f; + if (!size_align.empty()) return l; do { static constexpr size_t size_sz{5}; @@ -589,7 +590,6 @@ unordered_map>>& kernargs() { } }); - for (auto&& x : r) std::cerr << x.first << std::endl; return r; } From 73616582d6f8858d141933858f4b6db5d7cd51c5 Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Sun, 4 Nov 2018 10:39:34 +0100 Subject: [PATCH 04/55] Implement hipGetSymbolAddress and hipGetSymbolSize --- ..._Runtime_API_functions_supported_by_HIP.md | 8 +++--- docs/markdown/hip_kernel_language.md | 2 +- .../src/CUDA2HIP_Runtime_API_functions.cpp | 4 +-- include/hip/hcc_detail/hip_runtime_api.h | 26 +++++++++++++++++++ include/hip/nvcc_detail/hip_runtime_api.h | 8 ++++++ src/hip_memory.cpp | 17 ++++++++++++ 6 files changed, 58 insertions(+), 7 deletions(-) diff --git a/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md b/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md index 1a55667f82..7e5cd6fc3d 100644 --- a/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md +++ b/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md @@ -122,8 +122,8 @@ | `cudaFreeHost` | `hipHostFree` | | `cudaFreeMipmappedArray` | | | `cudaGetMipmappedArrayLevel` | | -| `cudaGetSymbolAddress` | | -| `cudaGetSymbolSize` | | +| `cudaGetSymbolAddress` | `hipGetSymbolAddress` | +| `cudaGetSymbolSize` | `hipGetSymbolSize` | | `cudaHostAlloc` | `hipHostMalloc` | | `cudaHostGetDevicePointer` | `hipHostGetDevicePointer` | | `cudaHostGetFlags` | `hipHostGetFlags` | @@ -373,8 +373,8 @@ | `cudaCreateChannelDesc` | `hipCreateChannelDesc` | | `cudaFuncGetAttributes` | | | `cudaFuncSetCacheConfig` | | -| `cudaGetSymbolAddress` | | -| `cudaGetSymbolSize` | | +| `cudaGetSymbolAddress` | `hipGetSymbolAddress` | +| `cudaGetSymbolSize` | `hipGetSymbolSize` | | `cudaGetTextureAlignmentOffset` | | | `cudaLaunch` | | | `cudaLaunchKernel` | | diff --git a/docs/markdown/hip_kernel_language.md b/docs/markdown/hip_kernel_language.md index 7c209acadf..d69f5a04a8 100644 --- a/docs/markdown/hip_kernel_language.md +++ b/docs/markdown/hip_kernel_language.md @@ -159,7 +159,7 @@ void callMyKernel() ## Variable-Type Qualifiers ### `__constant__` -The `__constant__` keyword is supported. The host writes constant memory before launching the kernel; from the GPU, this memory is read-only during kernel execution. The functions for accessing constant memory (hipGetSymbolAddress(), hipGetSymbolSize(), hipMemcpyToSymbol(), hipMemcpyToSymbolAsync, hipMemcpyFromSymbol, hipMemcpyFromSymbolAsync) are under development. +The `__constant__` keyword is supported. The host writes constant memory before launching the kernel; from the GPU, this memory is read-only during kernel execution. The functions for accessing constant memory (hipGetSymbolAddress(), hipGetSymbolSize(), hipMemcpyToSymbol(), hipMemcpyToSymbolAsync(), hipMemcpyFromSymbol(), hipMemcpyFromSymbolAsync()) are available. ### `__shared__` The `__shared__` keyword is supported. diff --git a/hipify-clang/src/CUDA2HIP_Runtime_API_functions.cpp b/hipify-clang/src/CUDA2HIP_Runtime_API_functions.cpp index 6c81de2817..12427b2ff4 100644 --- a/hipify-clang/src/CUDA2HIP_Runtime_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_Runtime_API_functions.cpp @@ -46,8 +46,8 @@ const std::map CUDA_RUNTIME_FUNCTION_MAP{ {"cudaArrayGetInfo", {"hipArrayGetInfo", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaFreeMipmappedArray", {"hipFreeMipmappedArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaGetMipmappedArrayLevel", {"hipGetMipmappedArrayLevel", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, - {"cudaGetSymbolAddress", {"hipGetSymbolAddress", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, - {"cudaGetSymbolSize", {"hipGetSymbolSize", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, + {"cudaGetSymbolAddress", {"hipGetSymbolAddress", CONV_MEMORY, API_RUNTIME}}, + {"cudaGetSymbolSize", {"hipGetSymbolSize", CONV_MEMORY, API_RUNTIME}}, {"cudaMemPrefetchAsync", {"hipMemPrefetchAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, // // API_Driver ANALOGUE (cuMemPrefetchAsync) // malloc diff --git a/include/hip/hcc_detail/hip_runtime_api.h b/include/hip/hcc_detail/hip_runtime_api.h index c9ff32d197..8b8bbe9e4f 100644 --- a/include/hip/hcc_detail/hip_runtime_api.h +++ b/include/hip/hcc_detail/hip_runtime_api.h @@ -1385,6 +1385,32 @@ hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t siz size_t offset __dparm(0), hipMemcpyKind kind __dparm(hipMemcpyHostToDevice)); +/** + * @brief Copies the memory address of symbol @p symbolName to @p devPtr + * + * @param[in] symbolName - Symbol on device + * @param[out] devPtr - Pointer to a pointer to the memory referred to by the symbol + * @return #... + * + * @see hipGetSymbolSize, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpyToSymbolAsync, + * hipMemcpyFromSymbolAsync + */ +hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName); + + +/** + * @brief Copies the size of symbol @p symbolName to @p size + * + * @param[in] symbolName - Symbol on device + * @param[out] size - Pointer to the size of the symbol + * @return #... + * + * @see hipGetSymbolSize, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpyToSymbolAsync, + * hipMemcpyFromSymbolAsync + */ +hipError_t hipGetSymbolSize(size_t* size, const void* symbolName); + + /** * @brief Copies @p sizeBytes bytes from the memory area pointed to by @p src to the memory area * pointed to by @p offset bytes from the start of symbol @p symbol diff --git a/include/hip/nvcc_detail/hip_runtime_api.h b/include/hip/nvcc_detail/hip_runtime_api.h index e68e8ac328..88867567c9 100644 --- a/include/hip/nvcc_detail/hip_runtime_api.h +++ b/include/hip/nvcc_detail/hip_runtime_api.h @@ -551,6 +551,14 @@ inline static hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolN dst, symbolName, sizeBytes, offset, hipMemcpyKindToCudaMemcpyKind(kind), stream)); } +inline static hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName) { + return hipCUDAErrorTohipError(cudaGetSymbolAddress(devPtr, symbolName); +} + +inline static hipError_t hipGetSymbolSize(size_t* size, const void* symbolName) { + return hipCUDAErrorTohipError(cudaGetSymbolSize(size, symbolName); +} + inline static hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) { return hipCUDAErrorTohipError( diff --git a/src/hip_memory.cpp b/src/hip_memory.cpp index 4ea5b24f43..87e5f97e73 100644 --- a/src/hip_memory.cpp +++ b/src/hip_memory.cpp @@ -1099,6 +1099,23 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t co return ihipLogStatus(e); } + +hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName) { + HIP_INIT_SPECIAL_API((TRACE_MCMD), devPtr, symbolName); + + size_t size = 0; + return hipModuleGetGlobal(devPtr, &size, 0, static_cast(symbolName)); +} + + +hipError_t hipGetSymbolSize(size_t* size, const void* symbolName) { + HIP_INIT_SPECIAL_API((TRACE_MCMD), size, symbolName); + + void* devPtr = nullptr; + return hipModuleGetGlobal(&devPtr, size, 0, static_cast(symbolName)); +} + + //--- hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind) { HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, kind); From 4390c82121c2bfef05ee770973c0743444f3e17b Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Sun, 4 Nov 2018 11:47:17 +0100 Subject: [PATCH 05/55] Document return values of hipMemcpyToSymbol, hipGetSymbolAddress --- include/hip/hcc_detail/hip_runtime_api.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hip/hcc_detail/hip_runtime_api.h b/include/hip/hcc_detail/hip_runtime_api.h index 8b8bbe9e4f..cfecb144c3 100644 --- a/include/hip/hcc_detail/hip_runtime_api.h +++ b/include/hip/hcc_detail/hip_runtime_api.h @@ -1390,7 +1390,7 @@ hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t siz * * @param[in] symbolName - Symbol on device * @param[out] devPtr - Pointer to a pointer to the memory referred to by the symbol - * @return #... + * @return #hipSuccess, #hipErrorNotInitialized, #hipErrorNotFound * * @see hipGetSymbolSize, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpyToSymbolAsync, * hipMemcpyFromSymbolAsync @@ -1403,7 +1403,7 @@ hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName); * * @param[in] symbolName - Symbol on device * @param[out] size - Pointer to the size of the symbol - * @return #... + * @return #hipSuccess, #hipErrorNotInitialized, #hipErrorNotFound * * @see hipGetSymbolSize, hipMemcpyToSymbol, hipMemcpyFromSymbol, hipMemcpyToSymbolAsync, * hipMemcpyFromSymbolAsync From 31acf1c268a51a6e50d60f2a84154caab5cccd61 Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Tue, 6 Nov 2018 09:54:34 +0100 Subject: [PATCH 06/55] Introduce ihipModuleGetGlobal --- include/hip/hcc_detail/hip_runtime_api.h | 3 +++ src/hip_memory.cpp | 6 +++--- src/hip_module.cpp | 11 ++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/hip/hcc_detail/hip_runtime_api.h b/include/hip/hcc_detail/hip_runtime_api.h index cfecb144c3..3567a67854 100644 --- a/include/hip/hcc_detail/hip_runtime_api.h +++ b/include/hip/hcc_detail/hip_runtime_api.h @@ -2360,6 +2360,9 @@ hipError_t hipFuncGetAttributes(hipFuncAttributes* attr, const void* func); hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod, const char* name); +hipError_t ihipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod, + const char* name); + hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const char* name); /** * @brief builds module from code object which resides in host memory. Image is pointer to that diff --git a/src/hip_memory.cpp b/src/hip_memory.cpp index 87e5f97e73..4322ada199 100644 --- a/src/hip_memory.cpp +++ b/src/hip_memory.cpp @@ -953,7 +953,7 @@ inline hipDeviceptr_t agent_address_for_symbol(const char* symbolName) { #if __hcc_workweek__ >= 17481 size_t byte_cnt = 0u; - hipModuleGetGlobal(&r, &byte_cnt, 0, symbolName); + ihipModuleGetGlobal(&r, &byte_cnt, 0, symbolName); #else auto ctx = ihipGetTlsDefaultCtx(); auto acc = ctx->getDevice()->_acc; @@ -1104,7 +1104,7 @@ hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName) { HIP_INIT_SPECIAL_API((TRACE_MCMD), devPtr, symbolName); size_t size = 0; - return hipModuleGetGlobal(devPtr, &size, 0, static_cast(symbolName)); + return ihipModuleGetGlobal(devPtr, &size, 0, static_cast(symbolName)); } @@ -1112,7 +1112,7 @@ hipError_t hipGetSymbolSize(size_t* size, const void* symbolName) { HIP_INIT_SPECIAL_API((TRACE_MCMD), size, symbolName); void* devPtr = nullptr; - return hipModuleGetGlobal(&devPtr, size, 0, static_cast(symbolName)); + return ihipModuleGetGlobal(&devPtr, size, 0, static_cast(symbolName)); } diff --git a/src/hip_module.cpp b/src/hip_module.cpp index a6d486b6de..efb091f68a 100644 --- a/src/hip_module.cpp +++ b/src/hip_module.cpp @@ -463,14 +463,19 @@ hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t h const char* name) { HIP_INIT_API(dptr, bytes, hmod, name); - if (!dptr || !bytes) return ihipLogStatus(hipErrorInvalidValue); + return ihipLogStatus(ihipModuleGetGlobal(dptr, bytes, hmod, name)); +} - if (!name) return ihipLogStatus(hipErrorNotInitialized); +hipError_t ihipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod, + const char* name) { + if (!dptr || !bytes) return hipErrorInvalidValue; + + if (!name) return hipErrorNotInitialized; const auto r = hmod ? read_agent_global_from_module(dptr, bytes, hmod, name) : read_agent_global_from_process(dptr, bytes, name); - return ihipLogStatus(r); + return r; } namespace From 49cc703d7a01b37c1dcf44de14273bd2d6c7379c Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Tue, 6 Nov 2018 11:39:34 +0100 Subject: [PATCH 07/55] Test for hipGetSymbolSize and hipGetSymbolAddress --- tests/src/deviceLib/hipTestDeviceSymbol.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 4bac9a902b..a17dd75a31 100644 --- a/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -40,6 +40,12 @@ __global__ void Assign(int* Out) { globalOut[tid] = globalIn[tid]; } +__device__ __constant__ int globalConst[NUM]; + +__global__ void checkAddress(int* addr, bool* out) { + *out = (globalConst == addr); +} + int main() { int *A, *Am, *B, *Ad, *C, *Cm; A = new int[NUM]; @@ -101,6 +107,20 @@ int main() { assert(A[i] == B[i]); assert(A[i] == C[i]); } + + bool *checkOkD; + bool checkOk = false; + size_t symbolSize = 0; + int *symbolAddress; + hipGetSymbolSize(&symbolSize, HIP_SYMBOL(globalConst)); + hipGetSymbolAddress((void**) &symbolAddress, HIP_SYMBOL(globalConst)); + hipMalloc((void**)&checkOkD, sizeof(bool)); + hipLaunchKernelGGL(checkAddress, dim3(1, 1, 1), dim3(1, 1, 1), 0, 0, symbolAddress, checkOkD); + hipMemcpy(&checkOk, checkOkD, sizeof(bool), hipMemcpyDeviceToHost); + hipFree(checkOkD); + assert(checkOk); + assert(symbolSize == SIZE); + hipHostFree(Am); hipHostFree(Cm); hipFree(Ad); From 509b29594a9e70c95c1544badedd98812dab92b8 Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Tue, 6 Nov 2018 12:02:21 +0100 Subject: [PATCH 08/55] hipify-perl: add hipGetSymbolAddress and hipGetSymbolSize --- bin/hipify-perl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/hipify-perl b/bin/hipify-perl index 3ea201d14f..792bf86d94 100755 --- a/bin/hipify-perl +++ b/bin/hipify-perl @@ -287,6 +287,9 @@ while (@ARGV) { $ft{'mem'} += s/\bcudaMemcpy2DToArray\b/hipMemcpy2DToArray/g; $ft{'mem'} += s/\bcudaMemcpyToArray\b/hipMemcpyToArray/g; + $ft{'mem'} += s/\bcudaGetSymbolAddress\b/hipGetSymbolAddress/g; + $ft{'mem'} += s/\bcudaGetSymbolSize\b/hipGetSymbolSize/g; + #-------- # Memory management: $ft{'mem'} += s/\bcudaMalloc\b/hipMalloc/g; From 6ebcc2922cbce135d7bd48a7e9623295e73d3b73 Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Tue, 6 Nov 2018 20:46:30 +0100 Subject: [PATCH 09/55] Use correct trace macro in hipGetSymbolAddress/hipGetSymbolSize --- src/hip_memory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hip_memory.cpp b/src/hip_memory.cpp index 4322ada199..d02bb5acb8 100644 --- a/src/hip_memory.cpp +++ b/src/hip_memory.cpp @@ -1101,7 +1101,7 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t co hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), devPtr, symbolName); + HIP_INIT_API(devPtr, symbolName); size_t size = 0; return ihipModuleGetGlobal(devPtr, &size, 0, static_cast(symbolName)); @@ -1109,7 +1109,7 @@ hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName) { hipError_t hipGetSymbolSize(size_t* size, const void* symbolName) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), size, symbolName); + HIP_INIT_API(size, symbolName); void* devPtr = nullptr; return ihipModuleGetGlobal(&devPtr, size, 0, static_cast(symbolName)); From a31b6b78d56c0e65819250912ced6cad471858e1 Mon Sep 17 00:00:00 2001 From: Yaxun Sam Liu Date: Wed, 31 Oct 2018 14:09:59 -0400 Subject: [PATCH 10/55] Add more checks for fatbin --- src/hip_clang.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hip_clang.cpp b/src/hip_clang.cpp index cfd75df562..44080884e7 100644 --- a/src/hip_clang.cpp +++ b/src/hip_clang.cpp @@ -165,11 +165,13 @@ extern "C" void __hipRegisterFunction( assert(modules && modules->size() >= g_deviceCnt); for (int deviceId = 0; deviceId < g_deviceCnt; ++deviceId) { hipFunction_t function; - if (hipSuccess == hipModuleGetFunction(&function, modules->at(deviceId), deviceName)) { + if (hipSuccess == hipModuleGetFunction(&function, modules->at(deviceId), deviceName) && + function != nullptr) { functions[deviceId] = function; } else { - tprintf(DB_FB, "missing kernel %s for device %d\n", deviceName, deviceId); + tprintf(DB_FB, "__hipRegisterFunction cannot find kernel %s for" + " device %d\n", deviceName, deviceId); } } @@ -249,9 +251,11 @@ hipError_t hipLaunchByPtr(const void *hostFunction) hipError_t e = hipSuccess; decltype(g_functions)::iterator it; - if ((it = g_functions.find(hostFunction)) == g_functions.end()) { + if ((it = g_functions.find(hostFunction)) == g_functions.end() || + !it->second[deviceId]) { e = hipErrorUnknown; - fprintf(stderr, "kernel %p not found!\n", hostFunction); + fprintf(stderr, "hipLaunchByPtr cannot find kernel with stub address %p" + " for device %d!\n", hostFunction, deviceId); abort(); } else { size_t size = exec._arguments.size(); From 3d51a1fb0105e2f2312d2523c20e0034339f6ada Mon Sep 17 00:00:00 2001 From: Yaxun Sam Liu Date: Thu, 8 Nov 2018 11:28:47 -0500 Subject: [PATCH 11/55] Let hipcc handle clang-offload-bundler file in obj format for hip-clang --- bin/hipcc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/hipcc b/bin/hipcc index cea6211a87..68e4a96721 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -498,6 +498,10 @@ foreach $arg (@ARGV) $obj = "$tmpdir/$obj"; my $fileType = `file $obj`; my $isObj = ($fileType =~ m/ELF/ or $fileType =~ m/COFF/); + if ($fileType =~ m/ELF/) { + my $sections = `readelf -e -W $obj`; + $isObj = !($sections =~ m/__CLANG_OFFLOAD_BUNDLE__/); + } $allIsObj = ($allIsObj and $isObj); if ($isObj) { $realObjs = ($realObjs . " " . $obj); From c0bd1a5af8636d0c5d3fa52fcd20d8676c25ff39 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Mon, 12 Nov 2018 00:32:35 +0000 Subject: [PATCH 12/55] Handle (odd) corner case of argumentless __global__ function. --- include/hip/hcc_detail/functional_grid_launch.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/hip/hcc_detail/functional_grid_launch.hpp b/include/hip/hcc_detail/functional_grid_launch.hpp index ba9929c0a6..5edddad6c5 100644 --- a/include/hip/hcc_detail/functional_grid_launch.hpp +++ b/include/hip/hcc_detail/functional_grid_launch.hpp @@ -102,6 +102,8 @@ inline std::vector make_kernarg( static_assert(sizeof...(Formals) == sizeof...(Actuals), "The count of formal arguments must match the count of actuals."); + if (sizeof...(Formals) == 0) return {}; + const auto it = function_names().find( reinterpret_cast(kernel)); From 4ebc229b9ad496d3974641273eba4a5cb8a7af72 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Mon, 12 Nov 2018 01:51:59 +0000 Subject: [PATCH 13/55] Missing handling nullary `__global__` functions for mixed arity cases. --- src/program_state.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/program_state.cpp b/src/program_state.cpp index 97e9035e0d..7e42a44245 100644 --- a/src/program_state.cpp +++ b/src/program_state.cpp @@ -409,13 +409,18 @@ void read_kernarg_metadata( auto fn = tmp.substr(dx, tmp.find_first_of("'\n", dx) - dx); dx += fn.size(); + + auto dx1 = tmp.find("CodeProps", dx); dx = tmp.find("Args:", dx); + if (dx1 < dx) { + dx = dx1; + continue; + } if (dx == string::npos) break; static constexpr decltype(tmp.size()) args_sz{5}; - dx = parse_args( - tmp, dx + args_sz, tmp.find("CodeProps", dx), kernargs[fn]); + dx = parse_args(tmp, dx + args_sz, dx1, kernargs[fn]); } while (true); } } From 11e7ab8879952da0dec0e29976398da7850b47b0 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Tue, 13 Nov 2018 00:49:20 +0530 Subject: [PATCH 14/55] Fixed hipMemcpyToSymbol doesn't work on GPU other than device 0 SWDEV-166881 --- src/hip_memory.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/hip_memory.cpp b/src/hip_memory.cpp index 4ea5b24f43..7c25b714f8 100644 --- a/src/hip_memory.cpp +++ b/src/hip_memory.cpp @@ -985,10 +985,9 @@ hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t cou hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); - if (kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost || + if (kind == hipMemcpyHostToDevice || kind == hipMemcpyDefault || kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) { - stream->lockedSymbolCopySync(acc, dst, (void*)src, count, offset, kind); - // acc.memcpy_symbol(dst, (void*)src, count+offset); + stream->locked_copySync((char*)dst+offset, (void*)src, count, kind, false); } else { return ihipLogStatus(hipErrorInvalidValue); } @@ -1018,9 +1017,9 @@ hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t count, hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); - if (kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost || + if (kind == hipMemcpyDefault || kind == hipMemcpyDeviceToHost || kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) { - stream->lockedSymbolCopySync(acc, dst, (void*)src, count, offset, kind); + stream->locked_copySync((void*)dst, (char*)src+offset, count, kind, false); } else { return ihipLogStatus(hipErrorInvalidValue); } @@ -1052,7 +1051,7 @@ hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src, size_ if (stream) { try { - stream->lockedSymbolCopyAsync(acc, dst, (void*)src, count, offset, kind); + hip_internal::memcpyAsync((char*)dst+offset, src, count, kind, stream); } catch (ihipException& ex) { e = ex._code; } @@ -1088,7 +1087,7 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t co stream = ihipSyncAndResolveStream(stream); if (stream) { try { - stream->lockedSymbolCopyAsync(acc, dst, src, count, offset, kind); + hip_internal::memcpyAsync(dst, (char*)src+offset, count, kind, stream); } catch (ihipException& ex) { e = ex._code; } From 17ac81b69eb8cdd74ce5ea660d7f83f9120b6b0c Mon Sep 17 00:00:00 2001 From: Yaxun Sam Liu Date: Sun, 11 Nov 2018 22:51:28 -0500 Subject: [PATCH 15/55] Define __hip_device_heap in header for hip-clang only --- include/hip/hcc_detail/hip_memory.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/hip/hcc_detail/hip_memory.h b/include/hip/hcc_detail/hip_memory.h index 2c9ec1b7c3..866b9e879e 100644 --- a/include/hip/hcc_detail/hip_memory.h +++ b/include/hip/hcc_detail/hip_memory.h @@ -41,8 +41,14 @@ THE SOFTWARE. #define __HIP_SIZE_OF_HEAP (__HIP_NUM_PAGES * __HIP_SIZE_OF_PAGE) +#if __HIP__ && __HIP_DEVICE_COMPILE__ +__attribute__((weak)) __device__ char __hip_device_heap[__HIP_SIZE_OF_HEAP]; +__attribute__((weak)) __device__ + uint32_t __hip_device_page_flag[__HIP_NUM_PAGES]; +#else extern __device__ char __hip_device_heap[]; extern __device__ uint32_t __hip_device_page_flag[]; +#endif extern "C" inline __device__ void* __hip_malloc(size_t size) { char* heap = (char*)__hip_device_heap; From bc40ddabe0b503135ee74c9ba0fa4242885ca57e Mon Sep 17 00:00:00 2001 From: Yaxun Sam Liu Date: Sun, 11 Nov 2018 15:49:34 -0500 Subject: [PATCH 16/55] Fix sample bit_extract for hip-clang --- samples/0_Intro/bit_extract/bit_extract.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/samples/0_Intro/bit_extract/bit_extract.cpp b/samples/0_Intro/bit_extract/bit_extract.cpp index ab7a4b35a6..5c3907f0d3 100644 --- a/samples/0_Intro/bit_extract/bit_extract.cpp +++ b/samples/0_Intro/bit_extract/bit_extract.cpp @@ -23,10 +23,6 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" -#ifdef __HIP_PLATFORM_HCC__ -#include -#endif - #define CHECK(cmd) \ { \ @@ -44,7 +40,7 @@ __global__ void bit_extract_kernel(uint32_t* C_d, const uint32_t* A_d, size_t N) for (size_t i = offset; i < N; i += stride) { #ifdef __HIP_PLATFORM_HCC__ - C_d[i] = hc::__bitextract_u32(A_d[i], 8, 4); + C_d[i] = __bitextract_u32(A_d[i], 8, 4); #else /* defined __HIP_PLATFORM_NVCC__ or other path */ C_d[i] = ((A_d[i] & 0xf00) >> 8); #endif From 6b3cbc65ad0de050699e8140b2a7869e784cd519 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Tue, 13 Nov 2018 07:01:17 +0530 Subject: [PATCH 17/55] Fixed symbol tracking device index --- src/hip_module.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hip_module.cpp b/src/hip_module.cpp index 1dc6701fe6..019bafbe43 100644 --- a/src/hip_module.cpp +++ b/src/hip_module.cpp @@ -258,12 +258,16 @@ struct Agent_global { uint32_t byte_cnt; }; -inline void track(const Agent_global& x) { +inline void track(const Agent_global& x, hsa_agent_t agent) { tprintf(DB_MEM, " add variable '%s' with ptr=%p size=%u to tracker\n", x.name.c_str(), x.address, x.byte_cnt); - auto device = ihipGetTlsDefaultCtx()->getWriteableDevice(); - + int deviceIndex =0; + for ( deviceIndex = 0; deviceIndex < g_deviceCnt; deviceIndex++) { + if(g_allAgents[deviceIndex] == agent) + break; + } + auto device = ihipGetDevice(deviceIndex - 1); hc::AmPointerInfo ptr_info(nullptr, x.address, x.address, x.byte_cnt, device->_acc, true, false); hc::am_memtracker_add(x.address, ptr_info); @@ -276,7 +280,7 @@ inline void track(const Agent_global& x) { } template > -inline hsa_status_t copy_agent_global_variables(hsa_executable_t, hsa_agent_t, +inline hsa_status_t copy_agent_global_variables(hsa_executable_t, hsa_agent_t agent, hsa_executable_symbol_t x, void* out) { assert(out); @@ -286,7 +290,7 @@ inline hsa_status_t copy_agent_global_variables(hsa_executable_t, hsa_agent_t, if (t == HSA_SYMBOL_KIND_VARIABLE) { static_cast(out)->push_back(Agent_global{name(x), address(x), size(x)}); - track(static_cast(out)->back()); + track(static_cast(out)->back(),agent); } return HSA_STATUS_SUCCESS; From b8b1637ef775dc56b0f0c5ce0b002c214ed44f24 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 7 Aug 2018 07:32:27 -0500 Subject: [PATCH 18/55] adding activity prof layer --- CMakeLists.txt | 14 + include/hip/hcc_detail/hip_runtime_api.h | 18 + include/hip/hip_prof_api.h | 198 ++ include/hip/hip_prof_str.h | 2450 ++++++++++++++++++++++ src/hip_context.cpp | 46 +- src/hip_device.cpp | 40 +- src/hip_error.cpp | 4 +- src/hip_event.cpp | 14 +- src/hip_hcc.cpp | 4 +- src/hip_hcc_internal.h | 10 + src/hip_intercept.cpp | 49 + src/hip_memory.cpp | 100 +- src/hip_module.cpp | 16 +- src/hip_peer.cpp | 14 +- src/hip_stream.cpp | 16 +- 15 files changed, 2866 insertions(+), 127 deletions(-) create mode 100644 include/hip/hip_prof_api.h create mode 100644 include/hip/hip_prof_str.h create mode 100644 src/hip_intercept.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e018a5e4fe..154971f480 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,19 @@ if(NOT DEFINED COMPILE_HIP_ATP_MARKER) endif() add_to_config(_buildInfo COMPILE_HIP_ATP_MARKER) +################ +# Detect profiling API +################ +if (USE_PROF_API EQUAL 1) +add_definitions(-DUSE_PROF_API=1) +find_path(PROF_API_HEADER_DIR NAMES prof_protocol.h PATHS ${PROF_API_HEADER_PATH} /opt/rocm/roctracer/include/roctracer NO_DEFAULT_PATH) +if (NOT PROF_API_HEADER_DIR) + MESSAGE("Profiling API header not found, use -DPROF_API_HEADER_PATH=") +else () + include_directories ( ${PROF_API_HEADER_DIR} ) +endif () +MESSAGE("PROF_API_HEADER_DIR = ${PROF_API_HEADER_DIR}") +endif () ############################# # Build steps @@ -204,6 +217,7 @@ if(HIP_PLATFORM STREQUAL "hcc") src/grid_launch.cpp src/hip_texture.cpp src/hip_surface.cpp + src/hip_intercept.cpp src/env.cpp src/program_state.cpp) diff --git a/include/hip/hcc_detail/hip_runtime_api.h b/include/hip/hcc_detail/hip_runtime_api.h index c9ff32d197..f95e44f610 100644 --- a/include/hip/hcc_detail/hip_runtime_api.h +++ b/include/hip/hcc_detail/hip_runtime_api.h @@ -2581,6 +2581,24 @@ hipError_t hipLaunchByPtr(const void* func); } /* extern "c" */ #endif +#include + +#ifdef __cplusplus +extern "C" { +#endif +/** + * Callback/Activity API + */ +hipError_t hipRegisterApiCallback(uint32_t id, void* fun, void* arg); +hipError_t hipRemoveApiCallback(uint32_t id); +hipError_t hipRegisterActivityCallback(uint32_t id, void* fun, void* arg); +hipError_t hipRemoveActivityCallback(uint32_t id); +static inline const char* hipApiName(const uint32_t& id) { return hip_api_name(id); } +const char* hipKernelNameRef(hipFunction_t f); +#ifdef __cplusplus +} /* extern "C" */ +#endif + #ifdef __cplusplus hipError_t hipBindTexture(size_t* offset, textureReference* tex, const void* devPtr, diff --git a/include/hip/hip_prof_api.h b/include/hip/hip_prof_api.h new file mode 100644 index 0000000000..3ab7a4d303 --- /dev/null +++ b/include/hip/hip_prof_api.h @@ -0,0 +1,198 @@ +// automatically generated sources +#ifndef _HIP_PROF_API_H +#define _HIP_PROF_API_H + +#include +#include + +#include "hip/hip_prof_str.h" + +template +class api_callbacks_table_templ { + public: + typedef std::recursive_mutex mutex_t; + + typedef Record record_t; + typedef Fun fun_t; + typedef Act act_t; + + // HIP API callbacks table + struct hip_cb_table_entry_t { + volatile std::atomic sync; + volatile std::atomic sem; + act_t act; + void* a_arg; + fun_t fun; + void* arg; + }; + + struct hip_cb_table_t { + hip_cb_table_entry_t arr[HIP_API_ID_NUMBER]; + }; + + api_callbacks_table_templ() { + memset(&callbacks_table_, 0, sizeof(callbacks_table_)); + } + + bool set_activity(uint32_t id, act_t fun, void* arg) { + std::lock_guard lock(mutex_); + bool ret = true; + if (id == HIP_API_ID_ANY) { + for (unsigned i = 0; i < HIP_API_ID_NUMBER; ++i) set_activity(i, fun, arg); + } else if (id < HIP_API_ID_NUMBER) { + cb_sync(id); + callbacks_table_.arr[id].act = fun; + callbacks_table_.arr[id].a_arg = arg; + cb_release(id); + } else { + ret = false; + } + return ret; + } + + bool set_callback(uint32_t id, fun_t fun, void* arg) { + std::lock_guard lock(mutex_); + bool ret = true; + if (id == HIP_API_ID_ANY) { + for (unsigned i = 0; i < HIP_API_ID_NUMBER; ++i) set_callback(i, fun, arg); + } else if (id < HIP_API_ID_NUMBER) { + cb_sync(id); + callbacks_table_.arr[id].fun = fun; + callbacks_table_.arr[id].arg = arg; + cb_release(id); + } else { + ret = false; + } + return ret; + } + + inline hip_cb_table_entry_t& entry(const uint32_t& id) { + return callbacks_table_.arr[id]; + } + + inline void sem_sync(const uint32_t& id) { + sem_increment(id); + if (entry(id).sync.load() == true) sync_wait(id); + } + + inline void sem_release(const uint32_t& id) { + sem_decrement(id); + } + + private: + inline void cb_sync(const uint32_t& id) { + entry(id).sync.store(true); + while (entry(id).sem.load() != 0) {} + } + + inline void cb_release(const uint32_t& id) { + entry(id).sync.store(false); + } + + inline void sem_increment(const uint32_t& id) { + const uint32_t prev = entry(id).sem.fetch_add(1); + if (prev == UINT32_MAX) { + std::cerr << "sem overflow id = " << id << std::endl << std::flush; + abort(); + } + } + + inline void sem_decrement(const uint32_t& id) { + const uint32_t prev = entry(id).sem.fetch_sub(1); + if (prev == 0) { + std::cerr << "sem corrupted id = " << id << std::endl << std::flush; + abort(); + } + } + + void sync_wait(const uint32_t& id) { + sem_decrement(id); + while (entry(id).sync.load() == true) {} + sem_increment(id); + } + + mutex_t mutex_; + hip_cb_table_t callbacks_table_; +}; + + +#if USE_PROF_API +#include + +static const uint32_t HIP_DOMAIN_ID = ACTIVITY_DOMAIN_HIP_API; +typedef activity_record_t hip_api_record_t; +typedef activity_rtapi_callback_t hip_api_callback_t; +typedef activity_sync_callback_t hip_act_callback_t; + +// HIP API callbacks spawner object macro +#define HIP_CB_SPAWNER_OBJECT(CB_ID) \ + hip_api_data_t api_data{}; \ + INIT_CB_ARGS_DATA(CB_ID, api_data); \ + api_callbacks_spawner_t __api_tracer(HIP_API_ID_##CB_ID, api_data); + +typedef api_callbacks_table_templ api_callbacks_table_t; +extern api_callbacks_table_t callbacks_table; + +class api_callbacks_spawner_t { + public: + api_callbacks_spawner_t(const hip_api_id_t& cid, hip_api_data_t& api_data) : + cid_(cid), + api_data_(api_data), + record_({}) + { + if (cid_ >= HIP_API_ID_NUMBER) { + fprintf(stderr, "HIP %s bad id %d\n", __FUNCTION__, cid_); + abort(); + } + callbacks_table.sem_sync(cid_); + + act = entry(cid_).act; + a_arg = entry(cid_).a_arg; + fun = entry(cid_).fun; + arg = entry(cid_).arg; + + api_data_.phase = 0; + if (act != NULL) act(cid_, &record_, &api_data_, a_arg); + if (fun != NULL) fun(HIP_DOMAIN_ID, cid_, &api_data_, arg); + } + + ~api_callbacks_spawner_t() { + api_data_.phase = 1; + if (act != NULL) act(cid_, &record_, &api_data_, a_arg); + if (fun != NULL) fun(HIP_DOMAIN_ID, cid_, &api_data_, arg); + + callbacks_table.sem_release(cid_); + } + + private: + inline api_callbacks_table_t::hip_cb_table_entry_t& entry(const uint32_t& id) { + return callbacks_table.entry(id); + } + + const hip_api_id_t cid_; + hip_api_data_t& api_data_; + hip_api_record_t record_; + + hip_act_callback_t act; + void* a_arg; + hip_api_callback_t fun; + void* arg; +}; + +#else + +#define HIP_CB_SPAWNER_OBJECT(x) do {} while(0) + +class api_callbacks_table_t { + public: + typedef void* act_t; + typedef void* fun_t; + bool set_activity(uint32_t id, act_t fun, void* arg) { return true; } + bool set_callback(uint32_t id, fun_t fun, void* arg) { return true; } +}; + +#endif + +#endif // _HIP_PROF_API_H diff --git a/include/hip/hip_prof_str.h b/include/hip/hip_prof_str.h new file mode 100644 index 0000000000..43789104ba --- /dev/null +++ b/include/hip/hip_prof_str.h @@ -0,0 +1,2450 @@ +// automatically generated sources +#ifndef _HIP_PROF_STR_H +#define _HIP_PROF_STR_H +#include +#include + +// HIP API callbacks ID enumaration +enum hip_api_id_t { + HIP_API_ID_hipHostFree = 0, + HIP_API_ID_hipMemcpyToSymbolAsync = 1, + HIP_API_ID_hipMallocPitch = 2, + HIP_API_ID_hipMalloc = 3, + HIP_API_ID_hipDeviceGetName = 4, + HIP_API_ID_hipEventRecord = 5, + HIP_API_ID_hipCtxSynchronize = 6, + HIP_API_ID_hipSetDevice = 7, + HIP_API_ID_hipSetupArgument = 8, + HIP_API_ID_hipMemcpyFromSymbolAsync = 9, + HIP_API_ID_hipMemcpyDtoD = 10, + HIP_API_ID_hipMemcpy2DToArray = 11, + HIP_API_ID_hipCtxGetCacheConfig = 12, + HIP_API_ID_hipStreamWaitEvent = 13, + HIP_API_ID_hipModuleLoad = 14, + HIP_API_ID_hipDevicePrimaryCtxSetFlags = 15, + HIP_API_ID_hipMemcpyAsync = 16, + HIP_API_ID_hipMalloc3DArray = 17, + HIP_API_ID_hipStreamCreate = 18, + HIP_API_ID_hipCtxGetCurrent = 19, + HIP_API_ID_hipDevicePrimaryCtxGetState = 20, + HIP_API_ID_hipEventQuery = 21, + HIP_API_ID_hipEventCreate = 22, + HIP_API_ID_hipMemGetAddressRange = 23, + HIP_API_ID_hipMemcpyFromSymbol = 24, + HIP_API_ID_hipArrayCreate = 25, + HIP_API_ID_hipStreamGetFlags = 26, + HIP_API_ID_hipMallocArray = 27, + HIP_API_ID_hipCtxGetSharedMemConfig = 28, + HIP_API_ID_hipMemPtrGetInfo = 29, + HIP_API_ID_hipCtxGetFlags = 30, + HIP_API_ID_hipStreamDestroy = 31, + HIP_API_ID_hipMemset3DAsync = 32, + HIP_API_ID_hipMemcpy3D = 33, + HIP_API_ID_hipInit = 34, + HIP_API_ID_hipMemcpyAtoH = 35, + HIP_API_ID_hipMemset2D = 36, + HIP_API_ID_hipMemset2DAsync = 37, + HIP_API_ID_hipDeviceCanAccessPeer = 38, + HIP_API_ID_hipDeviceEnablePeerAccess = 39, + HIP_API_ID_hipModuleUnload = 40, + HIP_API_ID_hipHostUnregister = 41, + HIP_API_ID_hipProfilerStop = 42, + HIP_API_ID_hipLaunchByPtr = 43, + HIP_API_ID_hipStreamSynchronize = 44, + HIP_API_ID_hipFreeHost = 45, + HIP_API_ID_hipRemoveApiCallback = 46, + HIP_API_ID_hipDeviceSetCacheConfig = 47, + HIP_API_ID_hipCtxGetApiVersion = 48, + HIP_API_ID_hipMemcpyHtoD = 49, + HIP_API_ID_hipModuleGetGlobal = 50, + HIP_API_ID_hipMemcpyHtoA = 51, + HIP_API_ID_hipCtxCreate = 52, + HIP_API_ID_hipMemcpy2D = 53, + HIP_API_ID_hipIpcCloseMemHandle = 54, + HIP_API_ID_hipChooseDevice = 55, + HIP_API_ID_hipDeviceSetSharedMemConfig = 56, + HIP_API_ID_hipDeviceComputeCapability = 57, + HIP_API_ID_hipRegisterApiCallback = 58, + HIP_API_ID_hipDeviceGet = 59, + HIP_API_ID_hipProfilerStart = 60, + HIP_API_ID_hipCtxSetCacheConfig = 61, + HIP_API_ID_hipFuncSetCacheConfig = 62, + HIP_API_ID_hipMemcpyPeerAsync = 63, + HIP_API_ID_hipEventElapsedTime = 64, + HIP_API_ID_hipDevicePrimaryCtxReset = 65, + HIP_API_ID_hipEventDestroy = 66, + HIP_API_ID_hipCtxPopCurrent = 67, + HIP_API_ID_hipHostGetFlags = 68, + HIP_API_ID_hipHostMalloc = 69, + HIP_API_ID_hipDriverGetVersion = 70, + HIP_API_ID_hipMemGetInfo = 71, + HIP_API_ID_hipDeviceReset = 72, + HIP_API_ID_hipMemset = 73, + HIP_API_ID_hipMemsetD8 = 74, + HIP_API_ID_hipHostRegister = 75, + HIP_API_ID_hipCtxSetSharedMemConfig = 76, + HIP_API_ID_hipArray3DCreate = 77, + HIP_API_ID_hipIpcOpenMemHandle = 78, + HIP_API_ID_hipGetLastError = 79, + HIP_API_ID_hipCtxDestroy = 80, + HIP_API_ID_hipDeviceGetSharedMemConfig = 81, + HIP_API_ID_hipRegisterActivityCallback = 82, + HIP_API_ID_hipSetDeviceFlags = 83, + HIP_API_ID_hipFree = 84, + HIP_API_ID_hipDeviceGetAttribute = 85, + HIP_API_ID_hipMemcpyDtoH = 86, + HIP_API_ID_hipCtxDisablePeerAccess = 87, + HIP_API_ID_hipDeviceGetByPCIBusId = 88, + HIP_API_ID_hipIpcGetMemHandle = 89, + HIP_API_ID_hipMemcpyHtoDAsync = 90, + HIP_API_ID_hipCtxGetDevice = 91, + HIP_API_ID_hipMemset3D = 92, + HIP_API_ID_hipModuleLoadData = 93, + HIP_API_ID_hipDeviceTotalMem = 94, + HIP_API_ID_hipCtxSetCurrent = 95, + HIP_API_ID_hipMallocHost = 96, + HIP_API_ID_hipDevicePrimaryCtxRetain = 97, + HIP_API_ID_hipDeviceDisablePeerAccess = 98, + HIP_API_ID_hipStreamCreateWithFlags = 99, + HIP_API_ID_hipMemcpyFromArray = 100, + HIP_API_ID_hipMemcpy2DAsync = 101, + HIP_API_ID_hipFuncGetAttributes = 102, + HIP_API_ID_hipEventCreateWithFlags = 103, + HIP_API_ID_hipStreamQuery = 104, + HIP_API_ID_hipDeviceGetPCIBusId = 105, + HIP_API_ID_hipMemcpy = 106, + HIP_API_ID_hipPeekAtLastError = 107, + HIP_API_ID_hipHostAlloc = 108, + HIP_API_ID_hipStreamAddCallback = 109, + HIP_API_ID_hipMemcpyToArray = 110, + HIP_API_ID_hipDeviceSynchronize = 111, + HIP_API_ID_hipDeviceGetCacheConfig = 112, + HIP_API_ID_hipMalloc3D = 113, + HIP_API_ID_hipPointerGetAttributes = 114, + HIP_API_ID_hipMemsetAsync = 115, + HIP_API_ID_hipMemcpyToSymbol = 116, + HIP_API_ID_hipCtxPushCurrent = 117, + HIP_API_ID_hipMemcpyPeer = 118, + HIP_API_ID_hipEventSynchronize = 119, + HIP_API_ID_hipMemcpyDtoDAsync = 120, + HIP_API_ID_hipCtxEnablePeerAccess = 121, + HIP_API_ID_hipMemcpyDtoHAsync = 122, + HIP_API_ID_hipModuleLaunchKernel = 123, + HIP_API_ID_hipModuleGetTexRef = 124, + HIP_API_ID_hipRemoveActivityCallback = 125, + HIP_API_ID_hipDeviceGetLimit = 126, + HIP_API_ID_hipModuleLoadDataEx = 127, + HIP_API_ID_hipRuntimeGetVersion = 128, + HIP_API_ID_hipGetDeviceProperties = 129, + HIP_API_ID_hipFreeArray = 130, + HIP_API_ID_hipDevicePrimaryCtxRelease = 131, + HIP_API_ID_hipHostGetDevicePointer = 132, + HIP_API_ID_hipMemcpyParam2D = 133, + HIP_API_ID_hipConfigureCall = 134, + HIP_API_ID_hipModuleGetFunction = 135, + HIP_API_ID_hipGetDevice = 136, + HIP_API_ID_hipGetDeviceCount = 137, + HIP_API_ID_NUMBER = 138, + HIP_API_ID_ANY = 139, +}; + +// Return HIP API string +static const char* hip_api_name(const uint32_t& id) { + switch(id) { + case HIP_API_ID_hipHostFree: return "hipHostFree"; + case HIP_API_ID_hipMemcpyToSymbolAsync: return "hipMemcpyToSymbolAsync"; + case HIP_API_ID_hipMallocPitch: return "hipMallocPitch"; + case HIP_API_ID_hipMalloc: return "hipMalloc"; + case HIP_API_ID_hipDeviceGetName: return "hipDeviceGetName"; + case HIP_API_ID_hipEventRecord: return "hipEventRecord"; + case HIP_API_ID_hipCtxSynchronize: return "hipCtxSynchronize"; + case HIP_API_ID_hipSetDevice: return "hipSetDevice"; + case HIP_API_ID_hipSetupArgument: return "hipSetupArgument"; + case HIP_API_ID_hipMemcpyFromSymbolAsync: return "hipMemcpyFromSymbolAsync"; + case HIP_API_ID_hipMemcpyDtoD: return "hipMemcpyDtoD"; + case HIP_API_ID_hipMemcpy2DToArray: return "hipMemcpy2DToArray"; + case HIP_API_ID_hipCtxGetCacheConfig: return "hipCtxGetCacheConfig"; + case HIP_API_ID_hipStreamWaitEvent: return "hipStreamWaitEvent"; + case HIP_API_ID_hipModuleLoad: return "hipModuleLoad"; + case HIP_API_ID_hipDevicePrimaryCtxSetFlags: return "hipDevicePrimaryCtxSetFlags"; + case HIP_API_ID_hipMemcpyAsync: return "hipMemcpyAsync"; + case HIP_API_ID_hipMalloc3DArray: return "hipMalloc3DArray"; + case HIP_API_ID_hipStreamCreate: return "hipStreamCreate"; + case HIP_API_ID_hipCtxGetCurrent: return "hipCtxGetCurrent"; + case HIP_API_ID_hipDevicePrimaryCtxGetState: return "hipDevicePrimaryCtxGetState"; + case HIP_API_ID_hipEventQuery: return "hipEventQuery"; + case HIP_API_ID_hipEventCreate: return "hipEventCreate"; + case HIP_API_ID_hipMemGetAddressRange: return "hipMemGetAddressRange"; + case HIP_API_ID_hipMemcpyFromSymbol: return "hipMemcpyFromSymbol"; + case HIP_API_ID_hipArrayCreate: return "hipArrayCreate"; + case HIP_API_ID_hipStreamGetFlags: return "hipStreamGetFlags"; + case HIP_API_ID_hipMallocArray: return "hipMallocArray"; + case HIP_API_ID_hipCtxGetSharedMemConfig: return "hipCtxGetSharedMemConfig"; + case HIP_API_ID_hipMemPtrGetInfo: return "hipMemPtrGetInfo"; + case HIP_API_ID_hipCtxGetFlags: return "hipCtxGetFlags"; + case HIP_API_ID_hipStreamDestroy: return "hipStreamDestroy"; + case HIP_API_ID_hipMemset3DAsync: return "hipMemset3DAsync"; + case HIP_API_ID_hipMemcpy3D: return "hipMemcpy3D"; + case HIP_API_ID_hipInit: return "hipInit"; + case HIP_API_ID_hipMemcpyAtoH: return "hipMemcpyAtoH"; + case HIP_API_ID_hipMemset2D: return "hipMemset2D"; + case HIP_API_ID_hipMemset2DAsync: return "hipMemset2DAsync"; + case HIP_API_ID_hipDeviceCanAccessPeer: return "hipDeviceCanAccessPeer"; + case HIP_API_ID_hipDeviceEnablePeerAccess: return "hipDeviceEnablePeerAccess"; + case HIP_API_ID_hipModuleUnload: return "hipModuleUnload"; + case HIP_API_ID_hipHostUnregister: return "hipHostUnregister"; + case HIP_API_ID_hipProfilerStop: return "hipProfilerStop"; + case HIP_API_ID_hipLaunchByPtr: return "hipLaunchByPtr"; + case HIP_API_ID_hipStreamSynchronize: return "hipStreamSynchronize"; + case HIP_API_ID_hipFreeHost: return "hipFreeHost"; + case HIP_API_ID_hipRemoveApiCallback: return "hipRemoveApiCallback"; + case HIP_API_ID_hipDeviceSetCacheConfig: return "hipDeviceSetCacheConfig"; + case HIP_API_ID_hipCtxGetApiVersion: return "hipCtxGetApiVersion"; + case HIP_API_ID_hipMemcpyHtoD: return "hipMemcpyHtoD"; + case HIP_API_ID_hipModuleGetGlobal: return "hipModuleGetGlobal"; + case HIP_API_ID_hipMemcpyHtoA: return "hipMemcpyHtoA"; + case HIP_API_ID_hipCtxCreate: return "hipCtxCreate"; + case HIP_API_ID_hipMemcpy2D: return "hipMemcpy2D"; + case HIP_API_ID_hipIpcCloseMemHandle: return "hipIpcCloseMemHandle"; + case HIP_API_ID_hipChooseDevice: return "hipChooseDevice"; + case HIP_API_ID_hipDeviceSetSharedMemConfig: return "hipDeviceSetSharedMemConfig"; + case HIP_API_ID_hipDeviceComputeCapability: return "hipDeviceComputeCapability"; + case HIP_API_ID_hipRegisterApiCallback: return "hipRegisterApiCallback"; + case HIP_API_ID_hipDeviceGet: return "hipDeviceGet"; + case HIP_API_ID_hipProfilerStart: return "hipProfilerStart"; + case HIP_API_ID_hipCtxSetCacheConfig: return "hipCtxSetCacheConfig"; + case HIP_API_ID_hipFuncSetCacheConfig: return "hipFuncSetCacheConfig"; + case HIP_API_ID_hipMemcpyPeerAsync: return "hipMemcpyPeerAsync"; + case HIP_API_ID_hipEventElapsedTime: return "hipEventElapsedTime"; + case HIP_API_ID_hipDevicePrimaryCtxReset: return "hipDevicePrimaryCtxReset"; + case HIP_API_ID_hipEventDestroy: return "hipEventDestroy"; + case HIP_API_ID_hipCtxPopCurrent: return "hipCtxPopCurrent"; + case HIP_API_ID_hipHostGetFlags: return "hipHostGetFlags"; + case HIP_API_ID_hipHostMalloc: return "hipHostMalloc"; + case HIP_API_ID_hipDriverGetVersion: return "hipDriverGetVersion"; + case HIP_API_ID_hipMemGetInfo: return "hipMemGetInfo"; + case HIP_API_ID_hipDeviceReset: return "hipDeviceReset"; + case HIP_API_ID_hipMemset: return "hipMemset"; + case HIP_API_ID_hipMemsetD8: return "hipMemsetD8"; + case HIP_API_ID_hipHostRegister: return "hipHostRegister"; + case HIP_API_ID_hipCtxSetSharedMemConfig: return "hipCtxSetSharedMemConfig"; + case HIP_API_ID_hipArray3DCreate: return "hipArray3DCreate"; + case HIP_API_ID_hipIpcOpenMemHandle: return "hipIpcOpenMemHandle"; + case HIP_API_ID_hipGetLastError: return "hipGetLastError"; + case HIP_API_ID_hipCtxDestroy: return "hipCtxDestroy"; + case HIP_API_ID_hipDeviceGetSharedMemConfig: return "hipDeviceGetSharedMemConfig"; + case HIP_API_ID_hipRegisterActivityCallback: return "hipRegisterActivityCallback"; + case HIP_API_ID_hipSetDeviceFlags: return "hipSetDeviceFlags"; + case HIP_API_ID_hipFree: return "hipFree"; + case HIP_API_ID_hipDeviceGetAttribute: return "hipDeviceGetAttribute"; + case HIP_API_ID_hipMemcpyDtoH: return "hipMemcpyDtoH"; + case HIP_API_ID_hipCtxDisablePeerAccess: return "hipCtxDisablePeerAccess"; + case HIP_API_ID_hipDeviceGetByPCIBusId: return "hipDeviceGetByPCIBusId"; + case HIP_API_ID_hipIpcGetMemHandle: return "hipIpcGetMemHandle"; + case HIP_API_ID_hipMemcpyHtoDAsync: return "hipMemcpyHtoDAsync"; + case HIP_API_ID_hipCtxGetDevice: return "hipCtxGetDevice"; + case HIP_API_ID_hipMemset3D: return "hipMemset3D"; + case HIP_API_ID_hipModuleLoadData: return "hipModuleLoadData"; + case HIP_API_ID_hipDeviceTotalMem: return "hipDeviceTotalMem"; + case HIP_API_ID_hipCtxSetCurrent: return "hipCtxSetCurrent"; + case HIP_API_ID_hipMallocHost: return "hipMallocHost"; + case HIP_API_ID_hipDevicePrimaryCtxRetain: return "hipDevicePrimaryCtxRetain"; + case HIP_API_ID_hipDeviceDisablePeerAccess: return "hipDeviceDisablePeerAccess"; + case HIP_API_ID_hipStreamCreateWithFlags: return "hipStreamCreateWithFlags"; + case HIP_API_ID_hipMemcpyFromArray: return "hipMemcpyFromArray"; + case HIP_API_ID_hipMemcpy2DAsync: return "hipMemcpy2DAsync"; + case HIP_API_ID_hipFuncGetAttributes: return "hipFuncGetAttributes"; + case HIP_API_ID_hipEventCreateWithFlags: return "hipEventCreateWithFlags"; + case HIP_API_ID_hipStreamQuery: return "hipStreamQuery"; + case HIP_API_ID_hipDeviceGetPCIBusId: return "hipDeviceGetPCIBusId"; + case HIP_API_ID_hipMemcpy: return "hipMemcpy"; + case HIP_API_ID_hipPeekAtLastError: return "hipPeekAtLastError"; + case HIP_API_ID_hipHostAlloc: return "hipHostAlloc"; + case HIP_API_ID_hipStreamAddCallback: return "hipStreamAddCallback"; + case HIP_API_ID_hipMemcpyToArray: return "hipMemcpyToArray"; + case HIP_API_ID_hipDeviceSynchronize: return "hipDeviceSynchronize"; + case HIP_API_ID_hipDeviceGetCacheConfig: return "hipDeviceGetCacheConfig"; + case HIP_API_ID_hipMalloc3D: return "hipMalloc3D"; + case HIP_API_ID_hipPointerGetAttributes: return "hipPointerGetAttributes"; + case HIP_API_ID_hipMemsetAsync: return "hipMemsetAsync"; + case HIP_API_ID_hipMemcpyToSymbol: return "hipMemcpyToSymbol"; + case HIP_API_ID_hipCtxPushCurrent: return "hipCtxPushCurrent"; + case HIP_API_ID_hipMemcpyPeer: return "hipMemcpyPeer"; + case HIP_API_ID_hipEventSynchronize: return "hipEventSynchronize"; + case HIP_API_ID_hipMemcpyDtoDAsync: return "hipMemcpyDtoDAsync"; + case HIP_API_ID_hipCtxEnablePeerAccess: return "hipCtxEnablePeerAccess"; + case HIP_API_ID_hipMemcpyDtoHAsync: return "hipMemcpyDtoHAsync"; + case HIP_API_ID_hipModuleLaunchKernel: return "hipModuleLaunchKernel"; + case HIP_API_ID_hipModuleGetTexRef: return "hipModuleGetTexRef"; + case HIP_API_ID_hipRemoveActivityCallback: return "hipRemoveActivityCallback"; + case HIP_API_ID_hipDeviceGetLimit: return "hipDeviceGetLimit"; + case HIP_API_ID_hipModuleLoadDataEx: return "hipModuleLoadDataEx"; + case HIP_API_ID_hipRuntimeGetVersion: return "hipRuntimeGetVersion"; + case HIP_API_ID_hipGetDeviceProperties: return "hipGetDeviceProperties"; + case HIP_API_ID_hipFreeArray: return "hipFreeArray"; + case HIP_API_ID_hipDevicePrimaryCtxRelease: return "hipDevicePrimaryCtxRelease"; + case HIP_API_ID_hipHostGetDevicePointer: return "hipHostGetDevicePointer"; + case HIP_API_ID_hipMemcpyParam2D: return "hipMemcpyParam2D"; + case HIP_API_ID_hipConfigureCall: return "hipConfigureCall"; + case HIP_API_ID_hipModuleGetFunction: return "hipModuleGetFunction"; + case HIP_API_ID_hipGetDevice: return "hipGetDevice"; + case HIP_API_ID_hipGetDeviceCount: return "hipGetDeviceCount"; + }; + return "unknown"; +}; + +// HIP API callbacks data structure +struct hip_cb_data_t { + uint64_t correlation_id; + uint32_t phase; + union { + struct { + void* ptr; + } hipHostFree; + struct { + const void* symbolName; + const void* src; + size_t sizeBytes; + size_t offset; + hipMemcpyKind kind; + hipStream_t stream; + } hipMemcpyToSymbolAsync; + struct { + void** ptr; + size_t* pitch; + size_t width; + size_t height; + } hipMallocPitch; + struct { + void** ptr; + size_t size; + } hipMalloc; + struct { + char* name; + int len; + hipDevice_t device; + } hipDeviceGetName; + struct { + hipEvent_t event; + hipStream_t stream; + } hipEventRecord; + struct { + int deviceId; + } hipSetDevice; + struct { + const void* arg; + size_t size; + size_t offset; + } hipSetupArgument; + struct { + void* dst; + const void* symbolName; + size_t sizeBytes; + size_t offset; + hipMemcpyKind kind; + hipStream_t stream; + } hipMemcpyFromSymbolAsync; + struct { + hipDeviceptr_t dst; + hipDeviceptr_t src; + size_t sizeBytes; + } hipMemcpyDtoD; + struct { + hipArray* dst; + size_t wOffset; + size_t hOffset; + const void* src; + size_t spitch; + size_t width; + size_t height; + hipMemcpyKind kind; + } hipMemcpy2DToArray; + struct { + hipFuncCache_t* cacheConfig; + } hipCtxGetCacheConfig; + struct { + hipStream_t stream; + hipEvent_t event; + unsigned int flags; + } hipStreamWaitEvent; + struct { + hipModule_t* module; + const char* fname; + } hipModuleLoad; + struct { + hipDevice_t dev; + unsigned int flags; + } hipDevicePrimaryCtxSetFlags; + struct { + void* dst; + const void* src; + size_t sizeBytes; + hipMemcpyKind kind; + hipStream_t stream; + } hipMemcpyAsync; + struct { + hipArray** array; + const hipChannelFormatDesc* desc; + hipExtent extent; + unsigned int flags; + } hipMalloc3DArray; + struct { + hipStream_t* stream; + } hipStreamCreate; + struct { + hipCtx_t* ctx; + } hipCtxGetCurrent; + struct { + hipDevice_t dev; + unsigned int* flags; + int* active; + } hipDevicePrimaryCtxGetState; + struct { + hipEvent_t event; + } hipEventQuery; + struct { + hipEvent_t* event; + } hipEventCreate; + struct { + hipDeviceptr_t* pbase; + size_t* psize; + hipDeviceptr_t dptr; + } hipMemGetAddressRange; + struct { + void* dst; + const void* symbolName; + size_t sizeBytes; + size_t offset; + hipMemcpyKind kind; + } hipMemcpyFromSymbol; + struct { + hipArray** pHandle; + const HIP_ARRAY_DESCRIPTOR* pAllocateArray; + } hipArrayCreate; + struct { + hipStream_t stream; + unsigned int* flags; + } hipStreamGetFlags; + struct { + hipArray** array; + const hipChannelFormatDesc* desc; + size_t width; + size_t height; + unsigned int flags; + } hipMallocArray; + struct { + hipSharedMemConfig* pConfig; + } hipCtxGetSharedMemConfig; + struct { + void* ptr; + size_t* size; + } hipMemPtrGetInfo; + struct { + unsigned int* flags; + } hipCtxGetFlags; + struct { + hipStream_t stream; + } hipStreamDestroy; + struct { + hipPitchedPtr pitchedDevPtr; + int value; + hipExtent extent; + hipStream_t stream; + } hipMemset3DAsync; + struct { + const hipMemcpy3DParms* p; + } hipMemcpy3D; + struct { + unsigned int flags; + } hipInit; + struct { + void* dst; + hipArray* srcArray; + size_t srcOffset; + size_t count; + } hipMemcpyAtoH; + struct { + void* dst; + size_t pitch; + int value; + size_t width; + size_t height; + } hipMemset2D; + struct { + void* dst; + size_t pitch; + int value; + size_t width; + size_t height; + hipStream_t stream; + } hipMemset2DAsync; + struct { + int* canAccessPeer; + int deviceId; + int peerDeviceId; + } hipDeviceCanAccessPeer; + struct { + int peerDeviceId; + unsigned int flags; + } hipDeviceEnablePeerAccess; + struct { + hipModule_t module; + } hipModuleUnload; + struct { + void* hostPtr; + } hipHostUnregister; + struct { + const void* func; + } hipLaunchByPtr; + struct { + hipStream_t stream; + } hipStreamSynchronize; + struct { + void* ptr; + } hipFreeHost; + struct { + uint32_t id; + } hipRemoveApiCallback; + struct { + hipFuncCache_t cacheConfig; + } hipDeviceSetCacheConfig; + struct { + hipCtx_t ctx; + int* apiVersion; + } hipCtxGetApiVersion; + struct { + hipDeviceptr_t dst; + void* src; + size_t sizeBytes; + } hipMemcpyHtoD; + struct { + hipDeviceptr_t* dptr; + size_t* bytes; + hipModule_t hmod; + const char* name; + } hipModuleGetGlobal; + struct { + hipArray* dstArray; + size_t dstOffset; + const void* srcHost; + size_t count; + } hipMemcpyHtoA; + struct { + hipCtx_t* ctx; + unsigned int flags; + hipDevice_t device; + } hipCtxCreate; + struct { + void* dst; + size_t dpitch; + const void* src; + size_t spitch; + size_t width; + size_t height; + hipMemcpyKind kind; + } hipMemcpy2D; + struct { + void* devPtr; + } hipIpcCloseMemHandle; + struct { + int* device; + const hipDeviceProp_t* prop; + } hipChooseDevice; + struct { + hipSharedMemConfig config; + } hipDeviceSetSharedMemConfig; + struct { + int* major; + int* minor; + hipDevice_t device; + } hipDeviceComputeCapability; + struct { + uint32_t id; + void* fun; + void* arg; + } hipRegisterApiCallback; + struct { + hipDevice_t* device; + int ordinal; + } hipDeviceGet; + struct { + hipFuncCache_t cacheConfig; + } hipCtxSetCacheConfig; + struct { + const void* func; + hipFuncCache_t config; + } hipFuncSetCacheConfig; + struct { + void* dst; + int dstDeviceId; + const void* src; + int srcDevice; + size_t sizeBytes; + hipStream_t stream; + } hipMemcpyPeerAsync; + struct { + float* ms; + hipEvent_t start; + hipEvent_t stop; + } hipEventElapsedTime; + struct { + hipDevice_t dev; + } hipDevicePrimaryCtxReset; + struct { + hipEvent_t event; + } hipEventDestroy; + struct { + hipCtx_t* ctx; + } hipCtxPopCurrent; + struct { + unsigned int* flagsPtr; + void* hostPtr; + } hipHostGetFlags; + struct { + void** ptr; + size_t size; + unsigned int flags; + } hipHostMalloc; + struct { + int* driverVersion; + } hipDriverGetVersion; + struct { + size_t* free; + size_t* total; + } hipMemGetInfo; + struct { + void* dst; + int value; + size_t sizeBytes; + } hipMemset; + struct { + hipDeviceptr_t dest; + unsigned char value; + size_t sizeBytes; + } hipMemsetD8; + struct { + void* hostPtr; + size_t sizeBytes; + unsigned int flags; + } hipHostRegister; + struct { + hipSharedMemConfig config; + } hipCtxSetSharedMemConfig; + struct { + hipArray** array; + const HIP_ARRAY_DESCRIPTOR* pAllocateArray; + } hipArray3DCreate; + struct { + void** devPtr; + hipIpcMemHandle_t handle; + unsigned int flags; + } hipIpcOpenMemHandle; + struct { + hipCtx_t ctx; + } hipCtxDestroy; + struct { + hipSharedMemConfig* pConfig; + } hipDeviceGetSharedMemConfig; + struct { + uint32_t id; + void* fun; + void* arg; + } hipRegisterActivityCallback; + struct { + unsigned flags; + } hipSetDeviceFlags; + struct { + void* ptr; + } hipFree; + struct { + int* pi; + hipDeviceAttribute_t attr; + int deviceId; + } hipDeviceGetAttribute; + struct { + void* dst; + hipDeviceptr_t src; + size_t sizeBytes; + } hipMemcpyDtoH; + struct { + hipCtx_t peerCtx; + } hipCtxDisablePeerAccess; + struct { + int* device; + const char* pciBusId; + } hipDeviceGetByPCIBusId; + struct { + hipIpcMemHandle_t* handle; + void* devPtr; + } hipIpcGetMemHandle; + struct { + hipDeviceptr_t dst; + void* src; + size_t sizeBytes; + hipStream_t stream; + } hipMemcpyHtoDAsync; + struct { + hipDevice_t* device; + } hipCtxGetDevice; + struct { + hipPitchedPtr pitchedDevPtr; + int value; + hipExtent extent; + } hipMemset3D; + struct { + hipModule_t* module; + const void* image; + } hipModuleLoadData; + struct { + size_t* bytes; + hipDevice_t device; + } hipDeviceTotalMem; + struct { + hipCtx_t ctx; + } hipCtxSetCurrent; + struct { + void** ptr; + size_t size; + } hipMallocHost; + struct { + hipCtx_t* pctx; + hipDevice_t dev; + } hipDevicePrimaryCtxRetain; + struct { + int peerDeviceId; + } hipDeviceDisablePeerAccess; + struct { + hipStream_t* stream; + unsigned int flags; + } hipStreamCreateWithFlags; + struct { + void* dst; + hipArray_const_t srcArray; + size_t wOffset; + size_t hOffset; + size_t count; + hipMemcpyKind kind; + } hipMemcpyFromArray; + struct { + void* dst; + size_t dpitch; + const void* src; + size_t spitch; + size_t width; + size_t height; + hipMemcpyKind kind; + hipStream_t stream; + } hipMemcpy2DAsync; + struct { + hipFuncAttributes* attr; + const void* func; + } hipFuncGetAttributes; + struct { + hipEvent_t* event; + unsigned flags; + } hipEventCreateWithFlags; + struct { + hipStream_t stream; + } hipStreamQuery; + struct { + char* pciBusId; + int len; + int device; + } hipDeviceGetPCIBusId; + struct { + void* dst; + const void* src; + size_t sizeBytes; + hipMemcpyKind kind; + } hipMemcpy; + struct { + void** ptr; + size_t size; + unsigned int flags; + } hipHostAlloc; + struct { + hipStream_t stream; + hipStreamCallback_t callback; + void* userData; + unsigned int flags; + } hipStreamAddCallback; + struct { + hipArray* dst; + size_t wOffset; + size_t hOffset; + const void* src; + size_t count; + hipMemcpyKind kind; + } hipMemcpyToArray; + struct { + hipFuncCache_t* cacheConfig; + } hipDeviceGetCacheConfig; + struct { + hipPitchedPtr* pitchedDevPtr; + hipExtent extent; + } hipMalloc3D; + struct { + hipPointerAttribute_t* attributes; + const void* ptr; + } hipPointerGetAttributes; + struct { + void* dst; + int value; + size_t sizeBytes; + hipStream_t stream; + } hipMemsetAsync; + struct { + const void* symbolName; + const void* src; + size_t sizeBytes; + size_t offset; + hipMemcpyKind kind; + } hipMemcpyToSymbol; + struct { + hipCtx_t ctx; + } hipCtxPushCurrent; + struct { + void* dst; + int dstDeviceId; + const void* src; + int srcDeviceId; + size_t sizeBytes; + } hipMemcpyPeer; + struct { + hipEvent_t event; + } hipEventSynchronize; + struct { + hipDeviceptr_t dst; + hipDeviceptr_t src; + size_t sizeBytes; + hipStream_t stream; + } hipMemcpyDtoDAsync; + struct { + hipCtx_t peerCtx; + unsigned int flags; + } hipCtxEnablePeerAccess; + struct { + void* dst; + hipDeviceptr_t src; + size_t sizeBytes; + hipStream_t stream; + } hipMemcpyDtoHAsync; + struct { + hipFunction_t f; + unsigned int gridDimX; + unsigned int gridDimY; + unsigned int gridDimZ; + unsigned int blockDimX; + unsigned int blockDimY; + unsigned int blockDimZ; + unsigned int sharedMemBytes; + hipStream_t stream; + void** kernelParams; + void** extra; + } hipModuleLaunchKernel; + struct { + textureReference** texRef; + hipModule_t hmod; + const char* name; + } hipModuleGetTexRef; + struct { + uint32_t id; + } hipRemoveActivityCallback; + struct { + size_t* pValue; + hipLimit_t limit; + } hipDeviceGetLimit; + struct { + hipModule_t* module; + const void* image; + unsigned int numOptions; + hipJitOption* options; + void** optionValues; + } hipModuleLoadDataEx; + struct { + int* runtimeVersion; + } hipRuntimeGetVersion; + struct { + hipDeviceProp_t* prop; + int deviceId; + } hipGetDeviceProperties; + struct { + hipArray* array; + } hipFreeArray; + struct { + hipDevice_t dev; + } hipDevicePrimaryCtxRelease; + struct { + void** devPtr; + void* hstPtr; + unsigned int flags; + } hipHostGetDevicePointer; + struct { + const hip_Memcpy2D* pCopy; + } hipMemcpyParam2D; + struct { + dim3 gridDim; + dim3 blockDim; + size_t sharedMem; + hipStream_t stream; + } hipConfigureCall; + struct { + hipFunction_t* function; + hipModule_t module; + const char* kname; + } hipModuleGetFunction; + struct { + int* deviceId; + } hipGetDevice; + struct { + int* count; + } hipGetDeviceCount; + } args; +}; + +// HIP API callbacks args data filling macros +#define INIT_hipHostFree_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipHostFree.ptr = (void*)ptr; \ +}; +#define INIT_hipMemcpyToSymbolAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyToSymbolAsync.symbolName = (const void*)symbolName; \ + cb_data.args.hipMemcpyToSymbolAsync.src = (const void*)src; \ + cb_data.args.hipMemcpyToSymbolAsync.sizeBytes = (size_t)count; \ + cb_data.args.hipMemcpyToSymbolAsync.offset = (size_t)offset; \ + cb_data.args.hipMemcpyToSymbolAsync.kind = (hipMemcpyKind)kind; \ + cb_data.args.hipMemcpyToSymbolAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipMallocPitch_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMallocPitch.ptr = (void**)ptr; \ + cb_data.args.hipMallocPitch.pitch = (size_t*)pitch; \ + cb_data.args.hipMallocPitch.width = (size_t)width; \ + cb_data.args.hipMallocPitch.height = (size_t)height; \ +}; +#define INIT_hipMalloc_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMalloc.ptr = (void**)ptr; \ + cb_data.args.hipMalloc.size = (size_t)sizeBytes; \ +}; +#define INIT_hipDeviceGetName_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceGetName.name = (char*)name; \ + cb_data.args.hipDeviceGetName.len = (int)len; \ + cb_data.args.hipDeviceGetName.device = (hipDevice_t)device; \ +}; +#define INIT_hipEventRecord_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipEventRecord.event = (hipEvent_t)event; \ + cb_data.args.hipEventRecord.stream = (hipStream_t)stream; \ +}; +#define INIT_hipCtxSynchronize_CB_ARGS_DATA(cb_data) { \ +}; +#define INIT_hipSetDevice_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipSetDevice.deviceId = (int)deviceId; \ +}; +#define INIT_hipSetupArgument_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipSetupArgument.arg = (const void*)arg; \ + cb_data.args.hipSetupArgument.size = (size_t)size; \ + cb_data.args.hipSetupArgument.offset = (size_t)offset; \ +}; +#define INIT_hipMemcpyFromSymbolAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyFromSymbolAsync.dst = (void*)dst; \ + cb_data.args.hipMemcpyFromSymbolAsync.symbolName = (const void*)symbolName; \ + cb_data.args.hipMemcpyFromSymbolAsync.sizeBytes = (size_t)count; \ + cb_data.args.hipMemcpyFromSymbolAsync.offset = (size_t)offset; \ + cb_data.args.hipMemcpyFromSymbolAsync.kind = (hipMemcpyKind)kind; \ + cb_data.args.hipMemcpyFromSymbolAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipMemcpyDtoD_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyDtoD.dst = (hipDeviceptr_t)dst; \ + cb_data.args.hipMemcpyDtoD.src = (hipDeviceptr_t)src; \ + cb_data.args.hipMemcpyDtoD.sizeBytes = (size_t)sizeBytes; \ +}; +#define INIT_hipMemcpy2DToArray_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpy2DToArray.dst = (hipArray*)dst; \ + cb_data.args.hipMemcpy2DToArray.wOffset = (size_t)wOffset; \ + cb_data.args.hipMemcpy2DToArray.hOffset = (size_t)hOffset; \ + cb_data.args.hipMemcpy2DToArray.src = (const void*)src; \ + cb_data.args.hipMemcpy2DToArray.spitch = (size_t)spitch; \ + cb_data.args.hipMemcpy2DToArray.width = (size_t)width; \ + cb_data.args.hipMemcpy2DToArray.height = (size_t)height; \ + cb_data.args.hipMemcpy2DToArray.kind = (hipMemcpyKind)kind; \ +}; +#define INIT_hipCtxGetCacheConfig_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxGetCacheConfig.cacheConfig = (hipFuncCache_t*)cacheConfig; \ +}; +#define INIT_hipStreamWaitEvent_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipStreamWaitEvent.stream = (hipStream_t)stream; \ + cb_data.args.hipStreamWaitEvent.event = (hipEvent_t)event; \ + cb_data.args.hipStreamWaitEvent.flags = (unsigned int)flags; \ +}; +#define INIT_hipModuleLoad_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipModuleLoad.module = (hipModule_t*)module; \ + cb_data.args.hipModuleLoad.fname = (const char*)fname; \ +}; +#define INIT_hipDevicePrimaryCtxSetFlags_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDevicePrimaryCtxSetFlags.dev = (hipDevice_t)dev; \ + cb_data.args.hipDevicePrimaryCtxSetFlags.flags = (unsigned int)flags; \ +}; +#define INIT_hipMemcpyAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyAsync.dst = (void*)dst; \ + cb_data.args.hipMemcpyAsync.src = (const void*)src; \ + cb_data.args.hipMemcpyAsync.sizeBytes = (size_t)sizeBytes; \ + cb_data.args.hipMemcpyAsync.kind = (hipMemcpyKind)kind; \ + cb_data.args.hipMemcpyAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipMalloc3DArray_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMalloc3DArray.array = (hipArray**)array; \ + cb_data.args.hipMalloc3DArray.desc = (const hipChannelFormatDesc*)desc; \ + cb_data.args.hipMalloc3DArray.extent = (hipExtent)extent; \ + cb_data.args.hipMalloc3DArray.flags = (unsigned int)flags; \ +}; +#define INIT_hipStreamCreate_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipStreamCreate.stream = (hipStream_t*)stream; \ +}; +#define INIT_hipCtxGetCurrent_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxGetCurrent.ctx = (hipCtx_t*)ctx; \ +}; +#define INIT_hipDevicePrimaryCtxGetState_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDevicePrimaryCtxGetState.dev = (hipDevice_t)dev; \ + cb_data.args.hipDevicePrimaryCtxGetState.flags = (unsigned int*)flags; \ + cb_data.args.hipDevicePrimaryCtxGetState.active = (int*)active; \ +}; +#define INIT_hipEventQuery_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipEventQuery.event = (hipEvent_t)event; \ +}; +#define INIT_hipEventCreate_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipEventCreate.event = (hipEvent_t*)event; \ +}; +#define INIT_hipMemGetAddressRange_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemGetAddressRange.pbase = (hipDeviceptr_t*)pbase; \ + cb_data.args.hipMemGetAddressRange.psize = (size_t*)psize; \ + cb_data.args.hipMemGetAddressRange.dptr = (hipDeviceptr_t)dptr; \ +}; +#define INIT_hipMemcpyFromSymbol_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyFromSymbol.dst = (void*)dst; \ + cb_data.args.hipMemcpyFromSymbol.symbolName = (const void*)symbolName; \ + cb_data.args.hipMemcpyFromSymbol.sizeBytes = (size_t)count; \ + cb_data.args.hipMemcpyFromSymbol.offset = (size_t)offset; \ + cb_data.args.hipMemcpyFromSymbol.kind = (hipMemcpyKind)kind; \ +}; +#define INIT_hipArrayCreate_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipArrayCreate.pHandle = (hipArray**)array; \ + cb_data.args.hipArrayCreate.pAllocateArray = (const HIP_ARRAY_DESCRIPTOR*)pAllocateArray; \ +}; +#define INIT_hipStreamGetFlags_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipStreamGetFlags.stream = (hipStream_t)stream; \ + cb_data.args.hipStreamGetFlags.flags = (unsigned int*)flags; \ +}; +#define INIT_hipMallocArray_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMallocArray.array = (hipArray**)array; \ + cb_data.args.hipMallocArray.desc = (const hipChannelFormatDesc*)desc; \ + cb_data.args.hipMallocArray.width = (size_t)width; \ + cb_data.args.hipMallocArray.height = (size_t)height; \ + cb_data.args.hipMallocArray.flags = (unsigned int)flags; \ +}; +#define INIT_hipCtxGetSharedMemConfig_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxGetSharedMemConfig.pConfig = (hipSharedMemConfig*)pConfig; \ +}; +#define INIT_hipMemPtrGetInfo_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemPtrGetInfo.ptr = (void*)ptr; \ + cb_data.args.hipMemPtrGetInfo.size = (size_t*)size; \ +}; +#define INIT_hipCtxGetFlags_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxGetFlags.flags = (unsigned int*)flags; \ +}; +#define INIT_hipStreamDestroy_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipStreamDestroy.stream = (hipStream_t)stream; \ +}; +#define INIT_hipMemset3DAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemset3DAsync.pitchedDevPtr = (hipPitchedPtr)pitchedDevPtr; \ + cb_data.args.hipMemset3DAsync.value = (int)value; \ + cb_data.args.hipMemset3DAsync.extent = (hipExtent)extent; \ + cb_data.args.hipMemset3DAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipMemcpy3D_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpy3D.p = (const hipMemcpy3DParms*)p; \ +}; +#define INIT_hipInit_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipInit.flags = (unsigned int)flags; \ +}; +#define INIT_hipMemcpyAtoH_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyAtoH.dst = (void*)dst; \ + cb_data.args.hipMemcpyAtoH.srcArray = (hipArray*)srcArray; \ + cb_data.args.hipMemcpyAtoH.srcOffset = (size_t)srcOffset; \ + cb_data.args.hipMemcpyAtoH.count = (size_t)count; \ +}; +#define INIT_hipMemset2D_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemset2D.dst = (void*)dst; \ + cb_data.args.hipMemset2D.pitch = (size_t)pitch; \ + cb_data.args.hipMemset2D.value = (int)value; \ + cb_data.args.hipMemset2D.width = (size_t)width; \ + cb_data.args.hipMemset2D.height = (size_t)height; \ +}; +#define INIT_hipMemset2DAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemset2DAsync.dst = (void*)dst; \ + cb_data.args.hipMemset2DAsync.pitch = (size_t)pitch; \ + cb_data.args.hipMemset2DAsync.value = (int)value; \ + cb_data.args.hipMemset2DAsync.width = (size_t)width; \ + cb_data.args.hipMemset2DAsync.height = (size_t)height; \ + cb_data.args.hipMemset2DAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipDeviceCanAccessPeer_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceCanAccessPeer.canAccessPeer = (int*)canAccessPeer; \ + cb_data.args.hipDeviceCanAccessPeer.deviceId = (int)deviceId; \ + cb_data.args.hipDeviceCanAccessPeer.peerDeviceId = (int)peerDeviceId; \ +}; +#define INIT_hipDeviceEnablePeerAccess_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceEnablePeerAccess.peerDeviceId = (int)peerDeviceId; \ + cb_data.args.hipDeviceEnablePeerAccess.flags = (unsigned int)flags; \ +}; +#define INIT_hipModuleUnload_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipModuleUnload.module = (hipModule_t)hmod; \ +}; +#define INIT_hipHostUnregister_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipHostUnregister.hostPtr = (void*)hostPtr; \ +}; +#define INIT_hipProfilerStop_CB_ARGS_DATA(cb_data) { \ +}; +#define INIT_hipLaunchByPtr_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipLaunchByPtr.func = (const void*)hostFunction; \ +}; +#define INIT_hipStreamSynchronize_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipStreamSynchronize.stream = (hipStream_t)stream; \ +}; +#define INIT_hipFreeHost_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipFreeHost.ptr = (void*)ptr; \ +}; +#define INIT_hipRemoveApiCallback_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipRemoveApiCallback.id = (uint32_t)id; \ +}; +#define INIT_hipDeviceSetCacheConfig_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceSetCacheConfig.cacheConfig = (hipFuncCache_t)cacheConfig; \ +}; +#define INIT_hipCtxGetApiVersion_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxGetApiVersion.ctx = (hipCtx_t)ctx; \ + cb_data.args.hipCtxGetApiVersion.apiVersion = (int*)apiVersion; \ +}; +#define INIT_hipMemcpyHtoD_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyHtoD.dst = (hipDeviceptr_t)dst; \ + cb_data.args.hipMemcpyHtoD.src = (void*)src; \ + cb_data.args.hipMemcpyHtoD.sizeBytes = (size_t)sizeBytes; \ +}; +#define INIT_hipModuleGetGlobal_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipModuleGetGlobal.dptr = (hipDeviceptr_t*)dptr; \ + cb_data.args.hipModuleGetGlobal.bytes = (size_t*)bytes; \ + cb_data.args.hipModuleGetGlobal.hmod = (hipModule_t)hmod; \ + cb_data.args.hipModuleGetGlobal.name = (const char*)name; \ +}; +#define INIT_hipMemcpyHtoA_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyHtoA.dstArray = (hipArray*)dstArray; \ + cb_data.args.hipMemcpyHtoA.dstOffset = (size_t)dstOffset; \ + cb_data.args.hipMemcpyHtoA.srcHost = (const void*)srcHost; \ + cb_data.args.hipMemcpyHtoA.count = (size_t)count; \ +}; +#define INIT_hipCtxCreate_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxCreate.ctx = (hipCtx_t*)ctx; \ + cb_data.args.hipCtxCreate.flags = (unsigned int)flags; \ + cb_data.args.hipCtxCreate.device = (hipDevice_t)device; \ +}; +#define INIT_hipMemcpy2D_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpy2D.dst = (void*)dst; \ + cb_data.args.hipMemcpy2D.dpitch = (size_t)dpitch; \ + cb_data.args.hipMemcpy2D.src = (const void*)src; \ + cb_data.args.hipMemcpy2D.spitch = (size_t)spitch; \ + cb_data.args.hipMemcpy2D.width = (size_t)width; \ + cb_data.args.hipMemcpy2D.height = (size_t)height; \ + cb_data.args.hipMemcpy2D.kind = (hipMemcpyKind)kind; \ +}; +#define INIT_hipIpcCloseMemHandle_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipIpcCloseMemHandle.devPtr = (void*)devPtr; \ +}; +#define INIT_hipChooseDevice_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipChooseDevice.device = (int*)device; \ + cb_data.args.hipChooseDevice.prop = (const hipDeviceProp_t*)prop; \ +}; +#define INIT_hipDeviceSetSharedMemConfig_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceSetSharedMemConfig.config = (hipSharedMemConfig)config; \ +}; +#define INIT_hipDeviceComputeCapability_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceComputeCapability.major = (int*)major; \ + cb_data.args.hipDeviceComputeCapability.minor = (int*)minor; \ + cb_data.args.hipDeviceComputeCapability.device = (hipDevice_t)device; \ +}; +#define INIT_hipRegisterApiCallback_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipRegisterApiCallback.id = (uint32_t)id; \ + cb_data.args.hipRegisterApiCallback.fun = (void*)fun; \ + cb_data.args.hipRegisterApiCallback.arg = (void*)arg; \ +}; +#define INIT_hipDeviceGet_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceGet.device = (hipDevice_t*)device; \ + cb_data.args.hipDeviceGet.ordinal = (int)deviceId; \ +}; +#define INIT_hipProfilerStart_CB_ARGS_DATA(cb_data) { \ +}; +#define INIT_hipCtxSetCacheConfig_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxSetCacheConfig.cacheConfig = (hipFuncCache_t)cacheConfig; \ +}; +#define INIT_hipFuncSetCacheConfig_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipFuncSetCacheConfig.func = (const void*)func; \ + cb_data.args.hipFuncSetCacheConfig.config = (hipFuncCache_t)cacheConfig; \ +}; +#define INIT_hipMemcpyPeerAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyPeerAsync.dst = (void*)dst; \ + cb_data.args.hipMemcpyPeerAsync.dstDeviceId = (int)dstDevice; \ + cb_data.args.hipMemcpyPeerAsync.src = (const void*)src; \ + cb_data.args.hipMemcpyPeerAsync.srcDevice = (int)srcDevice; \ + cb_data.args.hipMemcpyPeerAsync.sizeBytes = (size_t)sizeBytes; \ + cb_data.args.hipMemcpyPeerAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipEventElapsedTime_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipEventElapsedTime.ms = (float*)ms; \ + cb_data.args.hipEventElapsedTime.start = (hipEvent_t)start; \ + cb_data.args.hipEventElapsedTime.stop = (hipEvent_t)stop; \ +}; +#define INIT_hipDevicePrimaryCtxReset_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDevicePrimaryCtxReset.dev = (hipDevice_t)dev; \ +}; +#define INIT_hipEventDestroy_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipEventDestroy.event = (hipEvent_t)event; \ +}; +#define INIT_hipCtxPopCurrent_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxPopCurrent.ctx = (hipCtx_t*)ctx; \ +}; +#define INIT_hipHostGetFlags_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipHostGetFlags.flagsPtr = (unsigned int*)flagsPtr; \ + cb_data.args.hipHostGetFlags.hostPtr = (void*)hostPtr; \ +}; +#define INIT_hipHostMalloc_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipHostMalloc.ptr = (void**)ptr; \ + cb_data.args.hipHostMalloc.size = (size_t)sizeBytes; \ + cb_data.args.hipHostMalloc.flags = (unsigned int)flags; \ +}; +#define INIT_hipDriverGetVersion_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDriverGetVersion.driverVersion = (int*)driverVersion; \ +}; +#define INIT_hipMemGetInfo_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemGetInfo.free = (size_t*)free; \ + cb_data.args.hipMemGetInfo.total = (size_t*)total; \ +}; +#define INIT_hipDeviceReset_CB_ARGS_DATA(cb_data) { \ +}; +#define INIT_hipMemset_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemset.dst = (void*)dst; \ + cb_data.args.hipMemset.value = (int)value; \ + cb_data.args.hipMemset.sizeBytes = (size_t)sizeBytes; \ +}; +#define INIT_hipMemsetD8_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemsetD8.dest = (hipDeviceptr_t)dst; \ + cb_data.args.hipMemsetD8.value = (unsigned char)value; \ + cb_data.args.hipMemsetD8.sizeBytes = (size_t)sizeBytes; \ +}; +#define INIT_hipHostRegister_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipHostRegister.hostPtr = (void*)hostPtr; \ + cb_data.args.hipHostRegister.sizeBytes = (size_t)sizeBytes; \ + cb_data.args.hipHostRegister.flags = (unsigned int)flags; \ +}; +#define INIT_hipCtxSetSharedMemConfig_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxSetSharedMemConfig.config = (hipSharedMemConfig)config; \ +}; +#define INIT_hipArray3DCreate_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipArray3DCreate.array = (hipArray**)array; \ + cb_data.args.hipArray3DCreate.pAllocateArray = (const HIP_ARRAY_DESCRIPTOR*)pAllocateArray; \ +}; +#define INIT_hipIpcOpenMemHandle_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipIpcOpenMemHandle.devPtr = (void**)devPtr; \ + cb_data.args.hipIpcOpenMemHandle.handle = (hipIpcMemHandle_t)handle; \ + cb_data.args.hipIpcOpenMemHandle.flags = (unsigned int)flags; \ +}; +#define INIT_hipGetLastError_CB_ARGS_DATA(cb_data) { \ +}; +#define INIT_hipCtxDestroy_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxDestroy.ctx = (hipCtx_t)ctx; \ +}; +#define INIT_hipDeviceGetSharedMemConfig_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceGetSharedMemConfig.pConfig = (hipSharedMemConfig*)pConfig; \ +}; +#define INIT_hipRegisterActivityCallback_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipRegisterActivityCallback.id = (uint32_t)id; \ + cb_data.args.hipRegisterActivityCallback.fun = (void*)fun; \ + cb_data.args.hipRegisterActivityCallback.arg = (void*)arg; \ +}; +#define INIT_hipSetDeviceFlags_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipSetDeviceFlags.flags = (unsigned)flags; \ +}; +#define INIT_hipFree_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipFree.ptr = (void*)ptr; \ +}; +#define INIT_hipDeviceGetAttribute_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceGetAttribute.pi = (int*)pi; \ + cb_data.args.hipDeviceGetAttribute.attr = (hipDeviceAttribute_t)attr; \ + cb_data.args.hipDeviceGetAttribute.deviceId = (int)device; \ +}; +#define INIT_hipMemcpyDtoH_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyDtoH.dst = (void*)dst; \ + cb_data.args.hipMemcpyDtoH.src = (hipDeviceptr_t)src; \ + cb_data.args.hipMemcpyDtoH.sizeBytes = (size_t)sizeBytes; \ +}; +#define INIT_hipCtxDisablePeerAccess_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxDisablePeerAccess.peerCtx = (hipCtx_t)peerCtx; \ +}; +#define INIT_hipDeviceGetByPCIBusId_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceGetByPCIBusId.device = (int*)device; \ + cb_data.args.hipDeviceGetByPCIBusId.pciBusId = (const char*)pciBusId; \ +}; +#define INIT_hipIpcGetMemHandle_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipIpcGetMemHandle.handle = (hipIpcMemHandle_t*)handle; \ + cb_data.args.hipIpcGetMemHandle.devPtr = (void*)devPtr; \ +}; +#define INIT_hipMemcpyHtoDAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyHtoDAsync.dst = (hipDeviceptr_t)dst; \ + cb_data.args.hipMemcpyHtoDAsync.src = (void*)src; \ + cb_data.args.hipMemcpyHtoDAsync.sizeBytes = (size_t)sizeBytes; \ + cb_data.args.hipMemcpyHtoDAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipCtxGetDevice_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxGetDevice.device = (hipDevice_t*)device; \ +}; +#define INIT_hipMemset3D_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemset3D.pitchedDevPtr = (hipPitchedPtr)pitchedDevPtr; \ + cb_data.args.hipMemset3D.value = (int)value; \ + cb_data.args.hipMemset3D.extent = (hipExtent)extent; \ +}; +#define INIT_hipModuleLoadData_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipModuleLoadData.module = (hipModule_t*)module; \ + cb_data.args.hipModuleLoadData.image = (const void*)image; \ +}; +#define INIT_hipDeviceTotalMem_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceTotalMem.bytes = (size_t*)bytes; \ + cb_data.args.hipDeviceTotalMem.device = (hipDevice_t)device; \ +}; +#define INIT_hipCtxSetCurrent_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxSetCurrent.ctx = (hipCtx_t)ctx; \ +}; +#define INIT_hipMallocHost_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMallocHost.ptr = (void**)ptr; \ + cb_data.args.hipMallocHost.size = (size_t)sizeBytes; \ +}; +#define INIT_hipDevicePrimaryCtxRetain_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDevicePrimaryCtxRetain.pctx = (hipCtx_t*)pctx; \ + cb_data.args.hipDevicePrimaryCtxRetain.dev = (hipDevice_t)dev; \ +}; +#define INIT_hipDeviceDisablePeerAccess_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceDisablePeerAccess.peerDeviceId = (int)peerDeviceId; \ +}; +#define INIT_hipStreamCreateWithFlags_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipStreamCreateWithFlags.stream = (hipStream_t*)stream; \ + cb_data.args.hipStreamCreateWithFlags.flags = (unsigned int)flags; \ +}; +#define INIT_hipMemcpyFromArray_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyFromArray.dst = (void*)dst; \ + cb_data.args.hipMemcpyFromArray.srcArray = (hipArray_const_t)srcArray; \ + cb_data.args.hipMemcpyFromArray.wOffset = (size_t)wOffset; \ + cb_data.args.hipMemcpyFromArray.hOffset = (size_t)hOffset; \ + cb_data.args.hipMemcpyFromArray.count = (size_t)count; \ + cb_data.args.hipMemcpyFromArray.kind = (hipMemcpyKind)kind; \ +}; +#define INIT_hipMemcpy2DAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpy2DAsync.dst = (void*)dst; \ + cb_data.args.hipMemcpy2DAsync.dpitch = (size_t)dpitch; \ + cb_data.args.hipMemcpy2DAsync.src = (const void*)src; \ + cb_data.args.hipMemcpy2DAsync.spitch = (size_t)spitch; \ + cb_data.args.hipMemcpy2DAsync.width = (size_t)width; \ + cb_data.args.hipMemcpy2DAsync.height = (size_t)height; \ + cb_data.args.hipMemcpy2DAsync.kind = (hipMemcpyKind)kind; \ + cb_data.args.hipMemcpy2DAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipFuncGetAttributes_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipFuncGetAttributes.attr = (hipFuncAttributes*)attr; \ + cb_data.args.hipFuncGetAttributes.func = (const void*)func; \ +}; +#define INIT_hipEventCreateWithFlags_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipEventCreateWithFlags.event = (hipEvent_t*)event; \ + cb_data.args.hipEventCreateWithFlags.flags = (unsigned)flags; \ +}; +#define INIT_hipStreamQuery_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipStreamQuery.stream = (hipStream_t)stream; \ +}; +#define INIT_hipDeviceGetPCIBusId_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceGetPCIBusId.pciBusId = (char*)pciBusId; \ + cb_data.args.hipDeviceGetPCIBusId.len = (int)len; \ + cb_data.args.hipDeviceGetPCIBusId.device = (int)device; \ +}; +#define INIT_hipMemcpy_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpy.dst = (void*)dst; \ + cb_data.args.hipMemcpy.src = (const void*)src; \ + cb_data.args.hipMemcpy.sizeBytes = (size_t)sizeBytes; \ + cb_data.args.hipMemcpy.kind = (hipMemcpyKind)kind; \ +}; +#define INIT_hipPeekAtLastError_CB_ARGS_DATA(cb_data) { \ +}; +#define INIT_hipHostAlloc_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipHostAlloc.ptr = (void**)ptr; \ + cb_data.args.hipHostAlloc.size = (size_t)sizeBytes; \ + cb_data.args.hipHostAlloc.flags = (unsigned int)flags; \ +}; +#define INIT_hipStreamAddCallback_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipStreamAddCallback.stream = (hipStream_t)stream; \ + cb_data.args.hipStreamAddCallback.callback = (hipStreamCallback_t)callback; \ + cb_data.args.hipStreamAddCallback.userData = (void*)userData; \ + cb_data.args.hipStreamAddCallback.flags = (unsigned int)flags; \ +}; +#define INIT_hipMemcpyToArray_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyToArray.dst = (hipArray*)dst; \ + cb_data.args.hipMemcpyToArray.wOffset = (size_t)wOffset; \ + cb_data.args.hipMemcpyToArray.hOffset = (size_t)hOffset; \ + cb_data.args.hipMemcpyToArray.src = (const void*)src; \ + cb_data.args.hipMemcpyToArray.count = (size_t)count; \ + cb_data.args.hipMemcpyToArray.kind = (hipMemcpyKind)kind; \ +}; +#define INIT_hipDeviceSynchronize_CB_ARGS_DATA(cb_data) { \ +}; +#define INIT_hipDeviceGetCacheConfig_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceGetCacheConfig.cacheConfig = (hipFuncCache_t*)cacheConfig; \ +}; +#define INIT_hipMalloc3D_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMalloc3D.pitchedDevPtr = (hipPitchedPtr*)pitchedDevPtr; \ + cb_data.args.hipMalloc3D.extent = (hipExtent)extent; \ +}; +#define INIT_hipPointerGetAttributes_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipPointerGetAttributes.attributes = (hipPointerAttribute_t*)attributes; \ + cb_data.args.hipPointerGetAttributes.ptr = (const void*)ptr; \ +}; +#define INIT_hipMemsetAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemsetAsync.dst = (void*)dst; \ + cb_data.args.hipMemsetAsync.value = (int)value; \ + cb_data.args.hipMemsetAsync.sizeBytes = (size_t)sizeBytes; \ + cb_data.args.hipMemsetAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipMemcpyToSymbol_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyToSymbol.symbolName = (const void*)symbolName; \ + cb_data.args.hipMemcpyToSymbol.src = (const void*)src; \ + cb_data.args.hipMemcpyToSymbol.sizeBytes = (size_t)count; \ + cb_data.args.hipMemcpyToSymbol.offset = (size_t)offset; \ + cb_data.args.hipMemcpyToSymbol.kind = (hipMemcpyKind)kind; \ +}; +#define INIT_hipCtxPushCurrent_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxPushCurrent.ctx = (hipCtx_t)ctx; \ +}; +#define INIT_hipMemcpyPeer_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyPeer.dst = (void*)dst; \ + cb_data.args.hipMemcpyPeer.dstDeviceId = (int)dstDevice; \ + cb_data.args.hipMemcpyPeer.src = (const void*)src; \ + cb_data.args.hipMemcpyPeer.srcDeviceId = (int)srcDevice; \ + cb_data.args.hipMemcpyPeer.sizeBytes = (size_t)sizeBytes; \ +}; +#define INIT_hipEventSynchronize_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipEventSynchronize.event = (hipEvent_t)event; \ +}; +#define INIT_hipMemcpyDtoDAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyDtoDAsync.dst = (hipDeviceptr_t)dst; \ + cb_data.args.hipMemcpyDtoDAsync.src = (hipDeviceptr_t)src; \ + cb_data.args.hipMemcpyDtoDAsync.sizeBytes = (size_t)sizeBytes; \ + cb_data.args.hipMemcpyDtoDAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipCtxEnablePeerAccess_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipCtxEnablePeerAccess.peerCtx = (hipCtx_t)peerCtx; \ + cb_data.args.hipCtxEnablePeerAccess.flags = (unsigned int)flags; \ +}; +#define INIT_hipMemcpyDtoHAsync_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyDtoHAsync.dst = (void*)dst; \ + cb_data.args.hipMemcpyDtoHAsync.src = (hipDeviceptr_t)src; \ + cb_data.args.hipMemcpyDtoHAsync.sizeBytes = (size_t)sizeBytes; \ + cb_data.args.hipMemcpyDtoHAsync.stream = (hipStream_t)stream; \ +}; +#define INIT_hipModuleLaunchKernel_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipModuleLaunchKernel.f = (hipFunction_t)f; \ + cb_data.args.hipModuleLaunchKernel.gridDimX = (unsigned int)gridDimX; \ + cb_data.args.hipModuleLaunchKernel.gridDimY = (unsigned int)gridDimY; \ + cb_data.args.hipModuleLaunchKernel.gridDimZ = (unsigned int)gridDimZ; \ + cb_data.args.hipModuleLaunchKernel.blockDimX = (unsigned int)blockDimX; \ + cb_data.args.hipModuleLaunchKernel.blockDimY = (unsigned int)blockDimY; \ + cb_data.args.hipModuleLaunchKernel.blockDimZ = (unsigned int)blockDimZ; \ + cb_data.args.hipModuleLaunchKernel.sharedMemBytes = (unsigned int)sharedMemBytes; \ + cb_data.args.hipModuleLaunchKernel.stream = (hipStream_t)hStream; \ + cb_data.args.hipModuleLaunchKernel.kernelParams = (void**)kernelParams; \ + cb_data.args.hipModuleLaunchKernel.extra = (void**)extra; \ +}; +#define INIT_hipModuleGetTexRef_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipModuleGetTexRef.texRef = (textureReference**)texRef; \ + cb_data.args.hipModuleGetTexRef.hmod = (hipModule_t)hmod; \ + cb_data.args.hipModuleGetTexRef.name = (const char*)name; \ +}; +#define INIT_hipRemoveActivityCallback_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipRemoveActivityCallback.id = (uint32_t)id; \ +}; +#define INIT_hipDeviceGetLimit_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDeviceGetLimit.pValue = (size_t*)pValue; \ + cb_data.args.hipDeviceGetLimit.limit = (hipLimit_t)limit; \ +}; +#define INIT_hipModuleLoadDataEx_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipModuleLoadDataEx.module = (hipModule_t*)module; \ + cb_data.args.hipModuleLoadDataEx.image = (const void*)image; \ + cb_data.args.hipModuleLoadDataEx.numOptions = (unsigned int)numOptions; \ + cb_data.args.hipModuleLoadDataEx.options = (hipJitOption*)options; \ + cb_data.args.hipModuleLoadDataEx.optionValues = (void**)optionValues; \ +}; +#define INIT_hipRuntimeGetVersion_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipRuntimeGetVersion.runtimeVersion = (int*)runtimeVersion; \ +}; +#define INIT_hipGetDeviceProperties_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipGetDeviceProperties.prop = (hipDeviceProp_t*)props; \ + cb_data.args.hipGetDeviceProperties.deviceId = (int)device; \ +}; +#define INIT_hipFreeArray_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipFreeArray.array = (hipArray*)array; \ +}; +#define INIT_hipDevicePrimaryCtxRelease_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipDevicePrimaryCtxRelease.dev = (hipDevice_t)dev; \ +}; +#define INIT_hipHostGetDevicePointer_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipHostGetDevicePointer.devPtr = (void**)devicePointer; \ + cb_data.args.hipHostGetDevicePointer.hstPtr = (void*)hostPointer; \ + cb_data.args.hipHostGetDevicePointer.flags = (unsigned int)flags; \ +}; +#define INIT_hipMemcpyParam2D_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipMemcpyParam2D.pCopy = (const hip_Memcpy2D*)pCopy; \ +}; +#define INIT_hipConfigureCall_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipConfigureCall.gridDim = (dim3)gridDim; \ + cb_data.args.hipConfigureCall.blockDim = (dim3)blockDim; \ + cb_data.args.hipConfigureCall.sharedMem = (size_t)sharedMem; \ + cb_data.args.hipConfigureCall.stream = (hipStream_t)stream; \ +}; +#define INIT_hipModuleGetFunction_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipModuleGetFunction.function = (hipFunction_t*)hfunc; \ + cb_data.args.hipModuleGetFunction.module = (hipModule_t)hmod; \ + cb_data.args.hipModuleGetFunction.kname = (const char*)name; \ +}; +#define INIT_hipGetDevice_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipGetDevice.deviceId = (int*)deviceId; \ +}; +#define INIT_hipGetDeviceCount_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipGetDeviceCount.count = (int*)count; \ +}; +#define INIT_CB_ARGS_DATA(cb_id, cb_data) INIT_##cb_id##_CB_ARGS_DATA(cb_data) + +#if 0 +// HIP API string method, method name and parameters +const char* hipApiString(hip_cb_id_t id, const hip_cb_data_t* data) { + std::ostringstream oss; + switch (id) { + case HIP_API_ID_hipHostFree: + oss << "hipHostFree(" + << " ptr=" << data->args.hipHostFree.ptr + << ")"; + break; + case HIP_API_ID_hipMemcpyToSymbolAsync: + oss << "hipMemcpyToSymbolAsync(" + << " symbolName=" << data->args.hipMemcpyToSymbolAsync.symbolName << "," + << " src=" << data->args.hipMemcpyToSymbolAsync.src << "," + << " sizeBytes=" << data->args.hipMemcpyToSymbolAsync.sizeBytes << "," + << " offset=" << data->args.hipMemcpyToSymbolAsync.offset << "," + << " kind=" << data->args.hipMemcpyToSymbolAsync.kind << "," + << " stream=" << data->args.hipMemcpyToSymbolAsync.stream + << ")"; + break; + case HIP_API_ID_hipMallocPitch: + oss << "hipMallocPitch(" + << " ptr=" << data->args.hipMallocPitch.ptr << "," + << " pitch=" << data->args.hipMallocPitch.pitch << "," + << " width=" << data->args.hipMallocPitch.width << "," + << " height=" << data->args.hipMallocPitch.height + << ")"; + break; + case HIP_API_ID_hipMalloc: + oss << "hipMalloc(" + << " ptr=" << data->args.hipMalloc.ptr << "," + << " size=" << data->args.hipMalloc.size + << ")"; + break; + case HIP_API_ID_hipDeviceGetName: + oss << "hipDeviceGetName(" + << " name=" << data->args.hipDeviceGetName.name << "," + << " len=" << data->args.hipDeviceGetName.len << "," + << " device=" << data->args.hipDeviceGetName.device + << ")"; + break; + case HIP_API_ID_hipEventRecord: + oss << "hipEventRecord(" + << " event=" << data->args.hipEventRecord.event << "," + << " stream=" << data->args.hipEventRecord.stream + << ")"; + break; + case HIP_API_ID_hipCtxSynchronize: + oss << "hipCtxSynchronize(" + << ")"; + break; + case HIP_API_ID_hipSetDevice: + oss << "hipSetDevice(" + << " deviceId=" << data->args.hipSetDevice.deviceId + << ")"; + break; + case HIP_API_ID_hipSetupArgument: + oss << "hipSetupArgument(" + << " arg=" << data->args.hipSetupArgument.arg << "," + << " size=" << data->args.hipSetupArgument.size << "," + << " offset=" << data->args.hipSetupArgument.offset + << ")"; + break; + case HIP_API_ID_hipMemcpyFromSymbolAsync: + oss << "hipMemcpyFromSymbolAsync(" + << " dst=" << data->args.hipMemcpyFromSymbolAsync.dst << "," + << " symbolName=" << data->args.hipMemcpyFromSymbolAsync.symbolName << "," + << " sizeBytes=" << data->args.hipMemcpyFromSymbolAsync.sizeBytes << "," + << " offset=" << data->args.hipMemcpyFromSymbolAsync.offset << "," + << " kind=" << data->args.hipMemcpyFromSymbolAsync.kind << "," + << " stream=" << data->args.hipMemcpyFromSymbolAsync.stream + << ")"; + break; + case HIP_API_ID_hipMemcpyDtoD: + oss << "hipMemcpyDtoD(" + << " dst=" << data->args.hipMemcpyDtoD.dst << "," + << " src=" << data->args.hipMemcpyDtoD.src << "," + << " sizeBytes=" << data->args.hipMemcpyDtoD.sizeBytes + << ")"; + break; + case HIP_API_ID_hipMemcpy2DToArray: + oss << "hipMemcpy2DToArray(" + << " dst=" << data->args.hipMemcpy2DToArray.dst << "," + << " wOffset=" << data->args.hipMemcpy2DToArray.wOffset << "," + << " hOffset=" << data->args.hipMemcpy2DToArray.hOffset << "," + << " src=" << data->args.hipMemcpy2DToArray.src << "," + << " spitch=" << data->args.hipMemcpy2DToArray.spitch << "," + << " width=" << data->args.hipMemcpy2DToArray.width << "," + << " height=" << data->args.hipMemcpy2DToArray.height << "," + << " kind=" << data->args.hipMemcpy2DToArray.kind + << ")"; + break; + case HIP_API_ID_hipCtxGetCacheConfig: + oss << "hipCtxGetCacheConfig(" + << " cacheConfig=" << data->args.hipCtxGetCacheConfig.cacheConfig + << ")"; + break; + case HIP_API_ID_hipStreamWaitEvent: + oss << "hipStreamWaitEvent(" + << " stream=" << data->args.hipStreamWaitEvent.stream << "," + << " event=" << data->args.hipStreamWaitEvent.event << "," + << " flags=" << data->args.hipStreamWaitEvent.flags + << ")"; + break; + case HIP_API_ID_hipModuleLoad: + oss << "hipModuleLoad(" + << " module=" << data->args.hipModuleLoad.module << "," + << " fname=" << data->args.hipModuleLoad.fname + << ")"; + break; + case HIP_API_ID_hipDevicePrimaryCtxSetFlags: + oss << "hipDevicePrimaryCtxSetFlags(" + << " dev=" << data->args.hipDevicePrimaryCtxSetFlags.dev << "," + << " flags=" << data->args.hipDevicePrimaryCtxSetFlags.flags + << ")"; + break; + case HIP_API_ID_hipMemcpyAsync: + oss << "hipMemcpyAsync(" + << " dst=" << data->args.hipMemcpyAsync.dst << "," + << " src=" << data->args.hipMemcpyAsync.src << "," + << " sizeBytes=" << data->args.hipMemcpyAsync.sizeBytes << "," + << " kind=" << data->args.hipMemcpyAsync.kind << "," + << " stream=" << data->args.hipMemcpyAsync.stream + << ")"; + break; + case HIP_API_ID_hipMalloc3DArray: + oss << "hipMalloc3DArray(" + << " array=" << data->args.hipMalloc3DArray.array << "," + << " desc=" << data->args.hipMalloc3DArray.desc << "," + << " extent=" << data->args.hipMalloc3DArray.extent << "," + << " flags=" << data->args.hipMalloc3DArray.flags + << ")"; + break; + case HIP_API_ID_hipStreamCreate: + oss << "hipStreamCreate(" + << " stream=" << data->args.hipStreamCreate.stream + << ")"; + break; + case HIP_API_ID_hipCtxGetCurrent: + oss << "hipCtxGetCurrent(" + << " ctx=" << data->args.hipCtxGetCurrent.ctx + << ")"; + break; + case HIP_API_ID_hipDevicePrimaryCtxGetState: + oss << "hipDevicePrimaryCtxGetState(" + << " dev=" << data->args.hipDevicePrimaryCtxGetState.dev << "," + << " flags=" << data->args.hipDevicePrimaryCtxGetState.flags << "," + << " active=" << data->args.hipDevicePrimaryCtxGetState.active + << ")"; + break; + case HIP_API_ID_hipEventQuery: + oss << "hipEventQuery(" + << " event=" << data->args.hipEventQuery.event + << ")"; + break; + case HIP_API_ID_hipEventCreate: + oss << "hipEventCreate(" + << " event=" << data->args.hipEventCreate.event + << ")"; + break; + case HIP_API_ID_hipMemGetAddressRange: + oss << "hipMemGetAddressRange(" + << " pbase=" << data->args.hipMemGetAddressRange.pbase << "," + << " psize=" << data->args.hipMemGetAddressRange.psize << "," + << " dptr=" << data->args.hipMemGetAddressRange.dptr + << ")"; + break; + case HIP_API_ID_hipMemcpyFromSymbol: + oss << "hipMemcpyFromSymbol(" + << " dst=" << data->args.hipMemcpyFromSymbol.dst << "," + << " symbolName=" << data->args.hipMemcpyFromSymbol.symbolName << "," + << " sizeBytes=" << data->args.hipMemcpyFromSymbol.sizeBytes << "," + << " offset=" << data->args.hipMemcpyFromSymbol.offset << "," + << " kind=" << data->args.hipMemcpyFromSymbol.kind + << ")"; + break; + case HIP_API_ID_hipArrayCreate: + oss << "hipArrayCreate(" + << " pHandle=" << data->args.hipArrayCreate.pHandle << "," + << " pAllocateArray=" << data->args.hipArrayCreate.pAllocateArray + << ")"; + break; + case HIP_API_ID_hipStreamGetFlags: + oss << "hipStreamGetFlags(" + << " stream=" << data->args.hipStreamGetFlags.stream << "," + << " flags=" << data->args.hipStreamGetFlags.flags + << ")"; + break; + case HIP_API_ID_hipMallocArray: + oss << "hipMallocArray(" + << " array=" << data->args.hipMallocArray.array << "," + << " desc=" << data->args.hipMallocArray.desc << "," + << " width=" << data->args.hipMallocArray.width << "," + << " height=" << data->args.hipMallocArray.height << "," + << " flags=" << data->args.hipMallocArray.flags + << ")"; + break; + case HIP_API_ID_hipCtxGetSharedMemConfig: + oss << "hipCtxGetSharedMemConfig(" + << " pConfig=" << data->args.hipCtxGetSharedMemConfig.pConfig + << ")"; + break; + case HIP_API_ID_hipMemPtrGetInfo: + oss << "hipMemPtrGetInfo(" + << " ptr=" << data->args.hipMemPtrGetInfo.ptr << "," + << " size=" << data->args.hipMemPtrGetInfo.size + << ")"; + break; + case HIP_API_ID_hipCtxGetFlags: + oss << "hipCtxGetFlags(" + << " flags=" << data->args.hipCtxGetFlags.flags + << ")"; + break; + case HIP_API_ID_hipStreamDestroy: + oss << "hipStreamDestroy(" + << " stream=" << data->args.hipStreamDestroy.stream + << ")"; + break; + case HIP_API_ID_hipMemset3DAsync: + oss << "hipMemset3DAsync(" + << " pitchedDevPtr=" << data->args.hipMemset3DAsync.pitchedDevPtr << "," + << " value=" << data->args.hipMemset3DAsync.value << "," + << " extent=" << data->args.hipMemset3DAsync.extent << "," + << " stream=" << data->args.hipMemset3DAsync.stream + << ")"; + break; + case HIP_API_ID_hipMemcpy3D: + oss << "hipMemcpy3D(" + << " p=" << data->args.hipMemcpy3D.p + << ")"; + break; + case HIP_API_ID_hipInit: + oss << "hipInit(" + << " flags=" << data->args.hipInit.flags + << ")"; + break; + case HIP_API_ID_hipMemcpyAtoH: + oss << "hipMemcpyAtoH(" + << " dst=" << data->args.hipMemcpyAtoH.dst << "," + << " srcArray=" << data->args.hipMemcpyAtoH.srcArray << "," + << " srcOffset=" << data->args.hipMemcpyAtoH.srcOffset << "," + << " count=" << data->args.hipMemcpyAtoH.count + << ")"; + break; + case HIP_API_ID_hipMemset2D: + oss << "hipMemset2D(" + << " dst=" << data->args.hipMemset2D.dst << "," + << " pitch=" << data->args.hipMemset2D.pitch << "," + << " value=" << data->args.hipMemset2D.value << "," + << " width=" << data->args.hipMemset2D.width << "," + << " height=" << data->args.hipMemset2D.height + << ")"; + break; + case HIP_API_ID_hipMemset2DAsync: + oss << "hipMemset2DAsync(" + << " dst=" << data->args.hipMemset2DAsync.dst << "," + << " pitch=" << data->args.hipMemset2DAsync.pitch << "," + << " value=" << data->args.hipMemset2DAsync.value << "," + << " width=" << data->args.hipMemset2DAsync.width << "," + << " height=" << data->args.hipMemset2DAsync.height << "," + << " stream=" << data->args.hipMemset2DAsync.stream + << ")"; + break; + case HIP_API_ID_hipDeviceCanAccessPeer: + oss << "hipDeviceCanAccessPeer(" + << " canAccessPeer=" << data->args.hipDeviceCanAccessPeer.canAccessPeer << "," + << " deviceId=" << data->args.hipDeviceCanAccessPeer.deviceId << "," + << " peerDeviceId=" << data->args.hipDeviceCanAccessPeer.peerDeviceId + << ")"; + break; + case HIP_API_ID_hipDeviceEnablePeerAccess: + oss << "hipDeviceEnablePeerAccess(" + << " peerDeviceId=" << data->args.hipDeviceEnablePeerAccess.peerDeviceId << "," + << " flags=" << data->args.hipDeviceEnablePeerAccess.flags + << ")"; + break; + case HIP_API_ID_hipModuleUnload: + oss << "hipModuleUnload(" + << " module=" << data->args.hipModuleUnload.module + << ")"; + break; + case HIP_API_ID_hipHostUnregister: + oss << "hipHostUnregister(" + << " hostPtr=" << data->args.hipHostUnregister.hostPtr + << ")"; + break; + case HIP_API_ID_hipProfilerStop: + oss << "hipProfilerStop(" + << ")"; + break; + case HIP_API_ID_hipLaunchByPtr: + oss << "hipLaunchByPtr(" + << " func=" << data->args.hipLaunchByPtr.func + << ")"; + break; + case HIP_API_ID_hipStreamSynchronize: + oss << "hipStreamSynchronize(" + << " stream=" << data->args.hipStreamSynchronize.stream + << ")"; + break; + case HIP_API_ID_hipFreeHost: + oss << "hipFreeHost(" + << " ptr=" << data->args.hipFreeHost.ptr + << ")"; + break; + case HIP_API_ID_hipRemoveApiCallback: + oss << "hipRemoveApiCallback(" + << " id=" << data->args.hipRemoveApiCallback.id + << ")"; + break; + case HIP_API_ID_hipDeviceSetCacheConfig: + oss << "hipDeviceSetCacheConfig(" + << " cacheConfig=" << data->args.hipDeviceSetCacheConfig.cacheConfig + << ")"; + break; + case HIP_API_ID_hipCtxGetApiVersion: + oss << "hipCtxGetApiVersion(" + << " ctx=" << data->args.hipCtxGetApiVersion.ctx << "," + << " apiVersion=" << data->args.hipCtxGetApiVersion.apiVersion + << ")"; + break; + case HIP_API_ID_hipMemcpyHtoD: + oss << "hipMemcpyHtoD(" + << " dst=" << data->args.hipMemcpyHtoD.dst << "," + << " src=" << data->args.hipMemcpyHtoD.src << "," + << " sizeBytes=" << data->args.hipMemcpyHtoD.sizeBytes + << ")"; + break; + case HIP_API_ID_hipModuleGetGlobal: + oss << "hipModuleGetGlobal(" + << " dptr=" << data->args.hipModuleGetGlobal.dptr << "," + << " bytes=" << data->args.hipModuleGetGlobal.bytes << "," + << " hmod=" << data->args.hipModuleGetGlobal.hmod << "," + << " name=" << data->args.hipModuleGetGlobal.name + << ")"; + break; + case HIP_API_ID_hipMemcpyHtoA: + oss << "hipMemcpyHtoA(" + << " dstArray=" << data->args.hipMemcpyHtoA.dstArray << "," + << " dstOffset=" << data->args.hipMemcpyHtoA.dstOffset << "," + << " srcHost=" << data->args.hipMemcpyHtoA.srcHost << "," + << " count=" << data->args.hipMemcpyHtoA.count + << ")"; + break; + case HIP_API_ID_hipCtxCreate: + oss << "hipCtxCreate(" + << " ctx=" << data->args.hipCtxCreate.ctx << "," + << " flags=" << data->args.hipCtxCreate.flags << "," + << " device=" << data->args.hipCtxCreate.device + << ")"; + break; + case HIP_API_ID_hipMemcpy2D: + oss << "hipMemcpy2D(" + << " dst=" << data->args.hipMemcpy2D.dst << "," + << " dpitch=" << data->args.hipMemcpy2D.dpitch << "," + << " src=" << data->args.hipMemcpy2D.src << "," + << " spitch=" << data->args.hipMemcpy2D.spitch << "," + << " width=" << data->args.hipMemcpy2D.width << "," + << " height=" << data->args.hipMemcpy2D.height << "," + << " kind=" << data->args.hipMemcpy2D.kind + << ")"; + break; + case HIP_API_ID_hipIpcCloseMemHandle: + oss << "hipIpcCloseMemHandle(" + << " devPtr=" << data->args.hipIpcCloseMemHandle.devPtr + << ")"; + break; + case HIP_API_ID_hipChooseDevice: + oss << "hipChooseDevice(" + << " device=" << data->args.hipChooseDevice.device << "," + << " prop=" << data->args.hipChooseDevice.prop + << ")"; + break; + case HIP_API_ID_hipDeviceSetSharedMemConfig: + oss << "hipDeviceSetSharedMemConfig(" + << " config=" << data->args.hipDeviceSetSharedMemConfig.config + << ")"; + break; + case HIP_API_ID_hipDeviceComputeCapability: + oss << "hipDeviceComputeCapability(" + << " major=" << data->args.hipDeviceComputeCapability.major << "," + << " minor=" << data->args.hipDeviceComputeCapability.minor << "," + << " device=" << data->args.hipDeviceComputeCapability.device + << ")"; + break; + case HIP_API_ID_hipRegisterApiCallback: + oss << "hipRegisterApiCallback(" + << " id=" << data->args.hipRegisterApiCallback.id << "," + << " fun=" << data->args.hipRegisterApiCallback.fun << "," + << " arg=" << data->args.hipRegisterApiCallback.arg + << ")"; + break; + case HIP_API_ID_hipDeviceGet: + oss << "hipDeviceGet(" + << " device=" << data->args.hipDeviceGet.device << "," + << " ordinal=" << data->args.hipDeviceGet.ordinal + << ")"; + break; + case HIP_API_ID_hipProfilerStart: + oss << "hipProfilerStart(" + << ")"; + break; + case HIP_API_ID_hipCtxSetCacheConfig: + oss << "hipCtxSetCacheConfig(" + << " cacheConfig=" << data->args.hipCtxSetCacheConfig.cacheConfig + << ")"; + break; + case HIP_API_ID_hipFuncSetCacheConfig: + oss << "hipFuncSetCacheConfig(" + << " func=" << data->args.hipFuncSetCacheConfig.func << "," + << " config=" << data->args.hipFuncSetCacheConfig.config + << ")"; + break; + case HIP_API_ID_hipMemcpyPeerAsync: + oss << "hipMemcpyPeerAsync(" + << " dst=" << data->args.hipMemcpyPeerAsync.dst << "," + << " dstDeviceId=" << data->args.hipMemcpyPeerAsync.dstDeviceId << "," + << " src=" << data->args.hipMemcpyPeerAsync.src << "," + << " srcDevice=" << data->args.hipMemcpyPeerAsync.srcDevice << "," + << " sizeBytes=" << data->args.hipMemcpyPeerAsync.sizeBytes << "," + << " stream=" << data->args.hipMemcpyPeerAsync.stream + << ")"; + break; + case HIP_API_ID_hipEventElapsedTime: + oss << "hipEventElapsedTime(" + << " ms=" << data->args.hipEventElapsedTime.ms << "," + << " start=" << data->args.hipEventElapsedTime.start << "," + << " stop=" << data->args.hipEventElapsedTime.stop + << ")"; + break; + case HIP_API_ID_hipDevicePrimaryCtxReset: + oss << "hipDevicePrimaryCtxReset(" + << " dev=" << data->args.hipDevicePrimaryCtxReset.dev + << ")"; + break; + case HIP_API_ID_hipEventDestroy: + oss << "hipEventDestroy(" + << " event=" << data->args.hipEventDestroy.event + << ")"; + break; + case HIP_API_ID_hipCtxPopCurrent: + oss << "hipCtxPopCurrent(" + << " ctx=" << data->args.hipCtxPopCurrent.ctx + << ")"; + break; + case HIP_API_ID_hipHostGetFlags: + oss << "hipHostGetFlags(" + << " flagsPtr=" << data->args.hipHostGetFlags.flagsPtr << "," + << " hostPtr=" << data->args.hipHostGetFlags.hostPtr + << ")"; + break; + case HIP_API_ID_hipHostMalloc: + oss << "hipHostMalloc(" + << " ptr=" << data->args.hipHostMalloc.ptr << "," + << " size=" << data->args.hipHostMalloc.size << "," + << " flags=" << data->args.hipHostMalloc.flags + << ")"; + break; + case HIP_API_ID_hipDriverGetVersion: + oss << "hipDriverGetVersion(" + << " driverVersion=" << data->args.hipDriverGetVersion.driverVersion + << ")"; + break; + case HIP_API_ID_hipMemGetInfo: + oss << "hipMemGetInfo(" + << " free=" << data->args.hipMemGetInfo.free << "," + << " total=" << data->args.hipMemGetInfo.total + << ")"; + break; + case HIP_API_ID_hipDeviceReset: + oss << "hipDeviceReset(" + << ")"; + break; + case HIP_API_ID_hipMemset: + oss << "hipMemset(" + << " dst=" << data->args.hipMemset.dst << "," + << " value=" << data->args.hipMemset.value << "," + << " sizeBytes=" << data->args.hipMemset.sizeBytes + << ")"; + break; + case HIP_API_ID_hipMemsetD8: + oss << "hipMemsetD8(" + << " dest=" << data->args.hipMemsetD8.dest << "," + << " value=" << data->args.hipMemsetD8.value << "," + << " sizeBytes=" << data->args.hipMemsetD8.sizeBytes + << ")"; + break; + case HIP_API_ID_hipHostRegister: + oss << "hipHostRegister(" + << " hostPtr=" << data->args.hipHostRegister.hostPtr << "," + << " sizeBytes=" << data->args.hipHostRegister.sizeBytes << "," + << " flags=" << data->args.hipHostRegister.flags + << ")"; + break; + case HIP_API_ID_hipCtxSetSharedMemConfig: + oss << "hipCtxSetSharedMemConfig(" + << " config=" << data->args.hipCtxSetSharedMemConfig.config + << ")"; + break; + case HIP_API_ID_hipArray3DCreate: + oss << "hipArray3DCreate(" + << " array=" << data->args.hipArray3DCreate.array << "," + << " pAllocateArray=" << data->args.hipArray3DCreate.pAllocateArray + << ")"; + break; + case HIP_API_ID_hipIpcOpenMemHandle: + oss << "hipIpcOpenMemHandle(" + << " devPtr=" << data->args.hipIpcOpenMemHandle.devPtr << "," + << " handle=" << data->args.hipIpcOpenMemHandle.handle << "," + << " flags=" << data->args.hipIpcOpenMemHandle.flags + << ")"; + break; + case HIP_API_ID_hipGetLastError: + oss << "hipGetLastError(" + << ")"; + break; + case HIP_API_ID_hipCtxDestroy: + oss << "hipCtxDestroy(" + << " ctx=" << data->args.hipCtxDestroy.ctx + << ")"; + break; + case HIP_API_ID_hipDeviceGetSharedMemConfig: + oss << "hipDeviceGetSharedMemConfig(" + << " pConfig=" << data->args.hipDeviceGetSharedMemConfig.pConfig + << ")"; + break; + case HIP_API_ID_hipRegisterActivityCallback: + oss << "hipRegisterActivityCallback(" + << " id=" << data->args.hipRegisterActivityCallback.id << "," + << " fun=" << data->args.hipRegisterActivityCallback.fun << "," + << " arg=" << data->args.hipRegisterActivityCallback.arg + << ")"; + break; + case HIP_API_ID_hipSetDeviceFlags: + oss << "hipSetDeviceFlags(" + << " flags=" << data->args.hipSetDeviceFlags.flags + << ")"; + break; + case HIP_API_ID_hipFree: + oss << "hipFree(" + << " ptr=" << data->args.hipFree.ptr + << ")"; + break; + case HIP_API_ID_hipDeviceGetAttribute: + oss << "hipDeviceGetAttribute(" + << " pi=" << data->args.hipDeviceGetAttribute.pi << "," + << " attr=" << data->args.hipDeviceGetAttribute.attr << "," + << " deviceId=" << data->args.hipDeviceGetAttribute.deviceId + << ")"; + break; + case HIP_API_ID_hipMemcpyDtoH: + oss << "hipMemcpyDtoH(" + << " dst=" << data->args.hipMemcpyDtoH.dst << "," + << " src=" << data->args.hipMemcpyDtoH.src << "," + << " sizeBytes=" << data->args.hipMemcpyDtoH.sizeBytes + << ")"; + break; + case HIP_API_ID_hipCtxDisablePeerAccess: + oss << "hipCtxDisablePeerAccess(" + << " peerCtx=" << data->args.hipCtxDisablePeerAccess.peerCtx + << ")"; + break; + case HIP_API_ID_hipDeviceGetByPCIBusId: + oss << "hipDeviceGetByPCIBusId(" + << " device=" << data->args.hipDeviceGetByPCIBusId.device << "," + << " pciBusId=" << data->args.hipDeviceGetByPCIBusId.pciBusId + << ")"; + break; + case HIP_API_ID_hipIpcGetMemHandle: + oss << "hipIpcGetMemHandle(" + << " handle=" << data->args.hipIpcGetMemHandle.handle << "," + << " devPtr=" << data->args.hipIpcGetMemHandle.devPtr + << ")"; + break; + case HIP_API_ID_hipMemcpyHtoDAsync: + oss << "hipMemcpyHtoDAsync(" + << " dst=" << data->args.hipMemcpyHtoDAsync.dst << "," + << " src=" << data->args.hipMemcpyHtoDAsync.src << "," + << " sizeBytes=" << data->args.hipMemcpyHtoDAsync.sizeBytes << "," + << " stream=" << data->args.hipMemcpyHtoDAsync.stream + << ")"; + break; + case HIP_API_ID_hipCtxGetDevice: + oss << "hipCtxGetDevice(" + << " device=" << data->args.hipCtxGetDevice.device + << ")"; + break; + case HIP_API_ID_hipMemset3D: + oss << "hipMemset3D(" + << " pitchedDevPtr=" << data->args.hipMemset3D.pitchedDevPtr << "," + << " value=" << data->args.hipMemset3D.value << "," + << " extent=" << data->args.hipMemset3D.extent + << ")"; + break; + case HIP_API_ID_hipModuleLoadData: + oss << "hipModuleLoadData(" + << " module=" << data->args.hipModuleLoadData.module << "," + << " image=" << data->args.hipModuleLoadData.image + << ")"; + break; + case HIP_API_ID_hipDeviceTotalMem: + oss << "hipDeviceTotalMem(" + << " bytes=" << data->args.hipDeviceTotalMem.bytes << "," + << " device=" << data->args.hipDeviceTotalMem.device + << ")"; + break; + case HIP_API_ID_hipCtxSetCurrent: + oss << "hipCtxSetCurrent(" + << " ctx=" << data->args.hipCtxSetCurrent.ctx + << ")"; + break; + case HIP_API_ID_hipMallocHost: + oss << "hipMallocHost(" + << " ptr=" << data->args.hipMallocHost.ptr << "," + << " size=" << data->args.hipMallocHost.size + << ")"; + break; + case HIP_API_ID_hipDevicePrimaryCtxRetain: + oss << "hipDevicePrimaryCtxRetain(" + << " pctx=" << data->args.hipDevicePrimaryCtxRetain.pctx << "," + << " dev=" << data->args.hipDevicePrimaryCtxRetain.dev + << ")"; + break; + case HIP_API_ID_hipDeviceDisablePeerAccess: + oss << "hipDeviceDisablePeerAccess(" + << " peerDeviceId=" << data->args.hipDeviceDisablePeerAccess.peerDeviceId + << ")"; + break; + case HIP_API_ID_hipStreamCreateWithFlags: + oss << "hipStreamCreateWithFlags(" + << " stream=" << data->args.hipStreamCreateWithFlags.stream << "," + << " flags=" << data->args.hipStreamCreateWithFlags.flags + << ")"; + break; + case HIP_API_ID_hipMemcpyFromArray: + oss << "hipMemcpyFromArray(" + << " dst=" << data->args.hipMemcpyFromArray.dst << "," + << " srcArray=" << data->args.hipMemcpyFromArray.srcArray << "," + << " wOffset=" << data->args.hipMemcpyFromArray.wOffset << "," + << " hOffset=" << data->args.hipMemcpyFromArray.hOffset << "," + << " count=" << data->args.hipMemcpyFromArray.count << "," + << " kind=" << data->args.hipMemcpyFromArray.kind + << ")"; + break; + case HIP_API_ID_hipMemcpy2DAsync: + oss << "hipMemcpy2DAsync(" + << " dst=" << data->args.hipMemcpy2DAsync.dst << "," + << " dpitch=" << data->args.hipMemcpy2DAsync.dpitch << "," + << " src=" << data->args.hipMemcpy2DAsync.src << "," + << " spitch=" << data->args.hipMemcpy2DAsync.spitch << "," + << " width=" << data->args.hipMemcpy2DAsync.width << "," + << " height=" << data->args.hipMemcpy2DAsync.height << "," + << " kind=" << data->args.hipMemcpy2DAsync.kind << "," + << " stream=" << data->args.hipMemcpy2DAsync.stream + << ")"; + break; + case HIP_API_ID_hipFuncGetAttributes: + oss << "hipFuncGetAttributes(" + << " attr=" << data->args.hipFuncGetAttributes.attr << "," + << " func=" << data->args.hipFuncGetAttributes.func + << ")"; + break; + case HIP_API_ID_hipEventCreateWithFlags: + oss << "hipEventCreateWithFlags(" + << " event=" << data->args.hipEventCreateWithFlags.event << "," + << " flags=" << data->args.hipEventCreateWithFlags.flags + << ")"; + break; + case HIP_API_ID_hipStreamQuery: + oss << "hipStreamQuery(" + << " stream=" << data->args.hipStreamQuery.stream + << ")"; + break; + case HIP_API_ID_hipDeviceGetPCIBusId: + oss << "hipDeviceGetPCIBusId(" + << " pciBusId=" << data->args.hipDeviceGetPCIBusId.pciBusId << "," + << " len=" << data->args.hipDeviceGetPCIBusId.len << "," + << " device=" << data->args.hipDeviceGetPCIBusId.device + << ")"; + break; + case HIP_API_ID_hipMemcpy: + oss << "hipMemcpy(" + << " dst=" << data->args.hipMemcpy.dst << "," + << " src=" << data->args.hipMemcpy.src << "," + << " sizeBytes=" << data->args.hipMemcpy.sizeBytes << "," + << " kind=" << data->args.hipMemcpy.kind + << ")"; + break; + case HIP_API_ID_hipPeekAtLastError: + oss << "hipPeekAtLastError(" + << ")"; + break; + case HIP_API_ID_hipHostAlloc: + oss << "hipHostAlloc(" + << " ptr=" << data->args.hipHostAlloc.ptr << "," + << " size=" << data->args.hipHostAlloc.size << "," + << " flags=" << data->args.hipHostAlloc.flags + << ")"; + break; + case HIP_API_ID_hipStreamAddCallback: + oss << "hipStreamAddCallback(" + << " stream=" << data->args.hipStreamAddCallback.stream << "," + << " callback=" << data->args.hipStreamAddCallback.callback << "," + << " userData=" << data->args.hipStreamAddCallback.userData << "," + << " flags=" << data->args.hipStreamAddCallback.flags + << ")"; + break; + case HIP_API_ID_hipMemcpyToArray: + oss << "hipMemcpyToArray(" + << " dst=" << data->args.hipMemcpyToArray.dst << "," + << " wOffset=" << data->args.hipMemcpyToArray.wOffset << "," + << " hOffset=" << data->args.hipMemcpyToArray.hOffset << "," + << " src=" << data->args.hipMemcpyToArray.src << "," + << " count=" << data->args.hipMemcpyToArray.count << "," + << " kind=" << data->args.hipMemcpyToArray.kind + << ")"; + break; + case HIP_API_ID_hipDeviceSynchronize: + oss << "hipDeviceSynchronize(" + << ")"; + break; + case HIP_API_ID_hipDeviceGetCacheConfig: + oss << "hipDeviceGetCacheConfig(" + << " cacheConfig=" << data->args.hipDeviceGetCacheConfig.cacheConfig + << ")"; + break; + case HIP_API_ID_hipMalloc3D: + oss << "hipMalloc3D(" + << " pitchedDevPtr=" << data->args.hipMalloc3D.pitchedDevPtr << "," + << " extent=" << data->args.hipMalloc3D.extent + << ")"; + break; + case HIP_API_ID_hipPointerGetAttributes: + oss << "hipPointerGetAttributes(" + << " attributes=" << data->args.hipPointerGetAttributes.attributes << "," + << " ptr=" << data->args.hipPointerGetAttributes.ptr + << ")"; + break; + case HIP_API_ID_hipMemsetAsync: + oss << "hipMemsetAsync(" + << " dst=" << data->args.hipMemsetAsync.dst << "," + << " value=" << data->args.hipMemsetAsync.value << "," + << " sizeBytes=" << data->args.hipMemsetAsync.sizeBytes << "," + << " stream=" << data->args.hipMemsetAsync.stream + << ")"; + break; + case HIP_API_ID_hipMemcpyToSymbol: + oss << "hipMemcpyToSymbol(" + << " symbolName=" << data->args.hipMemcpyToSymbol.symbolName << "," + << " src=" << data->args.hipMemcpyToSymbol.src << "," + << " sizeBytes=" << data->args.hipMemcpyToSymbol.sizeBytes << "," + << " offset=" << data->args.hipMemcpyToSymbol.offset << "," + << " kind=" << data->args.hipMemcpyToSymbol.kind + << ")"; + break; + case HIP_API_ID_hipCtxPushCurrent: + oss << "hipCtxPushCurrent(" + << " ctx=" << data->args.hipCtxPushCurrent.ctx + << ")"; + break; + case HIP_API_ID_hipMemcpyPeer: + oss << "hipMemcpyPeer(" + << " dst=" << data->args.hipMemcpyPeer.dst << "," + << " dstDeviceId=" << data->args.hipMemcpyPeer.dstDeviceId << "," + << " src=" << data->args.hipMemcpyPeer.src << "," + << " srcDeviceId=" << data->args.hipMemcpyPeer.srcDeviceId << "," + << " sizeBytes=" << data->args.hipMemcpyPeer.sizeBytes + << ")"; + break; + case HIP_API_ID_hipEventSynchronize: + oss << "hipEventSynchronize(" + << " event=" << data->args.hipEventSynchronize.event + << ")"; + break; + case HIP_API_ID_hipMemcpyDtoDAsync: + oss << "hipMemcpyDtoDAsync(" + << " dst=" << data->args.hipMemcpyDtoDAsync.dst << "," + << " src=" << data->args.hipMemcpyDtoDAsync.src << "," + << " sizeBytes=" << data->args.hipMemcpyDtoDAsync.sizeBytes << "," + << " stream=" << data->args.hipMemcpyDtoDAsync.stream + << ")"; + break; + case HIP_API_ID_hipCtxEnablePeerAccess: + oss << "hipCtxEnablePeerAccess(" + << " peerCtx=" << data->args.hipCtxEnablePeerAccess.peerCtx << "," + << " flags=" << data->args.hipCtxEnablePeerAccess.flags + << ")"; + break; + case HIP_API_ID_hipMemcpyDtoHAsync: + oss << "hipMemcpyDtoHAsync(" + << " dst=" << data->args.hipMemcpyDtoHAsync.dst << "," + << " src=" << data->args.hipMemcpyDtoHAsync.src << "," + << " sizeBytes=" << data->args.hipMemcpyDtoHAsync.sizeBytes << "," + << " stream=" << data->args.hipMemcpyDtoHAsync.stream + << ")"; + break; + case HIP_API_ID_hipModuleLaunchKernel: + oss << "hipModuleLaunchKernel(" + << " f=" << data->args.hipModuleLaunchKernel.f << "," + << " gridDimX=" << data->args.hipModuleLaunchKernel.gridDimX << "," + << " gridDimY=" << data->args.hipModuleLaunchKernel.gridDimY << "," + << " gridDimZ=" << data->args.hipModuleLaunchKernel.gridDimZ << "," + << " blockDimX=" << data->args.hipModuleLaunchKernel.blockDimX << "," + << " blockDimY=" << data->args.hipModuleLaunchKernel.blockDimY << "," + << " blockDimZ=" << data->args.hipModuleLaunchKernel.blockDimZ << "," + << " sharedMemBytes=" << data->args.hipModuleLaunchKernel.sharedMemBytes << "," + << " stream=" << data->args.hipModuleLaunchKernel.stream << "," + << " kernelParams=" << data->args.hipModuleLaunchKernel.kernelParams << "," + << " extra=" << data->args.hipModuleLaunchKernel.extra + << ")"; + break; + case HIP_API_ID_hipModuleGetTexRef: + oss << "hipModuleGetTexRef(" + << " texRef=" << data->args.hipModuleGetTexRef.texRef << "," + << " hmod=" << data->args.hipModuleGetTexRef.hmod << "," + << " name=" << data->args.hipModuleGetTexRef.name + << ")"; + break; + case HIP_API_ID_hipRemoveActivityCallback: + oss << "hipRemoveActivityCallback(" + << " id=" << data->args.hipRemoveActivityCallback.id + << ")"; + break; + case HIP_API_ID_hipDeviceGetLimit: + oss << "hipDeviceGetLimit(" + << " pValue=" << data->args.hipDeviceGetLimit.pValue << "," + << " limit=" << data->args.hipDeviceGetLimit.limit + << ")"; + break; + case HIP_API_ID_hipModuleLoadDataEx: + oss << "hipModuleLoadDataEx(" + << " module=" << data->args.hipModuleLoadDataEx.module << "," + << " image=" << data->args.hipModuleLoadDataEx.image << "," + << " numOptions=" << data->args.hipModuleLoadDataEx.numOptions << "," + << " options=" << data->args.hipModuleLoadDataEx.options << "," + << " optionValues=" << data->args.hipModuleLoadDataEx.optionValues + << ")"; + break; + case HIP_API_ID_hipRuntimeGetVersion: + oss << "hipRuntimeGetVersion(" + << " runtimeVersion=" << data->args.hipRuntimeGetVersion.runtimeVersion + << ")"; + break; + case HIP_API_ID_hipGetDeviceProperties: + oss << "hipGetDeviceProperties(" + << " prop=" << data->args.hipGetDeviceProperties.prop << "," + << " deviceId=" << data->args.hipGetDeviceProperties.deviceId + << ")"; + break; + case HIP_API_ID_hipFreeArray: + oss << "hipFreeArray(" + << " array=" << data->args.hipFreeArray.array + << ")"; + break; + case HIP_API_ID_hipDevicePrimaryCtxRelease: + oss << "hipDevicePrimaryCtxRelease(" + << " dev=" << data->args.hipDevicePrimaryCtxRelease.dev + << ")"; + break; + case HIP_API_ID_hipHostGetDevicePointer: + oss << "hipHostGetDevicePointer(" + << " devPtr=" << data->args.hipHostGetDevicePointer.devPtr << "," + << " hstPtr=" << data->args.hipHostGetDevicePointer.hstPtr << "," + << " flags=" << data->args.hipHostGetDevicePointer.flags + << ")"; + break; + case HIP_API_ID_hipMemcpyParam2D: + oss << "hipMemcpyParam2D(" + << " pCopy=" << data->args.hipMemcpyParam2D.pCopy + << ")"; + break; + case HIP_API_ID_hipConfigureCall: + oss << "hipConfigureCall(" + << " gridDim=" << data->args.hipConfigureCall.gridDim << "," + << " blockDim=" << data->args.hipConfigureCall.blockDim << "," + << " sharedMem=" << data->args.hipConfigureCall.sharedMem << "," + << " stream=" << data->args.hipConfigureCall.stream + << ")"; + break; + case HIP_API_ID_hipModuleGetFunction: + oss << "hipModuleGetFunction(" + << " function=" << data->args.hipModuleGetFunction.function << "," + << " module=" << data->args.hipModuleGetFunction.module << "," + << " kname=" << data->args.hipModuleGetFunction.kname + << ")"; + break; + case HIP_API_ID_hipGetDevice: + oss << "hipGetDevice(" + << " deviceId=" << data->args.hipGetDevice.deviceId + << ")"; + break; + case HIP_API_ID_hipGetDeviceCount: + oss << "hipGetDeviceCount(" + << " count=" << data->args.hipGetDeviceCount.count + << ")"; + break; + default: oss << "unknown"; + }; + return strdup(oss.str().c_str()); +}; +#endif + +// HIP API activity record type +// Base record type +struct hip_act_record_t { + uint32_t domain; // activity domain id + uint32_t op_id; // operation id, dispatch/copy/barrier + uint32_t activity_kind; // activity kind + uint64_t correlation_id; // activity correlation ID + uint64_t begin_ns; // host begin timestamp, nano-seconds + uint64_t end_ns; // host end timestamp, nano-seconds +}; +// Async record type +struct hip_async_record_t : hip_act_record_t { + int device_id; + uint64_t stream_id; +}; +// Dispatch record type +struct hip_dispatch_record_t : hip_async_record_t {}; +// Barrier record type +struct hip_barrier_record_t : hip_async_record_t {}; +// Memcpy record type +struct hip_copy_record_t : hip_async_record_t { + size_t bytes; +}; +// Generic async operation record +typedef hip_copy_record_t hip_ops_record_t; +#endif // _HIP_CBSTR diff --git a/src/hip_context.cpp b/src/hip_context.cpp index 976df33fa4..f03d3bc7b5 100644 --- a/src/hip_context.cpp +++ b/src/hip_context.cpp @@ -40,7 +40,7 @@ void ihipCtxStackUpdate() { } hipError_t hipInit(unsigned int flags) { - HIP_INIT_API(flags); + HIP_INIT_CB_API(hipInit, flags); hipError_t e = hipSuccess; @@ -53,7 +53,7 @@ hipError_t hipInit(unsigned int flags) { } hipError_t hipCtxCreate(hipCtx_t* ctx, unsigned int flags, hipDevice_t device) { - HIP_INIT_API(ctx, flags, device); // FIXME - review if we want to init + HIP_INIT_CB_API(hipCtxCreate, ctx, flags, device); // FIXME - review if we want to init hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(device); { @@ -71,7 +71,7 @@ hipError_t hipCtxCreate(hipCtx_t* ctx, unsigned int flags, hipDevice_t device) { } hipError_t hipDeviceGet(hipDevice_t* device, int deviceId) { - HIP_INIT_API(device, deviceId); // FIXME - review if we want to init + HIP_INIT_CB_API(hipDeviceGet, device, deviceId); // FIXME - review if we want to init auto deviceHandle = ihipGetDevice(deviceId); @@ -86,7 +86,7 @@ hipError_t hipDeviceGet(hipDevice_t* device, int deviceId) { }; hipError_t hipDriverGetVersion(int* driverVersion) { - HIP_INIT_API(driverVersion); + HIP_INIT_CB_API(hipDriverGetVersion, driverVersion); hipError_t e = hipSuccess; if (driverVersion) { *driverVersion = 4; @@ -98,7 +98,7 @@ hipError_t hipDriverGetVersion(int* driverVersion) { } hipError_t hipRuntimeGetVersion(int* runtimeVersion) { - HIP_INIT_API(runtimeVersion); + HIP_INIT_CB_API(hipRuntimeGetVersion, runtimeVersion); hipError_t e = hipSuccess; if (runtimeVersion) { *runtimeVersion = HIP_VERSION_PATCH; @@ -110,7 +110,7 @@ hipError_t hipRuntimeGetVersion(int* runtimeVersion) { } hipError_t hipCtxDestroy(hipCtx_t ctx) { - HIP_INIT_API(ctx); + HIP_INIT_CB_API(hipCtxDestroy, ctx); hipError_t e = hipSuccess; ihipCtx_t* currentCtx = ihipGetTlsDefaultCtx(); ihipCtx_t* primaryCtx = ((ihipDevice_t*)ctx->getDevice())->_primaryCtx; @@ -134,7 +134,7 @@ hipError_t hipCtxDestroy(hipCtx_t ctx) { } hipError_t hipCtxPopCurrent(hipCtx_t* ctx) { - HIP_INIT_API(ctx); + HIP_INIT_CB_API(hipCtxPopCurrent, ctx); hipError_t e = hipSuccess; ihipCtx_t* currentCtx = ihipGetTlsDefaultCtx(); auto deviceHandle = currentCtx->getDevice(); @@ -155,7 +155,7 @@ hipError_t hipCtxPopCurrent(hipCtx_t* ctx) { } hipError_t hipCtxPushCurrent(hipCtx_t ctx) { - HIP_INIT_API(ctx); + HIP_INIT_CB_API(hipCtxPushCurrent, ctx); hipError_t e = hipSuccess; if (ctx != NULL) { // TODO- is this check needed? ihipSetTlsDefaultCtx(ctx); @@ -168,7 +168,7 @@ hipError_t hipCtxPushCurrent(hipCtx_t ctx) { } hipError_t hipCtxGetCurrent(hipCtx_t* ctx) { - HIP_INIT_API(ctx); + HIP_INIT_CB_API(hipCtxGetCurrent, ctx); hipError_t e = hipSuccess; if ((tls_getPrimaryCtx) || tls_ctxStack.empty()) { *ctx = ihipGetTlsDefaultCtx(); @@ -179,7 +179,7 @@ hipError_t hipCtxGetCurrent(hipCtx_t* ctx) { } hipError_t hipCtxSetCurrent(hipCtx_t ctx) { - HIP_INIT_API(ctx); + HIP_INIT_CB_API(hipCtxSetCurrent, ctx); hipError_t e = hipSuccess; if (ctx == NULL) { tls_ctxStack.pop(); @@ -192,7 +192,7 @@ hipError_t hipCtxSetCurrent(hipCtx_t ctx) { } hipError_t hipCtxGetDevice(hipDevice_t* device) { - HIP_INIT_API(device); + HIP_INIT_CB_API(hipCtxGetDevice, device); hipError_t e = hipSuccess; ihipCtx_t* ctx = ihipGetTlsDefaultCtx(); @@ -208,7 +208,7 @@ hipError_t hipCtxGetDevice(hipDevice_t* device) { } hipError_t hipCtxGetApiVersion(hipCtx_t ctx, int* apiVersion) { - HIP_INIT_API(apiVersion); + HIP_INIT_CB_API(hipCtxGetApiVersion, apiVersion); if (apiVersion) { *apiVersion = 4; @@ -218,7 +218,7 @@ hipError_t hipCtxGetApiVersion(hipCtx_t ctx, int* apiVersion) { } hipError_t hipCtxGetCacheConfig(hipFuncCache_t* cacheConfig) { - HIP_INIT_API(cacheConfig); + HIP_INIT_CB_API(hipCtxGetCacheConfig, cacheConfig); *cacheConfig = hipFuncCachePreferNone; @@ -226,7 +226,7 @@ hipError_t hipCtxGetCacheConfig(hipFuncCache_t* cacheConfig) { } hipError_t hipCtxSetCacheConfig(hipFuncCache_t cacheConfig) { - HIP_INIT_API(cacheConfig); + HIP_INIT_CB_API(hipCtxSetCacheConfig, cacheConfig); // Nop, AMD does not support variable cache configs. @@ -234,7 +234,7 @@ hipError_t hipCtxSetCacheConfig(hipFuncCache_t cacheConfig) { } hipError_t hipCtxSetSharedMemConfig(hipSharedMemConfig config) { - HIP_INIT_API(config); + HIP_INIT_CB_API(hipCtxSetSharedMemConfig, config); // Nop, AMD does not support variable shared mem configs. @@ -242,7 +242,7 @@ hipError_t hipCtxSetSharedMemConfig(hipSharedMemConfig config) { } hipError_t hipCtxGetSharedMemConfig(hipSharedMemConfig* pConfig) { - HIP_INIT_API(pConfig); + HIP_INIT_CB_API(hipCtxGetSharedMemConfig, pConfig); *pConfig = hipSharedMemBankSizeFourByte; @@ -250,12 +250,12 @@ hipError_t hipCtxGetSharedMemConfig(hipSharedMemConfig* pConfig) { } hipError_t hipCtxSynchronize(void) { - HIP_INIT_API(1); + HIP_INIT_CB_API(hipCtxSynchronize, 1); return ihipLogStatus(ihipSynchronize()); // TODP Shall check validity of ctx? } hipError_t hipCtxGetFlags(unsigned int* flags) { - HIP_INIT_API(flags); + HIP_INIT_CB_API(hipCtxGetFlags, flags); hipError_t e = hipSuccess; ihipCtx_t* tempCtx; tempCtx = ihipGetTlsDefaultCtx(); @@ -264,7 +264,7 @@ hipError_t hipCtxGetFlags(unsigned int* flags) { } hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int* flags, int* active) { - HIP_INIT_API(dev, flags, active); + HIP_INIT_CB_API(hipDevicePrimaryCtxGetState, dev, flags, active); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(dev); @@ -286,7 +286,7 @@ hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int* flags, int } hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev) { - HIP_INIT_API(dev); + HIP_INIT_CB_API(hipDevicePrimaryCtxRelease, dev); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(dev); @@ -297,7 +297,7 @@ hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev) { } hipError_t hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev) { - HIP_INIT_API(pctx, dev); + HIP_INIT_CB_API(hipDevicePrimaryCtxRetain, pctx, dev); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(dev); @@ -309,7 +309,7 @@ hipError_t hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev) { } hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev) { - HIP_INIT_API(dev); + HIP_INIT_CB_API(hipDevicePrimaryCtxReset, dev); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(dev); @@ -322,7 +322,7 @@ hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev) { } hipError_t hipDevicePrimaryCtxSetFlags(hipDevice_t dev, unsigned int flags) { - HIP_INIT_API(dev, flags); + HIP_INIT_CB_API(hipDevicePrimaryCtxSetFlags, dev, flags); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(dev); diff --git a/src/hip_device.cpp b/src/hip_device.cpp index 2aae7cf2a8..4d45f441e8 100644 --- a/src/hip_device.cpp +++ b/src/hip_device.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. //------------------------------------------------------------------------------------------------- // TODO - does this initialize HIP runtime? hipError_t hipGetDevice(int* deviceId) { - HIP_INIT_API(deviceId); + HIP_INIT_CB_API(hipGetDevice, deviceId); hipError_t e = hipSuccess; @@ -69,12 +69,12 @@ hipError_t ihipGetDeviceCount(int* count) { } hipError_t hipGetDeviceCount(int* count) { - HIP_INIT_API(count); + HIP_INIT_CB_API(hipGetDeviceCount, count); return ihipLogStatus(ihipGetDeviceCount(count)); } hipError_t hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig) { - HIP_INIT_API(cacheConfig); + HIP_INIT_CB_API(hipDeviceSetCacheConfig, cacheConfig); // Nop, AMD does not support variable cache configs. @@ -82,7 +82,7 @@ hipError_t hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig) { } hipError_t hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig) { - HIP_INIT_API(cacheConfig); + HIP_INIT_CB_API(hipDeviceGetCacheConfig, cacheConfig); if (cacheConfig == nullptr) { return ihipLogStatus(hipErrorInvalidValue); @@ -94,7 +94,7 @@ hipError_t hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig) { } hipError_t hipDeviceGetLimit(size_t* pValue, hipLimit_t limit) { - HIP_INIT_API(pValue, limit); + HIP_INIT_CB_API(hipDeviceGetLimit, pValue, limit); if (pValue == nullptr) { return ihipLogStatus(hipErrorInvalidValue); } @@ -107,7 +107,7 @@ hipError_t hipDeviceGetLimit(size_t* pValue, hipLimit_t limit) { } hipError_t hipFuncSetCacheConfig(const void* func, hipFuncCache_t cacheConfig) { - HIP_INIT_API(cacheConfig); + HIP_INIT_CB_API(hipFuncSetCacheConfig, cacheConfig); // Nop, AMD does not support variable cache configs. @@ -115,7 +115,7 @@ hipError_t hipFuncSetCacheConfig(const void* func, hipFuncCache_t cacheConfig) { } hipError_t hipDeviceSetSharedMemConfig(hipSharedMemConfig config) { - HIP_INIT_API(config); + HIP_INIT_CB_API(hipDeviceSetSharedMemConfig, config); // Nop, AMD does not support variable shared mem configs. @@ -123,7 +123,7 @@ hipError_t hipDeviceSetSharedMemConfig(hipSharedMemConfig config) { } hipError_t hipDeviceGetSharedMemConfig(hipSharedMemConfig* pConfig) { - HIP_INIT_API(pConfig); + HIP_INIT_CB_API(hipDeviceGetSharedMemConfig, pConfig); *pConfig = hipSharedMemBankSizeFourByte; @@ -131,7 +131,7 @@ hipError_t hipDeviceGetSharedMemConfig(hipSharedMemConfig* pConfig) { } hipError_t hipSetDevice(int deviceId) { - HIP_INIT_API(deviceId); + HIP_INIT_CB_API(hipSetDevice, deviceId); if ((deviceId < 0) || (deviceId >= g_deviceCnt)) { return ihipLogStatus(hipErrorInvalidDevice); } else { @@ -142,12 +142,12 @@ hipError_t hipSetDevice(int deviceId) { } hipError_t hipDeviceSynchronize(void) { - HIP_INIT_SPECIAL_API(TRACE_SYNC); + HIP_INIT_SPECIAL_CB_API(hipDeviceSynchronize, TRACE_SYNC); return ihipLogStatus(ihipSynchronize()); } hipError_t hipDeviceReset(void) { - HIP_INIT_API(); + HIP_INIT_CB_API(hipDeviceReset, ); auto* ctx = ihipGetTlsDefaultCtx(); @@ -287,7 +287,7 @@ hipError_t ihipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device } hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) { - HIP_INIT_API(pi, attr, device); + HIP_INIT_CB_API(hipDeviceGetAttribute, pi, attr, device); if ((device < 0) || (device >= g_deviceCnt)) { return ihipLogStatus(hipErrorInvalidDevice); } @@ -314,7 +314,7 @@ hipError_t ihipGetDeviceProperties(hipDeviceProp_t* props, int device) { } hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device) { - HIP_INIT_API(props, device); + HIP_INIT_CB_API(hipGetDeviceProperties, props, device); if ((device < 0) || (device >= g_deviceCnt)) { return ihipLogStatus(hipErrorInvalidDevice); } @@ -322,7 +322,7 @@ hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device) { } hipError_t hipSetDeviceFlags(unsigned int flags) { - HIP_INIT_API(flags); + HIP_INIT_CB_API(hipSetDeviceFlags, flags); hipError_t e = hipSuccess; @@ -367,7 +367,7 @@ hipError_t hipSetDeviceFlags(unsigned int flags) { }; hipError_t hipDeviceComputeCapability(int* major, int* minor, hipDevice_t device) { - HIP_INIT_API(major, minor, device); + HIP_INIT_CB_API(hipDeviceComputeCapability, major, minor, device); hipError_t e = hipSuccess; if ((device < 0) || (device >= g_deviceCnt)) { e = hipErrorInvalidDevice; @@ -380,7 +380,7 @@ hipError_t hipDeviceComputeCapability(int* major, int* minor, hipDevice_t device hipError_t hipDeviceGetName(char* name, int len, hipDevice_t device) { // Cast to void* here to avoid printing garbage in debug modes. - HIP_INIT_API((void*)name, len, device); + HIP_INIT_CB_API(hipDeviceGetName, (void*)name, len, device); hipError_t e = hipSuccess; if ((device < 0) || (device >= g_deviceCnt)) { e = hipErrorInvalidDevice; @@ -394,7 +394,7 @@ hipError_t hipDeviceGetName(char* name, int len, hipDevice_t device) { hipError_t hipDeviceGetPCIBusId(char* pciBusId, int len, int device) { // Cast to void* here to avoid printing garbage in debug modes. - HIP_INIT_API((void*)pciBusId, len, device); + HIP_INIT_CB_API(hipDeviceGetPCIBusId, (void*)pciBusId, len, device); hipError_t e = hipErrorInvalidValue; if ((device < 0) || (device >= g_deviceCnt)) { e = hipErrorInvalidDevice; @@ -413,7 +413,7 @@ hipError_t hipDeviceGetPCIBusId(char* pciBusId, int len, int device) { } hipError_t hipDeviceTotalMem(size_t* bytes, hipDevice_t device) { - HIP_INIT_API(bytes, device); + HIP_INIT_CB_API(hipDeviceTotalMem, bytes, device); hipError_t e = hipSuccess; if ((device < 0) || (device >= g_deviceCnt)) { e = hipErrorInvalidDevice; @@ -425,7 +425,7 @@ hipError_t hipDeviceTotalMem(size_t* bytes, hipDevice_t device) { } hipError_t hipDeviceGetByPCIBusId(int* device, const char* pciBusId) { - HIP_INIT_API(device, pciBusId); + HIP_INIT_CB_API(hipDeviceGetByPCIBusId, device, pciBusId); hipDeviceProp_t tempProp; int deviceCount = 0; hipError_t e = hipErrorInvalidValue; @@ -451,7 +451,7 @@ hipError_t hipDeviceGetByPCIBusId(int* device, const char* pciBusId) { } hipError_t hipChooseDevice(int* device, const hipDeviceProp_t* prop) { - HIP_INIT_API(device, prop); + HIP_INIT_CB_API(hipChooseDevice, device, prop); hipDeviceProp_t tempProp; hipError_t e = hipSuccess; if ((device == NULL) || (prop == NULL)) { diff --git a/src/hip_error.cpp b/src/hip_error.cpp index 48d5213382..ec1e2fbb02 100644 --- a/src/hip_error.cpp +++ b/src/hip_error.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. //--- hipError_t hipGetLastError() { - HIP_INIT_API(); + HIP_INIT_CB_API(hipGetLastError); // Return last error, but then reset the state: hipError_t e = ihipLogStatus(tls_lastHipError); @@ -39,7 +39,7 @@ hipError_t hipGetLastError() { } hipError_t hipPeekAtLastError() { - HIP_INIT_API(); + HIP_INIT_CB_API(hipPeekAtLastError); // peek at last error, but don't reset it. return ihipLogStatus(tls_lastHipError); diff --git a/src/hip_event.cpp b/src/hip_event.cpp index 9e56817fd4..206ad16a79 100644 --- a/src/hip_event.cpp +++ b/src/hip_event.cpp @@ -95,20 +95,20 @@ hipError_t ihipEventCreate(hipEvent_t* event, unsigned flags) { } hipError_t hipEventCreateWithFlags(hipEvent_t* event, unsigned flags) { - HIP_INIT_API(event, flags); + HIP_INIT_CB_API(hipEventCreateWithFlags, event, flags); return ihipLogStatus(ihipEventCreate(event, flags)); } hipError_t hipEventCreate(hipEvent_t* event) { - HIP_INIT_API(event); + HIP_INIT_CB_API(hipEventCreate, event); return ihipLogStatus(ihipEventCreate(event, 0)); } hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) { - HIP_INIT_SPECIAL_API(TRACE_SYNC, event, stream); + HIP_INIT_SPECIAL_CB_API(hipEventRecord, TRACE_SYNC, event, stream); auto ecd = event->locked_copyCrit(); @@ -153,7 +153,7 @@ hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) { hipError_t hipEventDestroy(hipEvent_t event) { - HIP_INIT_API(event); + HIP_INIT_CB_API(hipEventDestroy, event); if (event) { delete event; @@ -165,7 +165,7 @@ hipError_t hipEventDestroy(hipEvent_t event) { } hipError_t hipEventSynchronize(hipEvent_t event) { - HIP_INIT_SPECIAL_API(TRACE_SYNC, event); + HIP_INIT_SPECIAL_CB_API(hipEventSynchronize, TRACE_SYNC, event); if (!(event->_flags & hipEventReleaseToSystem)) { tprintf(DB_WARN, @@ -198,7 +198,7 @@ hipError_t hipEventSynchronize(hipEvent_t event) { } hipError_t hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop) { - HIP_INIT_API(ms, start, stop); + HIP_INIT_CB_API(hipEventElapsedTime, ms, start, stop); hipError_t status = hipSuccess; @@ -255,7 +255,7 @@ hipError_t hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop) { } hipError_t hipEventQuery(hipEvent_t event) { - HIP_INIT_SPECIAL_API(TRACE_QUERY, event); + HIP_INIT_SPECIAL_CB_API(hipEventQuery, TRACE_QUERY, event); if (!(event->_flags & hipEventReleaseToSystem)) { tprintf(DB_WARN, diff --git a/src/hip_hcc.cpp b/src/hip_hcc.cpp index e152e7ba69..ab25a04795 100644 --- a/src/hip_hcc.cpp +++ b/src/hip_hcc.cpp @@ -2288,7 +2288,7 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes //------------------------------------------------------------------------------------------------- // Profiler, really these should live elsewhere: hipError_t hipProfilerStart() { - HIP_INIT_API(); + HIP_INIT_CB_API(hipProfilerStart); #if COMPILE_HIP_ATP_MARKER amdtResumeProfiling(AMDT_ALL_PROFILING); #endif @@ -2298,7 +2298,7 @@ hipError_t hipProfilerStart() { hipError_t hipProfilerStop() { - HIP_INIT_API(); + HIP_INIT_CB_API(hipProfilerStop); #if COMPILE_HIP_ATP_MARKER amdtStopProfiling(AMDT_ALL_PROFILING); #endif diff --git a/src/hip_hcc_internal.h b/src/hip_hcc_internal.h index 8102f066de..b9667776d3 100644 --- a/src/hip_hcc_internal.h +++ b/src/hip_hcc_internal.h @@ -301,6 +301,11 @@ extern uint64_t recordApiTrace(std::string* fullStr, const std::string& apiStr); HIP_INIT() \ API_TRACE(0, __VA_ARGS__); +#define HIP_INIT_CB_API(cid, ...) \ + HIP_INIT() \ + API_TRACE(0, __VA_ARGS__); \ + HIP_CB_SPAWNER_OBJECT(cid); + // Like above, but will trace with a specified "special" bit. // Replace HIP_INIT_API with this call inside HIP APIs that launch work on the GPU: @@ -309,6 +314,11 @@ extern uint64_t recordApiTrace(std::string* fullStr, const std::string& apiStr); HIP_INIT() \ API_TRACE((HIP_TRACE_API & (1 << tbit)), __VA_ARGS__); +#define HIP_INIT_SPECIAL_CB_API(cid, tbit, ...) \ + HIP_INIT() \ + API_TRACE((HIP_TRACE_API & (1 << tbit)), __VA_ARGS__); \ + HIP_CB_SPAWNER_OBJECT(cid); + // This macro should be called at the end of every HIP API, and only at the end of top-level hip // APIS (not internal hip) It has dual function: logs the last error returned for use by diff --git a/src/hip_intercept.cpp b/src/hip_intercept.cpp new file mode 100644 index 0000000000..d2fffb9ef8 --- /dev/null +++ b/src/hip_intercept.cpp @@ -0,0 +1,49 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "hip/hip_runtime.h" +#include "hip/hip_prof_api.h" + +// HIP API callback/activity + +api_callbacks_table_t callbacks_table; + +extern std::string& FunctionSymbol(hipFunction_t f); +const char* hipKernelNameRef(const hipFunction_t f) { return FunctionSymbol(f).c_str(); } + +hipError_t hipRegisterApiCallback(uint32_t id, void* fun, void* arg) { + return callbacks_table.set_callback(id, reinterpret_cast(fun), arg) ? + hipSuccess : hipErrorInvalidValue; +} + +hipError_t hipRemoveApiCallback(uint32_t id) { + return callbacks_table.set_callback(id, NULL, NULL) ? hipSuccess : hipErrorInvalidValue; +} + +hipError_t hipRegisterActivityCallback(uint32_t id, void* fun, void* arg) { + return callbacks_table.set_activity(id, reinterpret_cast(fun), arg) ? + hipSuccess : hipErrorInvalidValue; +} + +hipError_t hipRemoveActivityCallback(uint32_t id) { + return callbacks_table.set_activity(id, NULL, NULL) ? hipSuccess : hipErrorInvalidValue; +} diff --git a/src/hip_memory.cpp b/src/hip_memory.cpp index 4ea5b24f43..b31192f5c5 100644 --- a/src/hip_memory.cpp +++ b/src/hip_memory.cpp @@ -159,7 +159,7 @@ void* allocAndSharePtr(const char* msg, size_t sizeBytes, ihipCtx_t* ctx, bool s // TODO - add more info here when available. // hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void* ptr) { - HIP_INIT_API(attributes, ptr); + HIP_INIT_CB_API(hipPointerGetAttributes, attributes, ptr); hipError_t e = hipSuccess; if ((attributes == nullptr) || (ptr == nullptr)) { @@ -206,7 +206,7 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsigned flags) { - HIP_INIT_API(devicePointer, hostPointer, flags); + HIP_INIT_CB_API(hipHostGetDevicePointer, devicePointer, hostPointer, flags); hipError_t e = hipSuccess; @@ -237,7 +237,7 @@ hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsi hipError_t hipMalloc(void** ptr, size_t sizeBytes) { - HIP_INIT_SPECIAL_API((TRACE_MEM), ptr, sizeBytes); + HIP_INIT_SPECIAL_CB_API(hipMalloc, (TRACE_MEM), ptr, sizeBytes); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -266,7 +266,7 @@ hipError_t hipMalloc(void** ptr, size_t sizeBytes) { hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) { - HIP_INIT_SPECIAL_API((TRACE_MEM), ptr, sizeBytes, flags); + HIP_INIT_SPECIAL_CB_API(hipHostMalloc, (TRACE_MEM), ptr, sizeBytes, flags); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -398,7 +398,7 @@ hipError_t ihipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t heigh // width in bytes hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height) { - HIP_INIT_SPECIAL_API((TRACE_MEM), ptr, pitch, width, height); + HIP_INIT_SPECIAL_CB_API(hipMallocPitch, (TRACE_MEM), ptr, pitch, width, height); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -409,7 +409,7 @@ hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height } hipError_t hipMalloc3D(hipPitchedPtr* pitchedDevPtr, hipExtent extent) { - HIP_INIT_API(pitchedDevPtr, &extent); + HIP_INIT_CB_API(hipMalloc3D, pitchedDevPtr, &extent); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -444,7 +444,7 @@ extern void getChannelOrderAndType(const hipChannelFormatDesc& desc, hsa_ext_image_channel_type_t* channelType); hipError_t hipArrayCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray) { - HIP_INIT_SPECIAL_API((TRACE_MEM), array, pAllocateArray); + HIP_INIT_SPECIAL_CB_API(hipArrayCreate, (TRACE_MEM), array, pAllocateArray); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; if (pAllocateArray->width > 0) { @@ -554,7 +554,7 @@ hipError_t hipArrayCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocat hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width, size_t height, unsigned int flags) { - HIP_INIT_SPECIAL_API((TRACE_MEM), array, desc, width, height, flags); + HIP_INIT_SPECIAL_CB_API(hipMallocArray, (TRACE_MEM), array, desc, width, height, flags); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; if (width > 0) { @@ -635,7 +635,7 @@ hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, si } hipError_t hipArray3DCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray) { - HIP_INIT_SPECIAL_API((TRACE_MEM), array, pAllocateArray); + HIP_INIT_SPECIAL_CB_API(hipArray3DCreate, (TRACE_MEM), array, pAllocateArray); hipError_t hip_status = hipSuccess; auto ctx = ihipGetTlsDefaultCtx(); @@ -762,7 +762,7 @@ hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc* - HIP_INIT_API(array, desc, &extent, flags); + HIP_INIT_CB_API(hipMalloc3DArray, array, desc, &extent, flags); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -846,7 +846,7 @@ hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc* } hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) { - HIP_INIT_API(flagsPtr, hostPtr); + HIP_INIT_CB_API(hipHostGetFlags, flagsPtr, hostPtr); hipError_t hip_status = hipSuccess; @@ -874,7 +874,7 @@ hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) { // TODO - need to fix several issues here related to P2P access, host memory fallback. hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags) { - HIP_INIT_API(hostPtr, sizeBytes, flags); + HIP_INIT_CB_API(hipHostRegister, hostPtr, sizeBytes, flags); hipError_t hip_status = hipSuccess; @@ -931,7 +931,7 @@ hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags) } hipError_t hipHostUnregister(void* hostPtr) { - HIP_INIT_API(hostPtr); + HIP_INIT_CB_API(hipHostUnregister, hostPtr); auto ctx = ihipGetTlsDefaultCtx(); hipError_t hip_status = hipSuccess; if (hostPtr == NULL) { @@ -966,7 +966,7 @@ inline hipDeviceptr_t agent_address_for_symbol(const char* symbolName) { hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t count, size_t offset, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), symbolName, src, count, offset, kind); + HIP_INIT_SPECIAL_CB_API(hipMemcpyToSymbol, (TRACE_MCMD), symbolName, src, count, offset, kind); if (symbolName == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); @@ -999,7 +999,7 @@ hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t cou hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t count, size_t offset, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), symbolName, dst, count, offset, kind); + HIP_INIT_SPECIAL_CB_API(hipMemcpyFromSymbol, (TRACE_MCMD), symbolName, dst, count, offset, kind); if (symbolName == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); @@ -1031,7 +1031,7 @@ hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t count, hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), symbolName, src, count, offset, kind, stream); + HIP_INIT_SPECIAL_CB_API(hipMemcpyToSymbolAsync, (TRACE_MCMD), symbolName, src, count, offset, kind, stream); if (symbolName == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); @@ -1066,7 +1066,7 @@ hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src, size_ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), symbolName, dst, count, offset, kind, stream); + HIP_INIT_SPECIAL_CB_API(hipMemcpyFromSymbolAsync, (TRACE_MCMD), symbolName, dst, count, offset, kind, stream); if (symbolName == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); @@ -1101,7 +1101,7 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t co //--- hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, kind); + HIP_INIT_SPECIAL_CB_API(hipMemcpy, (TRACE_MCMD), dst, src, sizeBytes, kind); hipError_t e = hipSuccess; @@ -1128,7 +1128,7 @@ hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes); + HIP_INIT_SPECIAL_CB_API(hipMemcpyHtoD, (TRACE_MCMD), dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1147,7 +1147,7 @@ hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) { hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes); + HIP_INIT_SPECIAL_CB_API(hipMemcpyDtoH, (TRACE_MCMD), dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1166,7 +1166,7 @@ hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) { hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes); + HIP_INIT_SPECIAL_CB_API(hipMemcpyDtoD, (TRACE_MCMD), dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1203,13 +1203,13 @@ hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) { hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, kind, stream); + HIP_INIT_SPECIAL_CB_API(hipMemcpyAsync, (TRACE_MCMD), dst, src, sizeBytes, kind, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, kind, stream)); } hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void* src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, stream); + HIP_INIT_SPECIAL_CB_API(hipMemcpyHtoDAsync, (TRACE_MCMD), dst, src, sizeBytes, stream); return ihipLogStatus( hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyHostToDevice, stream)); @@ -1217,14 +1217,14 @@ hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void* src, size_t sizeBytes, h hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, stream); + HIP_INIT_SPECIAL_CB_API(hipMemcpyDtoDAsync, (TRACE_MCMD), dst, src, sizeBytes, stream); return ihipLogStatus( hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDeviceToDevice, stream)); } hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes, stream); + HIP_INIT_SPECIAL_CB_API(hipMemcpyDtoHAsync, (TRACE_MCMD), dst, src, sizeBytes, stream); return ihipLogStatus( hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDeviceToHost, stream)); @@ -1232,7 +1232,7 @@ hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, h hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, wOffset, hOffset, src, spitch, width, height, kind); + HIP_INIT_SPECIAL_CB_API(hipMemcpy2DToArray, (TRACE_MCMD), dst, wOffset, hOffset, src, spitch, width, height, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1284,7 +1284,7 @@ hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, con hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, wOffset, hOffset, src, count, kind); + HIP_INIT_SPECIAL_CB_API(hipMemcpyToArray, (TRACE_MCMD), dst, wOffset, hOffset, src, count, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1303,7 +1303,7 @@ hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const hipError_t hipMemcpyFromArray(void* dst, hipArray_const_t srcArray, size_t wOffset, size_t hOffset, size_t count, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, srcArray, wOffset, hOffset, count, kind); + HIP_INIT_SPECIAL_CB_API(hipMemcpyFromArray, (TRACE_MCMD), dst, srcArray, wOffset, hOffset, count, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1321,7 +1321,7 @@ hipError_t hipMemcpyFromArray(void* dst, hipArray_const_t srcArray, size_t wOffs } hipError_t hipMemcpyHtoA(hipArray* dstArray, size_t dstOffset, const void* srcHost, size_t count) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dstArray, dstOffset, srcHost, count); + HIP_INIT_SPECIAL_CB_API(hipMemcpyHtoA, (TRACE_MCMD), dstArray, dstOffset, srcHost, count); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1339,7 +1339,7 @@ hipError_t hipMemcpyHtoA(hipArray* dstArray, size_t dstOffset, const void* srcHo } hipError_t hipMemcpyAtoH(void* dst, hipArray* srcArray, size_t srcOffset, size_t count) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, srcArray, srcOffset, count); + HIP_INIT_SPECIAL_CB_API(hipMemcpyAtoH, (TRACE_MCMD), dst, srcArray, srcOffset, count); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1358,7 +1358,7 @@ hipError_t hipMemcpyAtoH(void* dst, hipArray* srcArray, size_t srcOffset, size_t } hipError_t hipMemcpy3D(const struct hipMemcpy3DParms* p) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), p); + HIP_INIT_SPECIAL_CB_API(hipMemcpy3D, (TRACE_MCMD), p); hipError_t e = hipSuccess; if (p) { size_t byteSize; @@ -1626,7 +1626,7 @@ hipError_t ihipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind); + HIP_INIT_SPECIAL_CB_API(hipMemcpy2D, (TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind); hipError_t e = hipSuccess; e = ihipMemcpy2D(dst, dpitch, src, spitch, width, height, kind); return ihipLogStatus(e); @@ -1634,7 +1634,7 @@ hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, hipError_t hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind, stream); + HIP_INIT_SPECIAL_CB_API(hipMemcpy2DAsync, (TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind, stream); if (dst == nullptr || src == nullptr || width > dpitch || width > spitch) return ihipLogStatus(hipErrorInvalidValue); hipError_t e = hipSuccess; int isLocked = 0; @@ -1673,7 +1673,7 @@ hipError_t hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t sp } hipError_t hipMemcpyParam2D(const hip_Memcpy2D* pCopy) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), pCopy); + HIP_INIT_SPECIAL_CB_API(hipMemcpyParam2D, (TRACE_MCMD), pCopy); hipError_t e = hipSuccess; if (pCopy == nullptr) { e = hipErrorInvalidValue; @@ -1685,7 +1685,7 @@ hipError_t hipMemcpyParam2D(const hip_Memcpy2D* pCopy) { // TODO-sync: function is async unless target is pinned host memory - then these are fully sync. hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, value, sizeBytes, stream); + HIP_INIT_SPECIAL_CB_API(hipMemsetAsync, (TRACE_MCMD), dst, value, sizeBytes, stream); hipError_t e = hipSuccess; @@ -1697,7 +1697,7 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t st }; hipError_t hipMemset(void* dst, int value, size_t sizeBytes) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, value, sizeBytes); + HIP_INIT_SPECIAL_CB_API(hipMemset, (TRACE_MCMD), dst, value, sizeBytes); hipError_t e = hipSuccess; @@ -1713,7 +1713,7 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes) { } hipError_t hipMemset2D(void* dst, size_t pitch, int value, size_t width, size_t height) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, pitch, value, width, height); + HIP_INIT_SPECIAL_CB_API(hipMemset2D, (TRACE_MCMD), dst, pitch, value, width, height); hipError_t e = hipSuccess; @@ -1732,7 +1732,7 @@ hipError_t hipMemset2D(void* dst, size_t pitch, int value, size_t width, size_t hipError_t hipMemset2DAsync(void* dst, size_t pitch, int value, size_t width, size_t height, hipStream_t stream ) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, pitch, value, width, height, stream); + HIP_INIT_SPECIAL_CB_API(hipMemset2DAsync, (TRACE_MCMD), dst, pitch, value, width, height, stream); hipError_t e = hipSuccess; @@ -1749,7 +1749,7 @@ hipError_t hipMemset2DAsync(void* dst, size_t pitch, int value, size_t width, si }; hipError_t hipMemsetD8(hipDeviceptr_t dst, unsigned char value, size_t sizeBytes) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, value, sizeBytes); + HIP_INIT_SPECIAL_CB_API(hipMemsetD8, (TRACE_MCMD), dst, value, sizeBytes); hipError_t e = hipSuccess; @@ -1766,7 +1766,7 @@ hipError_t hipMemsetD8(hipDeviceptr_t dst, unsigned char value, size_t sizeBytes hipError_t hipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent ) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), &pitchedDevPtr, value, &extent); + HIP_INIT_SPECIAL_CB_API(hipMemset3D, (TRACE_MCMD), &pitchedDevPtr, value, &extent); hipError_t e = hipSuccess; hipStream_t stream = hipStreamNull; @@ -1785,7 +1785,7 @@ hipError_t hipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent hipError_t hipMemset3DAsync(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent ,hipStream_t stream ) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), &pitchedDevPtr, value, &extent); + HIP_INIT_SPECIAL_CB_API(hipMemset3DAsync, (TRACE_MCMD), &pitchedDevPtr, value, &extent); hipError_t e = hipSuccess; // TODO - call an ihip memset so HIP_TRACE is correct. @@ -1801,7 +1801,7 @@ hipError_t hipMemset3DAsync(hipPitchedPtr pitchedDevPtr, int value, hipExtent e } hipError_t hipMemGetInfo(size_t* free, size_t* total) { - HIP_INIT_API(free, total); + HIP_INIT_CB_API(hipMemGetInfo, free, total); hipError_t e = hipSuccess; @@ -1835,7 +1835,7 @@ hipError_t hipMemGetInfo(size_t* free, size_t* total) { } hipError_t hipMemPtrGetInfo(void* ptr, size_t* size) { - HIP_INIT_API(ptr, size); + HIP_INIT_CB_API(hipMemPtrGetInfo, ptr, size); hipError_t e = hipSuccess; @@ -1860,7 +1860,7 @@ hipError_t hipMemPtrGetInfo(void* ptr, size_t* size) { hipError_t hipFree(void* ptr) { - HIP_INIT_SPECIAL_API((TRACE_MEM), ptr); + HIP_INIT_SPECIAL_CB_API(hipFree, (TRACE_MEM), ptr); hipError_t hipStatus = hipErrorInvalidDevicePointer; @@ -1892,7 +1892,7 @@ hipError_t hipFree(void* ptr) { hipError_t hipHostFree(void* ptr) { - HIP_INIT_SPECIAL_API((TRACE_MEM), ptr); + HIP_INIT_SPECIAL_CB_API(hipHostFree, (TRACE_MEM), ptr); // Synchronize to ensure all work has finished. ihipGetTlsDefaultCtx()->locked_waitAllStreams(); // ignores non-blocking streams, this waits @@ -1927,7 +1927,7 @@ hipError_t hipHostFree(void* ptr) { hipError_t hipFreeHost(void* ptr) { return hipHostFree(ptr); } hipError_t hipFreeArray(hipArray* array) { - HIP_INIT_SPECIAL_API((TRACE_MEM), array); + HIP_INIT_SPECIAL_CB_API(hipFreeArray, (TRACE_MEM), array); hipError_t hipStatus = hipErrorInvalidDevicePointer; @@ -1955,7 +1955,7 @@ hipError_t hipFreeArray(hipArray* array) { } hipError_t hipMemGetAddressRange(hipDeviceptr_t* pbase, size_t* psize, hipDeviceptr_t dptr) { - HIP_INIT_API(pbase, psize, dptr); + HIP_INIT_CB_API(hipMemGetAddressRange, pbase, psize, dptr); hipError_t hipStatus = hipSuccess; hc::accelerator acc; #if (__hcc_workweek__ >= 17332) @@ -1976,7 +1976,7 @@ hipError_t hipMemGetAddressRange(hipDeviceptr_t* pbase, size_t* psize, hipDevice // TODO: IPC implementaiton: hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr) { - HIP_INIT_API(handle, devPtr); + HIP_INIT_CB_API(hipIpcGetMemHandle, handle, devPtr); hipError_t hipStatus = hipSuccess; // Get the size of allocated pointer size_t psize = 0u; @@ -2012,7 +2012,7 @@ hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr) { } hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags) { - HIP_INIT_API(devPtr, &handle, flags); + HIP_INIT_CB_API(hipIpcOpenMemHandle, devPtr, &handle, flags); hipError_t hipStatus = hipSuccess; if (devPtr == NULL) { hipStatus = hipErrorInvalidValue; @@ -2042,7 +2042,7 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned } hipError_t hipIpcCloseMemHandle(void* devPtr) { - HIP_INIT_API(devPtr); + HIP_INIT_CB_API(hipIpcCloseMemHandle, devPtr); hipError_t hipStatus = hipSuccess; if (devPtr == NULL) { hipStatus = hipErrorInvalidValue; diff --git a/src/hip_module.cpp b/src/hip_module.cpp index 1dc6701fe6..d204b41cda 100644 --- a/src/hip_module.cpp +++ b/src/hip_module.cpp @@ -96,7 +96,7 @@ string ToString(hipFunction_t v) { } hipError_t hipModuleUnload(hipModule_t hmod) { - HIP_INIT_API(hmod); + HIP_INIT_CB_API(hipModuleUnload, hmod); // TODO - improve this synchronization so it is thread-safe. // Currently we want for all inflight activity to complete, but don't prevent another @@ -230,7 +230,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, uint32_t gridDimX, uint32_t gr uint32_t gridDimZ, uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ, uint32_t sharedMemBytes, hipStream_t hStream, void** kernelParams, void** extra) { - HIP_INIT_API(f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, + HIP_INIT_CB_API(hipModuleLaunchKernel, f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, hStream, kernelParams, extra); return ihipLogStatus(ihipModuleLaunchKernel( f, blockDimX * gridDimX, blockDimY * gridDimY, gridDimZ * blockDimZ, blockDimX, blockDimY, @@ -460,13 +460,13 @@ hipError_t ihipModuleGetFunction(hipFunction_t* func, hipModule_t hmod, const ch } hipError_t hipModuleGetFunction(hipFunction_t* hfunc, hipModule_t hmod, const char* name) { - HIP_INIT_API(hfunc, hmod, name); + HIP_INIT_CB_API(hipModuleGetFunction, hfunc, hmod, name); return ihipLogStatus(ihipModuleGetFunction(hfunc, hmod, name)); } hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod, const char* name) { - HIP_INIT_API(dptr, bytes, hmod, name); + HIP_INIT_CB_API(hipModuleGetGlobal, dptr, bytes, hmod, name); if (!dptr || !bytes) return ihipLogStatus(hipErrorInvalidValue); @@ -558,12 +558,12 @@ hipError_t ihipModuleLoadData(hipModule_t* module, const void* image) { } hipError_t hipModuleLoadData(hipModule_t* module, const void* image) { - HIP_INIT_API(module, image); + HIP_INIT_CB_API(hipModuleLoadData, module, image); return ihipLogStatus(ihipModuleLoadData(module,image)); } hipError_t hipModuleLoad(hipModule_t* module, const char* fname) { - HIP_INIT_API(module, fname); + HIP_INIT_CB_API(hipModuleLoad, module, fname); if (!fname) return ihipLogStatus(hipErrorInvalidValue); @@ -578,12 +578,12 @@ hipError_t hipModuleLoad(hipModule_t* module, const char* fname) { hipError_t hipModuleLoadDataEx(hipModule_t* module, const void* image, unsigned int numOptions, hipJitOption* options, void** optionValues) { - HIP_INIT_API(module, image, numOptions, options, optionValues); + HIP_INIT_CB_API(hipModuleLoadDataEx, module, image, numOptions, options, optionValues); return ihipLogStatus(ihipModuleLoadData(module, image)); } hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const char* name) { - HIP_INIT_API(texRef, hmod, name); + HIP_INIT_CB_API(hipModuleGetTexRef, texRef, hmod, name); hipError_t ret = hipErrorNotFound; if (!texRef) return ihipLogStatus(hipErrorInvalidValue); diff --git a/src/hip_peer.cpp b/src/hip_peer.cpp index 4787355c62..97c3fd4052 100644 --- a/src/hip_peer.cpp +++ b/src/hip_peer.cpp @@ -175,21 +175,21 @@ hipError_t hipMemcpyPeerAsync(void* dst, hipCtx_t dstDevice, const void* src, hi //============================================================================= hipError_t hipDeviceCanAccessPeer(int* canAccessPeer, int deviceId, int peerDeviceId) { - HIP_INIT_API(canAccessPeer, deviceId, peerDeviceId); + HIP_INIT_CB_API(hipDeviceCanAccessPeer, canAccessPeer, deviceId, peerDeviceId); return ihipLogStatus(ihipDeviceCanAccessPeer(canAccessPeer, ihipGetPrimaryCtx(deviceId), ihipGetPrimaryCtx(peerDeviceId))); } hipError_t hipDeviceDisablePeerAccess(int peerDeviceId) { - HIP_INIT_API(peerDeviceId); + HIP_INIT_CB_API(hipDeviceDisablePeerAccess, peerDeviceId); return ihipLogStatus(ihipDisablePeerAccess(ihipGetPrimaryCtx(peerDeviceId))); } hipError_t hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags) { - HIP_INIT_API(peerDeviceId, flags); + HIP_INIT_CB_API(hipDeviceEnablePeerAccess, peerDeviceId, flags); return ihipLogStatus(ihipEnablePeerAccess(ihipGetPrimaryCtx(peerDeviceId), flags)); } @@ -197,7 +197,7 @@ hipError_t hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags) { hipError_t hipMemcpyPeer(void* dst, int dstDevice, const void* src, int srcDevice, size_t sizeBytes) { - HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes); + HIP_INIT_CB_API(hipMemcpyPeer, dst, dstDevice, src, srcDevice, sizeBytes); return ihipLogStatus(hipMemcpyPeer(dst, ihipGetPrimaryCtx(dstDevice), src, ihipGetPrimaryCtx(srcDevice), sizeBytes)); } @@ -205,18 +205,18 @@ hipError_t hipMemcpyPeer(void* dst, int dstDevice, const void* src, int srcDevic hipError_t hipMemcpyPeerAsync(void* dst, int dstDevice, const void* src, int srcDevice, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes, stream); + HIP_INIT_CB_API(hipMemcpyPeerAsync, dst, dstDevice, src, srcDevice, sizeBytes, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDefault, stream)); } hipError_t hipCtxEnablePeerAccess(hipCtx_t peerCtx, unsigned int flags) { - HIP_INIT_API(peerCtx, flags); + HIP_INIT_CB_API(hipCtxEnablePeerAccess, peerCtx, flags); return ihipLogStatus(ihipEnablePeerAccess(peerCtx, flags)); } hipError_t hipCtxDisablePeerAccess(hipCtx_t peerCtx) { - HIP_INIT_API(peerCtx); + HIP_INIT_CB_API(hipCtxDisablePeerAccess, peerCtx); return ihipLogStatus(ihipDisablePeerAccess(peerCtx)); } diff --git a/src/hip_stream.cpp b/src/hip_stream.cpp index 2268a203dd..c710aba6c8 100644 --- a/src/hip_stream.cpp +++ b/src/hip_stream.cpp @@ -90,14 +90,14 @@ hipError_t ihipStreamCreate(hipStream_t* stream, unsigned int flags, int priorit //--- hipError_t hipStreamCreateWithFlags(hipStream_t* stream, unsigned int flags) { - HIP_INIT_API(stream, flags); + HIP_INIT_CB_API(hipStreamCreateWithFlags, stream, flags); return ihipLogStatus(ihipStreamCreate(stream, flags, priority_normal)); } //--- hipError_t hipStreamCreate(hipStream_t* stream) { - HIP_INIT_API(stream); + HIP_INIT_CB_API(hipStreamCreate, stream); return ihipLogStatus(ihipStreamCreate(stream, hipStreamDefault, priority_normal)); } @@ -121,7 +121,7 @@ hipError_t hipDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPrio } hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int flags) { - HIP_INIT_SPECIAL_API(TRACE_SYNC, stream, event, flags); + HIP_INIT_SPECIAL_CB_API(hipStreamWaitEvent, TRACE_SYNC, stream, event, flags); hipError_t e = hipSuccess; @@ -152,7 +152,7 @@ hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int //--- hipError_t hipStreamQuery(hipStream_t stream) { - HIP_INIT_SPECIAL_API(TRACE_QUERY, stream); + HIP_INIT_SPECIAL_CB_API(hipStreamQuery, TRACE_QUERY, stream); // Use default stream if 0 specified: if (stream == hipStreamNull) { @@ -175,7 +175,7 @@ hipError_t hipStreamQuery(hipStream_t stream) { //--- hipError_t hipStreamSynchronize(hipStream_t stream) { - HIP_INIT_SPECIAL_API(TRACE_SYNC, stream); + HIP_INIT_SPECIAL_CB_API(hipStreamSynchronize, TRACE_SYNC, stream); return ihipLogStatus(ihipStreamSynchronize(stream)); } @@ -186,7 +186,7 @@ hipError_t hipStreamSynchronize(hipStream_t stream) { * @return #hipSuccess, #hipErrorInvalidResourceHandle */ hipError_t hipStreamDestroy(hipStream_t stream) { - HIP_INIT_API(stream); + HIP_INIT_CB_API(hipStreamDestroy, stream); hipError_t e = hipSuccess; @@ -214,7 +214,7 @@ hipError_t hipStreamDestroy(hipStream_t stream) { //--- hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int* flags) { - HIP_INIT_API(stream, flags); + HIP_INIT_CB_API(hipStreamGetFlags, stream, flags); if (flags == NULL) { return ihipLogStatus(hipErrorInvalidValue); @@ -250,7 +250,7 @@ hipError_t hipStreamGetPriority(hipStream_t stream, int* priority) { //--- hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback, void* userData, unsigned int flags) { - HIP_INIT_API(stream, callback, userData, flags); + HIP_INIT_CB_API(hipStreamAddCallback, stream, callback, userData, flags); hipError_t e = hipSuccess; // Create a thread in detached mode to handle callback From ec989ffd963012a4dc5289dcd597203805505a80 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 7 Aug 2018 07:54:04 -0500 Subject: [PATCH 19/55] fix --- include/hip/hip_prof_api.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/hip/hip_prof_api.h b/include/hip/hip_prof_api.h index 3ab7a4d303..43dc146636 100644 --- a/include/hip/hip_prof_api.h +++ b/include/hip/hip_prof_api.h @@ -3,6 +3,7 @@ #define _HIP_PROF_API_H #include +#include #include #include "hip/hip_prof_str.h" From 5d6a6a5c6c49510b02a604d5f5608edfcb09e65e Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 26 Aug 2018 14:26:27 -0500 Subject: [PATCH 20/55] compilation fix - struct name fix --- include/hip/hip_prof_str.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hip/hip_prof_str.h b/include/hip/hip_prof_str.h index 43789104ba..80bb1049c4 100644 --- a/include/hip/hip_prof_str.h +++ b/include/hip/hip_prof_str.h @@ -294,7 +294,7 @@ static const char* hip_api_name(const uint32_t& id) { }; // HIP API callbacks data structure -struct hip_cb_data_t { +struct hip_api_data_t { uint64_t correlation_id; uint32_t phase; union { @@ -1522,7 +1522,7 @@ struct hip_cb_data_t { #if 0 // HIP API string method, method name and parameters -const char* hipApiString(hip_cb_id_t id, const hip_cb_data_t* data) { +const char* hipApiString(hip_api_id_t id, const hip_api_data_t* data) { std::ostringstream oss; switch (id) { case HIP_API_ID_hipHostFree: From cba2d42bbfd198c8eb62a29b004f9a094a0cbfe8 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 26 Aug 2018 17:34:26 -0500 Subject: [PATCH 21/55] adding lost i the merge change --- src/hip_module.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hip_module.cpp b/src/hip_module.cpp index d204b41cda..539fbed9af 100644 --- a/src/hip_module.cpp +++ b/src/hip_module.cpp @@ -84,6 +84,7 @@ string ToString(hipFunction_t v) { return ss.str(); }; +std::string& FunctionSymbol(hipFunction_t f) { return f->_name; }; #define CHECK_HSA(hsaStatus, hipStatus) \ if (hsaStatus != HSA_STATUS_SUCCESS) { \ From 47f1d059d116d6117b54838573c2d0b6c05708ce Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 8 Nov 2018 04:58:29 -0600 Subject: [PATCH 22/55] hip_prof_(api/str).h moving under hcc_detail dir --- include/hip/{ => hcc_detail}/hip_prof_api.h | 2 +- include/hip/{ => hcc_detail}/hip_prof_str.h | 0 include/hip/hcc_detail/hip_runtime_api.h | 2 +- src/hip_intercept.cpp | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename include/hip/{ => hcc_detail}/hip_prof_api.h (99%) rename include/hip/{ => hcc_detail}/hip_prof_str.h (100%) diff --git a/include/hip/hip_prof_api.h b/include/hip/hcc_detail/hip_prof_api.h similarity index 99% rename from include/hip/hip_prof_api.h rename to include/hip/hcc_detail/hip_prof_api.h index 43dc146636..98154873f3 100644 --- a/include/hip/hip_prof_api.h +++ b/include/hip/hcc_detail/hip_prof_api.h @@ -6,7 +6,7 @@ #include #include -#include "hip/hip_prof_str.h" +#include "hip/hcc_detail/hip_prof_str.h" template class api_callbacks_table_templ { diff --git a/include/hip/hip_prof_str.h b/include/hip/hcc_detail/hip_prof_str.h similarity index 100% rename from include/hip/hip_prof_str.h rename to include/hip/hcc_detail/hip_prof_str.h diff --git a/include/hip/hcc_detail/hip_runtime_api.h b/include/hip/hcc_detail/hip_runtime_api.h index f95e44f610..ceafee9212 100644 --- a/include/hip/hcc_detail/hip_runtime_api.h +++ b/include/hip/hcc_detail/hip_runtime_api.h @@ -2581,7 +2581,7 @@ hipError_t hipLaunchByPtr(const void* func); } /* extern "c" */ #endif -#include +#include #ifdef __cplusplus extern "C" { diff --git a/src/hip_intercept.cpp b/src/hip_intercept.cpp index d2fffb9ef8..459b360f2c 100644 --- a/src/hip_intercept.cpp +++ b/src/hip_intercept.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ #include "hip/hip_runtime.h" -#include "hip/hip_prof_api.h" +#include "hip/hcc_detail/hip_prof_api.h" // HIP API callback/activity From e5ba097afd71d0b25de5aabf8518926109b2ef8c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 8 Nov 2018 08:36:50 -0600 Subject: [PATCH 23/55] renaming HIP_INIT_CB_API to HIP_INIT_API --- include/hip/hcc_detail/hip_prof_api.h | 8 +- include/hip/hcc_detail/hip_prof_str.h | 65 ++++++++++++++++ src/hip_context.cpp | 46 ++++++------ src/hip_device.cpp | 40 +++++----- src/hip_error.cpp | 8 +- src/hip_event.cpp | 14 ++-- src/hip_hcc.cpp | 8 +- src/hip_hcc_internal.h | 12 +-- src/hip_memory.cpp | 102 +++++++++++++------------- src/hip_module.cpp | 18 ++--- src/hip_peer.cpp | 20 ++--- src/hip_stream.cpp | 16 ++-- src/hip_surface.cpp | 4 +- src/hip_texture.cpp | 40 +++++----- 14 files changed, 230 insertions(+), 171 deletions(-) diff --git a/include/hip/hcc_detail/hip_prof_api.h b/include/hip/hcc_detail/hip_prof_api.h index 98154873f3..8589bc0ee6 100644 --- a/include/hip/hcc_detail/hip_prof_api.h +++ b/include/hip/hcc_detail/hip_prof_api.h @@ -127,9 +127,11 @@ typedef activity_sync_callback_t hip_act_callback_t; // HIP API callbacks spawner object macro #define HIP_CB_SPAWNER_OBJECT(CB_ID) \ - hip_api_data_t api_data{}; \ - INIT_CB_ARGS_DATA(CB_ID, api_data); \ - api_callbacks_spawner_t __api_tracer(HIP_API_ID_##CB_ID, api_data); + if (HIP_API_ID_##CB_ID < HIP_API_ID_NUMBER) { \ + hip_api_data_t api_data{}; \ + INIT_CB_ARGS_DATA(CB_ID, api_data); \ + api_callbacks_spawner_t __api_tracer(HIP_API_ID_##CB_ID, api_data); \ + } typedef api_callbacks_table_templ #include +// Dummy API callbacks definition +#define INIT_hipHccModuleLaunchKernel_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipHccGetAccelerator_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipHccGetAcceleratorView_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipDeviceCanAccessPeer2_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipMemcpyPeer2_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipMemcpyPeerAsync2_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipCreateTextureObject_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipDestroyTextureObject_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipGetTextureObjectResourceDesc_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipGetTextureObjectResourceViewDesc_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipGetTextureObjectTextureDesc_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipBindTexture_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipBindTexture2D_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipBindTextureToArray_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipBindTextureToMipmappedArray_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipUnbindTexture_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipGetChannelDesc_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipGetTextureAlignmentOffset_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipGetTextureReference_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipTexRefSetFormat_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipTexRefSetFlags_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipTexRefSetFilterMode_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipTexRefSetAddressMode_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipTexRefSetArray_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipTexRefSetAddress_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipTexRefSetAddress2D_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipMemcpyHtoH_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipGetErrorName_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipGetErrorString_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipCreateSurfaceObject_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipDestroySurfaceObject_CB_ARGS_DATA(cb_data) {}; + // HIP API callbacks ID enumaration enum hip_api_id_t { HIP_API_ID_hipHostFree = 0, @@ -146,6 +179,38 @@ enum hip_api_id_t { HIP_API_ID_hipGetDeviceCount = 137, HIP_API_ID_NUMBER = 138, HIP_API_ID_ANY = 139, + + HIP_API_ID_hipHccModuleLaunchKernel = HIP_API_ID_NUMBER, + HIP_API_ID_hipHccGetAccelerator = HIP_API_ID_NUMBER, + HIP_API_ID_hipHccGetAcceleratorView = HIP_API_ID_NUMBER, + HIP_API_ID_hipDeviceCanAccessPeer2 = HIP_API_ID_NUMBER, + HIP_API_ID_hipMemcpyPeer2 = HIP_API_ID_NUMBER, + HIP_API_ID_hipMemcpyPeerAsync2 = HIP_API_ID_NUMBER, + HIP_API_ID_hipCreateTextureObject = HIP_API_ID_NUMBER, + HIP_API_ID_hipDestroyTextureObject = HIP_API_ID_NUMBER, + HIP_API_ID_hipGetTextureObjectResourceDesc = HIP_API_ID_NUMBER, + HIP_API_ID_hipGetTextureObjectResourceViewDesc = HIP_API_ID_NUMBER, + HIP_API_ID_hipGetTextureObjectTextureDesc = HIP_API_ID_NUMBER, + HIP_API_ID_hipBindTexture = HIP_API_ID_NUMBER, + HIP_API_ID_hipBindTexture2D = HIP_API_ID_NUMBER, + HIP_API_ID_hipBindTextureToArray = HIP_API_ID_NUMBER, + HIP_API_ID_hipBindTextureToMipmappedArray = HIP_API_ID_NUMBER, + HIP_API_ID_hipUnbindTexture = HIP_API_ID_NUMBER, + HIP_API_ID_hipGetChannelDesc = HIP_API_ID_NUMBER, + HIP_API_ID_hipGetTextureAlignmentOffset = HIP_API_ID_NUMBER, + HIP_API_ID_hipGetTextureReference = HIP_API_ID_NUMBER, + HIP_API_ID_hipTexRefSetFormat = HIP_API_ID_NUMBER, + HIP_API_ID_hipTexRefSetFlags = HIP_API_ID_NUMBER, + HIP_API_ID_hipTexRefSetFilterMode = HIP_API_ID_NUMBER, + HIP_API_ID_hipTexRefSetAddressMode = HIP_API_ID_NUMBER, + HIP_API_ID_hipTexRefSetArray = HIP_API_ID_NUMBER, + HIP_API_ID_hipTexRefSetAddress = HIP_API_ID_NUMBER, + HIP_API_ID_hipTexRefSetAddress2D = HIP_API_ID_NUMBER, + HIP_API_ID_hipMemcpyHtoH = HIP_API_ID_NUMBER, + HIP_API_ID_hipGetErrorName = HIP_API_ID_NUMBER, + HIP_API_ID_hipGetErrorString = HIP_API_ID_NUMBER, + HIP_API_ID_hipCreateSurfaceObject = HIP_API_ID_NUMBER, + HIP_API_ID_hipDestroySurfaceObject = HIP_API_ID_NUMBER, }; // Return HIP API string diff --git a/src/hip_context.cpp b/src/hip_context.cpp index f03d3bc7b5..e85c406cfc 100644 --- a/src/hip_context.cpp +++ b/src/hip_context.cpp @@ -40,7 +40,7 @@ void ihipCtxStackUpdate() { } hipError_t hipInit(unsigned int flags) { - HIP_INIT_CB_API(hipInit, flags); + HIP_INIT_API(hipInit, flags); hipError_t e = hipSuccess; @@ -53,7 +53,7 @@ hipError_t hipInit(unsigned int flags) { } hipError_t hipCtxCreate(hipCtx_t* ctx, unsigned int flags, hipDevice_t device) { - HIP_INIT_CB_API(hipCtxCreate, ctx, flags, device); // FIXME - review if we want to init + HIP_INIT_API(hipCtxCreate, ctx, flags, device); // FIXME - review if we want to init hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(device); { @@ -71,7 +71,7 @@ hipError_t hipCtxCreate(hipCtx_t* ctx, unsigned int flags, hipDevice_t device) { } hipError_t hipDeviceGet(hipDevice_t* device, int deviceId) { - HIP_INIT_CB_API(hipDeviceGet, device, deviceId); // FIXME - review if we want to init + HIP_INIT_API(hipDeviceGet, device, deviceId); // FIXME - review if we want to init auto deviceHandle = ihipGetDevice(deviceId); @@ -86,7 +86,7 @@ hipError_t hipDeviceGet(hipDevice_t* device, int deviceId) { }; hipError_t hipDriverGetVersion(int* driverVersion) { - HIP_INIT_CB_API(hipDriverGetVersion, driverVersion); + HIP_INIT_API(hipDriverGetVersion, driverVersion); hipError_t e = hipSuccess; if (driverVersion) { *driverVersion = 4; @@ -98,7 +98,7 @@ hipError_t hipDriverGetVersion(int* driverVersion) { } hipError_t hipRuntimeGetVersion(int* runtimeVersion) { - HIP_INIT_CB_API(hipRuntimeGetVersion, runtimeVersion); + HIP_INIT_API(hipRuntimeGetVersion, runtimeVersion); hipError_t e = hipSuccess; if (runtimeVersion) { *runtimeVersion = HIP_VERSION_PATCH; @@ -110,7 +110,7 @@ hipError_t hipRuntimeGetVersion(int* runtimeVersion) { } hipError_t hipCtxDestroy(hipCtx_t ctx) { - HIP_INIT_CB_API(hipCtxDestroy, ctx); + HIP_INIT_API(hipCtxDestroy, ctx); hipError_t e = hipSuccess; ihipCtx_t* currentCtx = ihipGetTlsDefaultCtx(); ihipCtx_t* primaryCtx = ((ihipDevice_t*)ctx->getDevice())->_primaryCtx; @@ -134,7 +134,7 @@ hipError_t hipCtxDestroy(hipCtx_t ctx) { } hipError_t hipCtxPopCurrent(hipCtx_t* ctx) { - HIP_INIT_CB_API(hipCtxPopCurrent, ctx); + HIP_INIT_API(hipCtxPopCurrent, ctx); hipError_t e = hipSuccess; ihipCtx_t* currentCtx = ihipGetTlsDefaultCtx(); auto deviceHandle = currentCtx->getDevice(); @@ -155,7 +155,7 @@ hipError_t hipCtxPopCurrent(hipCtx_t* ctx) { } hipError_t hipCtxPushCurrent(hipCtx_t ctx) { - HIP_INIT_CB_API(hipCtxPushCurrent, ctx); + HIP_INIT_API(hipCtxPushCurrent, ctx); hipError_t e = hipSuccess; if (ctx != NULL) { // TODO- is this check needed? ihipSetTlsDefaultCtx(ctx); @@ -168,7 +168,7 @@ hipError_t hipCtxPushCurrent(hipCtx_t ctx) { } hipError_t hipCtxGetCurrent(hipCtx_t* ctx) { - HIP_INIT_CB_API(hipCtxGetCurrent, ctx); + HIP_INIT_API(hipCtxGetCurrent, ctx); hipError_t e = hipSuccess; if ((tls_getPrimaryCtx) || tls_ctxStack.empty()) { *ctx = ihipGetTlsDefaultCtx(); @@ -179,7 +179,7 @@ hipError_t hipCtxGetCurrent(hipCtx_t* ctx) { } hipError_t hipCtxSetCurrent(hipCtx_t ctx) { - HIP_INIT_CB_API(hipCtxSetCurrent, ctx); + HIP_INIT_API(hipCtxSetCurrent, ctx); hipError_t e = hipSuccess; if (ctx == NULL) { tls_ctxStack.pop(); @@ -192,7 +192,7 @@ hipError_t hipCtxSetCurrent(hipCtx_t ctx) { } hipError_t hipCtxGetDevice(hipDevice_t* device) { - HIP_INIT_CB_API(hipCtxGetDevice, device); + HIP_INIT_API(hipCtxGetDevice, device); hipError_t e = hipSuccess; ihipCtx_t* ctx = ihipGetTlsDefaultCtx(); @@ -208,7 +208,7 @@ hipError_t hipCtxGetDevice(hipDevice_t* device) { } hipError_t hipCtxGetApiVersion(hipCtx_t ctx, int* apiVersion) { - HIP_INIT_CB_API(hipCtxGetApiVersion, apiVersion); + HIP_INIT_API(hipCtxGetApiVersion, apiVersion); if (apiVersion) { *apiVersion = 4; @@ -218,7 +218,7 @@ hipError_t hipCtxGetApiVersion(hipCtx_t ctx, int* apiVersion) { } hipError_t hipCtxGetCacheConfig(hipFuncCache_t* cacheConfig) { - HIP_INIT_CB_API(hipCtxGetCacheConfig, cacheConfig); + HIP_INIT_API(hipCtxGetCacheConfig, cacheConfig); *cacheConfig = hipFuncCachePreferNone; @@ -226,7 +226,7 @@ hipError_t hipCtxGetCacheConfig(hipFuncCache_t* cacheConfig) { } hipError_t hipCtxSetCacheConfig(hipFuncCache_t cacheConfig) { - HIP_INIT_CB_API(hipCtxSetCacheConfig, cacheConfig); + HIP_INIT_API(hipCtxSetCacheConfig, cacheConfig); // Nop, AMD does not support variable cache configs. @@ -234,7 +234,7 @@ hipError_t hipCtxSetCacheConfig(hipFuncCache_t cacheConfig) { } hipError_t hipCtxSetSharedMemConfig(hipSharedMemConfig config) { - HIP_INIT_CB_API(hipCtxSetSharedMemConfig, config); + HIP_INIT_API(hipCtxSetSharedMemConfig, config); // Nop, AMD does not support variable shared mem configs. @@ -242,7 +242,7 @@ hipError_t hipCtxSetSharedMemConfig(hipSharedMemConfig config) { } hipError_t hipCtxGetSharedMemConfig(hipSharedMemConfig* pConfig) { - HIP_INIT_CB_API(hipCtxGetSharedMemConfig, pConfig); + HIP_INIT_API(hipCtxGetSharedMemConfig, pConfig); *pConfig = hipSharedMemBankSizeFourByte; @@ -250,12 +250,12 @@ hipError_t hipCtxGetSharedMemConfig(hipSharedMemConfig* pConfig) { } hipError_t hipCtxSynchronize(void) { - HIP_INIT_CB_API(hipCtxSynchronize, 1); + HIP_INIT_API(hipCtxSynchronize, 1); return ihipLogStatus(ihipSynchronize()); // TODP Shall check validity of ctx? } hipError_t hipCtxGetFlags(unsigned int* flags) { - HIP_INIT_CB_API(hipCtxGetFlags, flags); + HIP_INIT_API(hipCtxGetFlags, flags); hipError_t e = hipSuccess; ihipCtx_t* tempCtx; tempCtx = ihipGetTlsDefaultCtx(); @@ -264,7 +264,7 @@ hipError_t hipCtxGetFlags(unsigned int* flags) { } hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int* flags, int* active) { - HIP_INIT_CB_API(hipDevicePrimaryCtxGetState, dev, flags, active); + HIP_INIT_API(hipDevicePrimaryCtxGetState, dev, flags, active); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(dev); @@ -286,7 +286,7 @@ hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int* flags, int } hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev) { - HIP_INIT_CB_API(hipDevicePrimaryCtxRelease, dev); + HIP_INIT_API(hipDevicePrimaryCtxRelease, dev); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(dev); @@ -297,7 +297,7 @@ hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev) { } hipError_t hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev) { - HIP_INIT_CB_API(hipDevicePrimaryCtxRetain, pctx, dev); + HIP_INIT_API(hipDevicePrimaryCtxRetain, pctx, dev); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(dev); @@ -309,7 +309,7 @@ hipError_t hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev) { } hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev) { - HIP_INIT_CB_API(hipDevicePrimaryCtxReset, dev); + HIP_INIT_API(hipDevicePrimaryCtxReset, dev); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(dev); @@ -322,7 +322,7 @@ hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev) { } hipError_t hipDevicePrimaryCtxSetFlags(hipDevice_t dev, unsigned int flags) { - HIP_INIT_CB_API(hipDevicePrimaryCtxSetFlags, dev, flags); + HIP_INIT_API(hipDevicePrimaryCtxSetFlags, dev, flags); hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(dev); diff --git a/src/hip_device.cpp b/src/hip_device.cpp index 4d45f441e8..246ce8cf6f 100644 --- a/src/hip_device.cpp +++ b/src/hip_device.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. //------------------------------------------------------------------------------------------------- // TODO - does this initialize HIP runtime? hipError_t hipGetDevice(int* deviceId) { - HIP_INIT_CB_API(hipGetDevice, deviceId); + HIP_INIT_API(hipGetDevice, deviceId); hipError_t e = hipSuccess; @@ -69,12 +69,12 @@ hipError_t ihipGetDeviceCount(int* count) { } hipError_t hipGetDeviceCount(int* count) { - HIP_INIT_CB_API(hipGetDeviceCount, count); + HIP_INIT_API(hipGetDeviceCount, count); return ihipLogStatus(ihipGetDeviceCount(count)); } hipError_t hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig) { - HIP_INIT_CB_API(hipDeviceSetCacheConfig, cacheConfig); + HIP_INIT_API(hipDeviceSetCacheConfig, cacheConfig); // Nop, AMD does not support variable cache configs. @@ -82,7 +82,7 @@ hipError_t hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig) { } hipError_t hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig) { - HIP_INIT_CB_API(hipDeviceGetCacheConfig, cacheConfig); + HIP_INIT_API(hipDeviceGetCacheConfig, cacheConfig); if (cacheConfig == nullptr) { return ihipLogStatus(hipErrorInvalidValue); @@ -94,7 +94,7 @@ hipError_t hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig) { } hipError_t hipDeviceGetLimit(size_t* pValue, hipLimit_t limit) { - HIP_INIT_CB_API(hipDeviceGetLimit, pValue, limit); + HIP_INIT_API(hipDeviceGetLimit, pValue, limit); if (pValue == nullptr) { return ihipLogStatus(hipErrorInvalidValue); } @@ -107,7 +107,7 @@ hipError_t hipDeviceGetLimit(size_t* pValue, hipLimit_t limit) { } hipError_t hipFuncSetCacheConfig(const void* func, hipFuncCache_t cacheConfig) { - HIP_INIT_CB_API(hipFuncSetCacheConfig, cacheConfig); + HIP_INIT_API(hipFuncSetCacheConfig, cacheConfig); // Nop, AMD does not support variable cache configs. @@ -115,7 +115,7 @@ hipError_t hipFuncSetCacheConfig(const void* func, hipFuncCache_t cacheConfig) { } hipError_t hipDeviceSetSharedMemConfig(hipSharedMemConfig config) { - HIP_INIT_CB_API(hipDeviceSetSharedMemConfig, config); + HIP_INIT_API(hipDeviceSetSharedMemConfig, config); // Nop, AMD does not support variable shared mem configs. @@ -123,7 +123,7 @@ hipError_t hipDeviceSetSharedMemConfig(hipSharedMemConfig config) { } hipError_t hipDeviceGetSharedMemConfig(hipSharedMemConfig* pConfig) { - HIP_INIT_CB_API(hipDeviceGetSharedMemConfig, pConfig); + HIP_INIT_API(hipDeviceGetSharedMemConfig, pConfig); *pConfig = hipSharedMemBankSizeFourByte; @@ -131,7 +131,7 @@ hipError_t hipDeviceGetSharedMemConfig(hipSharedMemConfig* pConfig) { } hipError_t hipSetDevice(int deviceId) { - HIP_INIT_CB_API(hipSetDevice, deviceId); + HIP_INIT_API(hipSetDevice, deviceId); if ((deviceId < 0) || (deviceId >= g_deviceCnt)) { return ihipLogStatus(hipErrorInvalidDevice); } else { @@ -142,12 +142,12 @@ hipError_t hipSetDevice(int deviceId) { } hipError_t hipDeviceSynchronize(void) { - HIP_INIT_SPECIAL_CB_API(hipDeviceSynchronize, TRACE_SYNC); + HIP_INIT_SPECIAL_API(hipDeviceSynchronize, TRACE_SYNC); return ihipLogStatus(ihipSynchronize()); } hipError_t hipDeviceReset(void) { - HIP_INIT_CB_API(hipDeviceReset, ); + HIP_INIT_API(hipDeviceReset, ); auto* ctx = ihipGetTlsDefaultCtx(); @@ -287,7 +287,7 @@ hipError_t ihipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device } hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) { - HIP_INIT_CB_API(hipDeviceGetAttribute, pi, attr, device); + HIP_INIT_API(hipDeviceGetAttribute, pi, attr, device); if ((device < 0) || (device >= g_deviceCnt)) { return ihipLogStatus(hipErrorInvalidDevice); } @@ -314,7 +314,7 @@ hipError_t ihipGetDeviceProperties(hipDeviceProp_t* props, int device) { } hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device) { - HIP_INIT_CB_API(hipGetDeviceProperties, props, device); + HIP_INIT_API(hipGetDeviceProperties, props, device); if ((device < 0) || (device >= g_deviceCnt)) { return ihipLogStatus(hipErrorInvalidDevice); } @@ -322,7 +322,7 @@ hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device) { } hipError_t hipSetDeviceFlags(unsigned int flags) { - HIP_INIT_CB_API(hipSetDeviceFlags, flags); + HIP_INIT_API(hipSetDeviceFlags, flags); hipError_t e = hipSuccess; @@ -367,7 +367,7 @@ hipError_t hipSetDeviceFlags(unsigned int flags) { }; hipError_t hipDeviceComputeCapability(int* major, int* minor, hipDevice_t device) { - HIP_INIT_CB_API(hipDeviceComputeCapability, major, minor, device); + HIP_INIT_API(hipDeviceComputeCapability, major, minor, device); hipError_t e = hipSuccess; if ((device < 0) || (device >= g_deviceCnt)) { e = hipErrorInvalidDevice; @@ -380,7 +380,7 @@ hipError_t hipDeviceComputeCapability(int* major, int* minor, hipDevice_t device hipError_t hipDeviceGetName(char* name, int len, hipDevice_t device) { // Cast to void* here to avoid printing garbage in debug modes. - HIP_INIT_CB_API(hipDeviceGetName, (void*)name, len, device); + HIP_INIT_API(hipDeviceGetName, (void*)name, len, device); hipError_t e = hipSuccess; if ((device < 0) || (device >= g_deviceCnt)) { e = hipErrorInvalidDevice; @@ -394,7 +394,7 @@ hipError_t hipDeviceGetName(char* name, int len, hipDevice_t device) { hipError_t hipDeviceGetPCIBusId(char* pciBusId, int len, int device) { // Cast to void* here to avoid printing garbage in debug modes. - HIP_INIT_CB_API(hipDeviceGetPCIBusId, (void*)pciBusId, len, device); + HIP_INIT_API(hipDeviceGetPCIBusId, (void*)pciBusId, len, device); hipError_t e = hipErrorInvalidValue; if ((device < 0) || (device >= g_deviceCnt)) { e = hipErrorInvalidDevice; @@ -413,7 +413,7 @@ hipError_t hipDeviceGetPCIBusId(char* pciBusId, int len, int device) { } hipError_t hipDeviceTotalMem(size_t* bytes, hipDevice_t device) { - HIP_INIT_CB_API(hipDeviceTotalMem, bytes, device); + HIP_INIT_API(hipDeviceTotalMem, bytes, device); hipError_t e = hipSuccess; if ((device < 0) || (device >= g_deviceCnt)) { e = hipErrorInvalidDevice; @@ -425,7 +425,7 @@ hipError_t hipDeviceTotalMem(size_t* bytes, hipDevice_t device) { } hipError_t hipDeviceGetByPCIBusId(int* device, const char* pciBusId) { - HIP_INIT_CB_API(hipDeviceGetByPCIBusId, device, pciBusId); + HIP_INIT_API(hipDeviceGetByPCIBusId, device, pciBusId); hipDeviceProp_t tempProp; int deviceCount = 0; hipError_t e = hipErrorInvalidValue; @@ -451,7 +451,7 @@ hipError_t hipDeviceGetByPCIBusId(int* device, const char* pciBusId) { } hipError_t hipChooseDevice(int* device, const hipDeviceProp_t* prop) { - HIP_INIT_CB_API(hipChooseDevice, device, prop); + HIP_INIT_API(hipChooseDevice, device, prop); hipDeviceProp_t tempProp; hipError_t e = hipSuccess; if ((device == NULL) || (prop == NULL)) { diff --git a/src/hip_error.cpp b/src/hip_error.cpp index ec1e2fbb02..6f1184d92f 100644 --- a/src/hip_error.cpp +++ b/src/hip_error.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. //--- hipError_t hipGetLastError() { - HIP_INIT_CB_API(hipGetLastError); + HIP_INIT_API(hipGetLastError); // Return last error, but then reset the state: hipError_t e = ihipLogStatus(tls_lastHipError); @@ -39,20 +39,20 @@ hipError_t hipGetLastError() { } hipError_t hipPeekAtLastError() { - HIP_INIT_CB_API(hipPeekAtLastError); + HIP_INIT_API(hipPeekAtLastError); // peek at last error, but don't reset it. return ihipLogStatus(tls_lastHipError); } const char* hipGetErrorName(hipError_t hip_error) { - HIP_INIT_API(hip_error); + HIP_INIT_API(hipGetErrorName, hip_error); return ihipErrorString(hip_error); } const char* hipGetErrorString(hipError_t hip_error) { - HIP_INIT_API(hip_error); + HIP_INIT_API(hipGetErrorString, hip_error); // TODO - return a message explaining the error. // TODO - This should be set up to return the same string reported in the the doxygen comments, diff --git a/src/hip_event.cpp b/src/hip_event.cpp index 206ad16a79..ea014ab292 100644 --- a/src/hip_event.cpp +++ b/src/hip_event.cpp @@ -95,20 +95,20 @@ hipError_t ihipEventCreate(hipEvent_t* event, unsigned flags) { } hipError_t hipEventCreateWithFlags(hipEvent_t* event, unsigned flags) { - HIP_INIT_CB_API(hipEventCreateWithFlags, event, flags); + HIP_INIT_API(hipEventCreateWithFlags, event, flags); return ihipLogStatus(ihipEventCreate(event, flags)); } hipError_t hipEventCreate(hipEvent_t* event) { - HIP_INIT_CB_API(hipEventCreate, event); + HIP_INIT_API(hipEventCreate, event); return ihipLogStatus(ihipEventCreate(event, 0)); } hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipEventRecord, TRACE_SYNC, event, stream); + HIP_INIT_SPECIAL_API(hipEventRecord, TRACE_SYNC, event, stream); auto ecd = event->locked_copyCrit(); @@ -153,7 +153,7 @@ hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) { hipError_t hipEventDestroy(hipEvent_t event) { - HIP_INIT_CB_API(hipEventDestroy, event); + HIP_INIT_API(hipEventDestroy, event); if (event) { delete event; @@ -165,7 +165,7 @@ hipError_t hipEventDestroy(hipEvent_t event) { } hipError_t hipEventSynchronize(hipEvent_t event) { - HIP_INIT_SPECIAL_CB_API(hipEventSynchronize, TRACE_SYNC, event); + HIP_INIT_SPECIAL_API(hipEventSynchronize, TRACE_SYNC, event); if (!(event->_flags & hipEventReleaseToSystem)) { tprintf(DB_WARN, @@ -198,7 +198,7 @@ hipError_t hipEventSynchronize(hipEvent_t event) { } hipError_t hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop) { - HIP_INIT_CB_API(hipEventElapsedTime, ms, start, stop); + HIP_INIT_API(hipEventElapsedTime, ms, start, stop); hipError_t status = hipSuccess; @@ -255,7 +255,7 @@ hipError_t hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop) { } hipError_t hipEventQuery(hipEvent_t event) { - HIP_INIT_SPECIAL_CB_API(hipEventQuery, TRACE_QUERY, event); + HIP_INIT_SPECIAL_API(hipEventQuery, TRACE_QUERY, event); if (!(event->_flags & hipEventReleaseToSystem)) { tprintf(DB_WARN, diff --git a/src/hip_hcc.cpp b/src/hip_hcc.cpp index ab25a04795..f99d171efa 100644 --- a/src/hip_hcc.cpp +++ b/src/hip_hcc.cpp @@ -2288,7 +2288,7 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes //------------------------------------------------------------------------------------------------- // Profiler, really these should live elsewhere: hipError_t hipProfilerStart() { - HIP_INIT_CB_API(hipProfilerStart); + HIP_INIT_API(hipProfilerStart); #if COMPILE_HIP_ATP_MARKER amdtResumeProfiling(AMDT_ALL_PROFILING); #endif @@ -2298,7 +2298,7 @@ hipError_t hipProfilerStart() { hipError_t hipProfilerStop() { - HIP_INIT_CB_API(hipProfilerStop); + HIP_INIT_API(hipProfilerStop); #if COMPILE_HIP_ATP_MARKER amdtStopProfiling(AMDT_ALL_PROFILING); #endif @@ -2313,7 +2313,7 @@ hipError_t hipProfilerStop() { //--- hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator* acc) { - HIP_INIT_API(deviceId, acc); + HIP_INIT_API(hipHccGetAccelerator, deviceId, acc); const ihipDevice_t* device = ihipGetDevice(deviceId); hipError_t err; @@ -2329,7 +2329,7 @@ hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator* acc) { //--- hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view** av) { - HIP_INIT_API(stream, av); + HIP_INIT_API(hipHccGetAcceleratorView, stream, av); if (stream == hipStreamNull) { ihipCtx_t* device = ihipGetTlsDefaultCtx(); diff --git a/src/hip_hcc_internal.h b/src/hip_hcc_internal.h index b9667776d3..bc407c3df5 100644 --- a/src/hip_hcc_internal.h +++ b/src/hip_hcc_internal.h @@ -297,11 +297,7 @@ extern uint64_t recordApiTrace(std::string* fullStr, const std::string& apiStr); // This macro should be called at the beginning of every HIP API. // It initializes the hip runtime (exactly once), and // generates a trace string that can be output to stderr or to ATP file. -#define HIP_INIT_API(...) \ - HIP_INIT() \ - API_TRACE(0, __VA_ARGS__); - -#define HIP_INIT_CB_API(cid, ...) \ +#define HIP_INIT_API(cid, ...) \ HIP_INIT() \ API_TRACE(0, __VA_ARGS__); \ HIP_CB_SPAWNER_OBJECT(cid); @@ -310,11 +306,7 @@ extern uint64_t recordApiTrace(std::string* fullStr, const std::string& apiStr); // Like above, but will trace with a specified "special" bit. // Replace HIP_INIT_API with this call inside HIP APIs that launch work on the GPU: // kernel launches, copy commands, memory sets, etc. -#define HIP_INIT_SPECIAL_API(tbit, ...) \ - HIP_INIT() \ - API_TRACE((HIP_TRACE_API & (1 << tbit)), __VA_ARGS__); - -#define HIP_INIT_SPECIAL_CB_API(cid, tbit, ...) \ +#define HIP_INIT_SPECIAL_API(cid, tbit, ...) \ HIP_INIT() \ API_TRACE((HIP_TRACE_API & (1 << tbit)), __VA_ARGS__); \ HIP_CB_SPAWNER_OBJECT(cid); diff --git a/src/hip_memory.cpp b/src/hip_memory.cpp index b31192f5c5..b389b4f93a 100644 --- a/src/hip_memory.cpp +++ b/src/hip_memory.cpp @@ -159,7 +159,7 @@ void* allocAndSharePtr(const char* msg, size_t sizeBytes, ihipCtx_t* ctx, bool s // TODO - add more info here when available. // hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void* ptr) { - HIP_INIT_CB_API(hipPointerGetAttributes, attributes, ptr); + HIP_INIT_API(hipPointerGetAttributes, attributes, ptr); hipError_t e = hipSuccess; if ((attributes == nullptr) || (ptr == nullptr)) { @@ -206,7 +206,7 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsigned flags) { - HIP_INIT_CB_API(hipHostGetDevicePointer, devicePointer, hostPointer, flags); + HIP_INIT_API(hipHostGetDevicePointer, devicePointer, hostPointer, flags); hipError_t e = hipSuccess; @@ -237,7 +237,7 @@ hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsi hipError_t hipMalloc(void** ptr, size_t sizeBytes) { - HIP_INIT_SPECIAL_CB_API(hipMalloc, (TRACE_MEM), ptr, sizeBytes); + HIP_INIT_SPECIAL_API(hipMalloc, (TRACE_MEM), ptr, sizeBytes); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -266,7 +266,7 @@ hipError_t hipMalloc(void** ptr, size_t sizeBytes) { hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) { - HIP_INIT_SPECIAL_CB_API(hipHostMalloc, (TRACE_MEM), ptr, sizeBytes, flags); + HIP_INIT_SPECIAL_API(hipHostMalloc, (TRACE_MEM), ptr, sizeBytes, flags); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -398,7 +398,7 @@ hipError_t ihipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t heigh // width in bytes hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height) { - HIP_INIT_SPECIAL_CB_API(hipMallocPitch, (TRACE_MEM), ptr, pitch, width, height); + HIP_INIT_SPECIAL_API(hipMallocPitch, (TRACE_MEM), ptr, pitch, width, height); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -409,7 +409,7 @@ hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height } hipError_t hipMalloc3D(hipPitchedPtr* pitchedDevPtr, hipExtent extent) { - HIP_INIT_CB_API(hipMalloc3D, pitchedDevPtr, &extent); + HIP_INIT_API(hipMalloc3D, pitchedDevPtr, &extent); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -444,7 +444,7 @@ extern void getChannelOrderAndType(const hipChannelFormatDesc& desc, hsa_ext_image_channel_type_t* channelType); hipError_t hipArrayCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray) { - HIP_INIT_SPECIAL_CB_API(hipArrayCreate, (TRACE_MEM), array, pAllocateArray); + HIP_INIT_SPECIAL_API(hipArrayCreate, (TRACE_MEM), array, pAllocateArray); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; if (pAllocateArray->width > 0) { @@ -554,7 +554,7 @@ hipError_t hipArrayCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocat hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width, size_t height, unsigned int flags) { - HIP_INIT_SPECIAL_CB_API(hipMallocArray, (TRACE_MEM), array, desc, width, height, flags); + HIP_INIT_SPECIAL_API(hipMallocArray, (TRACE_MEM), array, desc, width, height, flags); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; if (width > 0) { @@ -635,7 +635,7 @@ hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, si } hipError_t hipArray3DCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray) { - HIP_INIT_SPECIAL_CB_API(hipArray3DCreate, (TRACE_MEM), array, pAllocateArray); + HIP_INIT_SPECIAL_API(hipArray3DCreate, (TRACE_MEM), array, pAllocateArray); hipError_t hip_status = hipSuccess; auto ctx = ihipGetTlsDefaultCtx(); @@ -762,7 +762,7 @@ hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc* - HIP_INIT_CB_API(hipMalloc3DArray, array, desc, &extent, flags); + HIP_INIT_API(hipMalloc3DArray, array, desc, &extent, flags); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -846,7 +846,7 @@ hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc* } hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) { - HIP_INIT_CB_API(hipHostGetFlags, flagsPtr, hostPtr); + HIP_INIT_API(hipHostGetFlags, flagsPtr, hostPtr); hipError_t hip_status = hipSuccess; @@ -874,7 +874,7 @@ hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) { // TODO - need to fix several issues here related to P2P access, host memory fallback. hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags) { - HIP_INIT_CB_API(hipHostRegister, hostPtr, sizeBytes, flags); + HIP_INIT_API(hipHostRegister, hostPtr, sizeBytes, flags); hipError_t hip_status = hipSuccess; @@ -931,7 +931,7 @@ hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags) } hipError_t hipHostUnregister(void* hostPtr) { - HIP_INIT_CB_API(hipHostUnregister, hostPtr); + HIP_INIT_API(hipHostUnregister, hostPtr); auto ctx = ihipGetTlsDefaultCtx(); hipError_t hip_status = hipSuccess; if (hostPtr == NULL) { @@ -966,7 +966,7 @@ inline hipDeviceptr_t agent_address_for_symbol(const char* symbolName) { hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t count, size_t offset, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyToSymbol, (TRACE_MCMD), symbolName, src, count, offset, kind); + HIP_INIT_SPECIAL_API(hipMemcpyToSymbol, (TRACE_MCMD), symbolName, src, count, offset, kind); if (symbolName == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); @@ -999,7 +999,7 @@ hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t cou hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t count, size_t offset, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyFromSymbol, (TRACE_MCMD), symbolName, dst, count, offset, kind); + HIP_INIT_SPECIAL_API(hipMemcpyFromSymbol, (TRACE_MCMD), symbolName, dst, count, offset, kind); if (symbolName == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); @@ -1031,7 +1031,7 @@ hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t count, hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyToSymbolAsync, (TRACE_MCMD), symbolName, src, count, offset, kind, stream); + HIP_INIT_SPECIAL_API(hipMemcpyToSymbolAsync, (TRACE_MCMD), symbolName, src, count, offset, kind, stream); if (symbolName == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); @@ -1066,7 +1066,7 @@ hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src, size_ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyFromSymbolAsync, (TRACE_MCMD), symbolName, dst, count, offset, kind, stream); + HIP_INIT_SPECIAL_API(hipMemcpyFromSymbolAsync, (TRACE_MCMD), symbolName, dst, count, offset, kind, stream); if (symbolName == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); @@ -1101,7 +1101,7 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t co //--- hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_CB_API(hipMemcpy, (TRACE_MCMD), dst, src, sizeBytes, kind); + HIP_INIT_SPECIAL_API(hipMemcpy, (TRACE_MCMD), dst, src, sizeBytes, kind); hipError_t e = hipSuccess; @@ -1128,7 +1128,7 @@ hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyHtoD, (TRACE_MCMD), dst, src, sizeBytes); + HIP_INIT_SPECIAL_API(hipMemcpyHtoD, (TRACE_MCMD), dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1147,7 +1147,7 @@ hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) { hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyDtoH, (TRACE_MCMD), dst, src, sizeBytes); + HIP_INIT_SPECIAL_API(hipMemcpyDtoH, (TRACE_MCMD), dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1166,7 +1166,7 @@ hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) { hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyDtoD, (TRACE_MCMD), dst, src, sizeBytes); + HIP_INIT_SPECIAL_API(hipMemcpyDtoD, (TRACE_MCMD), dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1184,7 +1184,7 @@ hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeByte } hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) { - HIP_INIT_SPECIAL_API((TRACE_MCMD), dst, src, sizeBytes); + HIP_INIT_SPECIAL_API(hipMemcpyHtoH, (TRACE_MCMD), dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1203,13 +1203,13 @@ hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) { hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyAsync, (TRACE_MCMD), dst, src, sizeBytes, kind, stream); + HIP_INIT_SPECIAL_API(hipMemcpyAsync, (TRACE_MCMD), dst, src, sizeBytes, kind, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, kind, stream)); } hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void* src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyHtoDAsync, (TRACE_MCMD), dst, src, sizeBytes, stream); + HIP_INIT_SPECIAL_API(hipMemcpyHtoDAsync, (TRACE_MCMD), dst, src, sizeBytes, stream); return ihipLogStatus( hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyHostToDevice, stream)); @@ -1217,14 +1217,14 @@ hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void* src, size_t sizeBytes, h hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyDtoDAsync, (TRACE_MCMD), dst, src, sizeBytes, stream); + HIP_INIT_SPECIAL_API(hipMemcpyDtoDAsync, (TRACE_MCMD), dst, src, sizeBytes, stream); return ihipLogStatus( hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDeviceToDevice, stream)); } hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyDtoHAsync, (TRACE_MCMD), dst, src, sizeBytes, stream); + HIP_INIT_SPECIAL_API(hipMemcpyDtoHAsync, (TRACE_MCMD), dst, src, sizeBytes, stream); return ihipLogStatus( hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDeviceToHost, stream)); @@ -1232,7 +1232,7 @@ hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, h hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_CB_API(hipMemcpy2DToArray, (TRACE_MCMD), dst, wOffset, hOffset, src, spitch, width, height, kind); + HIP_INIT_SPECIAL_API(hipMemcpy2DToArray, (TRACE_MCMD), dst, wOffset, hOffset, src, spitch, width, height, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1284,7 +1284,7 @@ hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, con hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyToArray, (TRACE_MCMD), dst, wOffset, hOffset, src, count, kind); + HIP_INIT_SPECIAL_API(hipMemcpyToArray, (TRACE_MCMD), dst, wOffset, hOffset, src, count, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1303,7 +1303,7 @@ hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const hipError_t hipMemcpyFromArray(void* dst, hipArray_const_t srcArray, size_t wOffset, size_t hOffset, size_t count, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyFromArray, (TRACE_MCMD), dst, srcArray, wOffset, hOffset, count, kind); + HIP_INIT_SPECIAL_API(hipMemcpyFromArray, (TRACE_MCMD), dst, srcArray, wOffset, hOffset, count, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1321,7 +1321,7 @@ hipError_t hipMemcpyFromArray(void* dst, hipArray_const_t srcArray, size_t wOffs } hipError_t hipMemcpyHtoA(hipArray* dstArray, size_t dstOffset, const void* srcHost, size_t count) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyHtoA, (TRACE_MCMD), dstArray, dstOffset, srcHost, count); + HIP_INIT_SPECIAL_API(hipMemcpyHtoA, (TRACE_MCMD), dstArray, dstOffset, srcHost, count); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1339,7 +1339,7 @@ hipError_t hipMemcpyHtoA(hipArray* dstArray, size_t dstOffset, const void* srcHo } hipError_t hipMemcpyAtoH(void* dst, hipArray* srcArray, size_t srcOffset, size_t count) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyAtoH, (TRACE_MCMD), dst, srcArray, srcOffset, count); + HIP_INIT_SPECIAL_API(hipMemcpyAtoH, (TRACE_MCMD), dst, srcArray, srcOffset, count); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -1358,7 +1358,7 @@ hipError_t hipMemcpyAtoH(void* dst, hipArray* srcArray, size_t srcOffset, size_t } hipError_t hipMemcpy3D(const struct hipMemcpy3DParms* p) { - HIP_INIT_SPECIAL_CB_API(hipMemcpy3D, (TRACE_MCMD), p); + HIP_INIT_SPECIAL_API(hipMemcpy3D, (TRACE_MCMD), p); hipError_t e = hipSuccess; if (p) { size_t byteSize; @@ -1626,7 +1626,7 @@ hipError_t ihipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) { - HIP_INIT_SPECIAL_CB_API(hipMemcpy2D, (TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind); + HIP_INIT_SPECIAL_API(hipMemcpy2D, (TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind); hipError_t e = hipSuccess; e = ihipMemcpy2D(dst, dpitch, src, spitch, width, height, kind); return ihipLogStatus(e); @@ -1634,7 +1634,7 @@ hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, hipError_t hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipMemcpy2DAsync, (TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind, stream); + HIP_INIT_SPECIAL_API(hipMemcpy2DAsync, (TRACE_MCMD), dst, dpitch, src, spitch, width, height, kind, stream); if (dst == nullptr || src == nullptr || width > dpitch || width > spitch) return ihipLogStatus(hipErrorInvalidValue); hipError_t e = hipSuccess; int isLocked = 0; @@ -1673,7 +1673,7 @@ hipError_t hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t sp } hipError_t hipMemcpyParam2D(const hip_Memcpy2D* pCopy) { - HIP_INIT_SPECIAL_CB_API(hipMemcpyParam2D, (TRACE_MCMD), pCopy); + HIP_INIT_SPECIAL_API(hipMemcpyParam2D, (TRACE_MCMD), pCopy); hipError_t e = hipSuccess; if (pCopy == nullptr) { e = hipErrorInvalidValue; @@ -1685,7 +1685,7 @@ hipError_t hipMemcpyParam2D(const hip_Memcpy2D* pCopy) { // TODO-sync: function is async unless target is pinned host memory - then these are fully sync. hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipMemsetAsync, (TRACE_MCMD), dst, value, sizeBytes, stream); + HIP_INIT_SPECIAL_API(hipMemsetAsync, (TRACE_MCMD), dst, value, sizeBytes, stream); hipError_t e = hipSuccess; @@ -1697,7 +1697,7 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t st }; hipError_t hipMemset(void* dst, int value, size_t sizeBytes) { - HIP_INIT_SPECIAL_CB_API(hipMemset, (TRACE_MCMD), dst, value, sizeBytes); + HIP_INIT_SPECIAL_API(hipMemset, (TRACE_MCMD), dst, value, sizeBytes); hipError_t e = hipSuccess; @@ -1713,7 +1713,7 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes) { } hipError_t hipMemset2D(void* dst, size_t pitch, int value, size_t width, size_t height) { - HIP_INIT_SPECIAL_CB_API(hipMemset2D, (TRACE_MCMD), dst, pitch, value, width, height); + HIP_INIT_SPECIAL_API(hipMemset2D, (TRACE_MCMD), dst, pitch, value, width, height); hipError_t e = hipSuccess; @@ -1732,7 +1732,7 @@ hipError_t hipMemset2D(void* dst, size_t pitch, int value, size_t width, size_t hipError_t hipMemset2DAsync(void* dst, size_t pitch, int value, size_t width, size_t height, hipStream_t stream ) { - HIP_INIT_SPECIAL_CB_API(hipMemset2DAsync, (TRACE_MCMD), dst, pitch, value, width, height, stream); + HIP_INIT_SPECIAL_API(hipMemset2DAsync, (TRACE_MCMD), dst, pitch, value, width, height, stream); hipError_t e = hipSuccess; @@ -1749,7 +1749,7 @@ hipError_t hipMemset2DAsync(void* dst, size_t pitch, int value, size_t width, si }; hipError_t hipMemsetD8(hipDeviceptr_t dst, unsigned char value, size_t sizeBytes) { - HIP_INIT_SPECIAL_CB_API(hipMemsetD8, (TRACE_MCMD), dst, value, sizeBytes); + HIP_INIT_SPECIAL_API(hipMemsetD8, (TRACE_MCMD), dst, value, sizeBytes); hipError_t e = hipSuccess; @@ -1766,7 +1766,7 @@ hipError_t hipMemsetD8(hipDeviceptr_t dst, unsigned char value, size_t sizeBytes hipError_t hipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent ) { - HIP_INIT_SPECIAL_CB_API(hipMemset3D, (TRACE_MCMD), &pitchedDevPtr, value, &extent); + HIP_INIT_SPECIAL_API(hipMemset3D, (TRACE_MCMD), &pitchedDevPtr, value, &extent); hipError_t e = hipSuccess; hipStream_t stream = hipStreamNull; @@ -1785,7 +1785,7 @@ hipError_t hipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent hipError_t hipMemset3DAsync(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent ,hipStream_t stream ) { - HIP_INIT_SPECIAL_CB_API(hipMemset3DAsync, (TRACE_MCMD), &pitchedDevPtr, value, &extent); + HIP_INIT_SPECIAL_API(hipMemset3DAsync, (TRACE_MCMD), &pitchedDevPtr, value, &extent); hipError_t e = hipSuccess; // TODO - call an ihip memset so HIP_TRACE is correct. @@ -1801,7 +1801,7 @@ hipError_t hipMemset3DAsync(hipPitchedPtr pitchedDevPtr, int value, hipExtent e } hipError_t hipMemGetInfo(size_t* free, size_t* total) { - HIP_INIT_CB_API(hipMemGetInfo, free, total); + HIP_INIT_API(hipMemGetInfo, free, total); hipError_t e = hipSuccess; @@ -1835,7 +1835,7 @@ hipError_t hipMemGetInfo(size_t* free, size_t* total) { } hipError_t hipMemPtrGetInfo(void* ptr, size_t* size) { - HIP_INIT_CB_API(hipMemPtrGetInfo, ptr, size); + HIP_INIT_API(hipMemPtrGetInfo, ptr, size); hipError_t e = hipSuccess; @@ -1860,7 +1860,7 @@ hipError_t hipMemPtrGetInfo(void* ptr, size_t* size) { hipError_t hipFree(void* ptr) { - HIP_INIT_SPECIAL_CB_API(hipFree, (TRACE_MEM), ptr); + HIP_INIT_SPECIAL_API(hipFree, (TRACE_MEM), ptr); hipError_t hipStatus = hipErrorInvalidDevicePointer; @@ -1892,7 +1892,7 @@ hipError_t hipFree(void* ptr) { hipError_t hipHostFree(void* ptr) { - HIP_INIT_SPECIAL_CB_API(hipHostFree, (TRACE_MEM), ptr); + HIP_INIT_SPECIAL_API(hipHostFree, (TRACE_MEM), ptr); // Synchronize to ensure all work has finished. ihipGetTlsDefaultCtx()->locked_waitAllStreams(); // ignores non-blocking streams, this waits @@ -1927,7 +1927,7 @@ hipError_t hipHostFree(void* ptr) { hipError_t hipFreeHost(void* ptr) { return hipHostFree(ptr); } hipError_t hipFreeArray(hipArray* array) { - HIP_INIT_SPECIAL_CB_API(hipFreeArray, (TRACE_MEM), array); + HIP_INIT_SPECIAL_API(hipFreeArray, (TRACE_MEM), array); hipError_t hipStatus = hipErrorInvalidDevicePointer; @@ -1955,7 +1955,7 @@ hipError_t hipFreeArray(hipArray* array) { } hipError_t hipMemGetAddressRange(hipDeviceptr_t* pbase, size_t* psize, hipDeviceptr_t dptr) { - HIP_INIT_CB_API(hipMemGetAddressRange, pbase, psize, dptr); + HIP_INIT_API(hipMemGetAddressRange, pbase, psize, dptr); hipError_t hipStatus = hipSuccess; hc::accelerator acc; #if (__hcc_workweek__ >= 17332) @@ -1976,7 +1976,7 @@ hipError_t hipMemGetAddressRange(hipDeviceptr_t* pbase, size_t* psize, hipDevice // TODO: IPC implementaiton: hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr) { - HIP_INIT_CB_API(hipIpcGetMemHandle, handle, devPtr); + HIP_INIT_API(hipIpcGetMemHandle, handle, devPtr); hipError_t hipStatus = hipSuccess; // Get the size of allocated pointer size_t psize = 0u; @@ -2012,7 +2012,7 @@ hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr) { } hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags) { - HIP_INIT_CB_API(hipIpcOpenMemHandle, devPtr, &handle, flags); + HIP_INIT_API(hipIpcOpenMemHandle, devPtr, &handle, flags); hipError_t hipStatus = hipSuccess; if (devPtr == NULL) { hipStatus = hipErrorInvalidValue; @@ -2042,7 +2042,7 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned } hipError_t hipIpcCloseMemHandle(void* devPtr) { - HIP_INIT_CB_API(hipIpcCloseMemHandle, devPtr); + HIP_INIT_API(hipIpcCloseMemHandle, devPtr); hipError_t hipStatus = hipSuccess; if (devPtr == NULL) { hipStatus = hipErrorInvalidValue; diff --git a/src/hip_module.cpp b/src/hip_module.cpp index 539fbed9af..db89f5f3f8 100644 --- a/src/hip_module.cpp +++ b/src/hip_module.cpp @@ -97,7 +97,7 @@ std::string& FunctionSymbol(hipFunction_t f) { return f->_name; }; } hipError_t hipModuleUnload(hipModule_t hmod) { - HIP_INIT_CB_API(hipModuleUnload, hmod); + HIP_INIT_API(hipModuleUnload, hmod); // TODO - improve this synchronization so it is thread-safe. // Currently we want for all inflight activity to complete, but don't prevent another @@ -231,7 +231,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, uint32_t gridDimX, uint32_t gr uint32_t gridDimZ, uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ, uint32_t sharedMemBytes, hipStream_t hStream, void** kernelParams, void** extra) { - HIP_INIT_CB_API(hipModuleLaunchKernel, f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, + HIP_INIT_API(hipModuleLaunchKernel, f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes, hStream, kernelParams, extra); return ihipLogStatus(ihipModuleLaunchKernel( f, blockDimX * gridDimX, blockDimY * gridDimY, gridDimZ * blockDimZ, blockDimX, blockDimY, @@ -245,7 +245,7 @@ hipError_t hipHccModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX, uint32_t localWorkSizeZ, size_t sharedMemBytes, hipStream_t hStream, void** kernelParams, void** extra, hipEvent_t startEvent, hipEvent_t stopEvent) { - HIP_INIT_API(f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, + HIP_INIT_API(hipHccModuleLaunchKernel, f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY, localWorkSizeZ, sharedMemBytes, hStream, kernelParams, extra); return ihipLogStatus(ihipModuleLaunchKernel( f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY, @@ -461,13 +461,13 @@ hipError_t ihipModuleGetFunction(hipFunction_t* func, hipModule_t hmod, const ch } hipError_t hipModuleGetFunction(hipFunction_t* hfunc, hipModule_t hmod, const char* name) { - HIP_INIT_CB_API(hipModuleGetFunction, hfunc, hmod, name); + HIP_INIT_API(hipModuleGetFunction, hfunc, hmod, name); return ihipLogStatus(ihipModuleGetFunction(hfunc, hmod, name)); } hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t hmod, const char* name) { - HIP_INIT_CB_API(hipModuleGetGlobal, dptr, bytes, hmod, name); + HIP_INIT_API(hipModuleGetGlobal, dptr, bytes, hmod, name); if (!dptr || !bytes) return ihipLogStatus(hipErrorInvalidValue); @@ -559,12 +559,12 @@ hipError_t ihipModuleLoadData(hipModule_t* module, const void* image) { } hipError_t hipModuleLoadData(hipModule_t* module, const void* image) { - HIP_INIT_CB_API(hipModuleLoadData, module, image); + HIP_INIT_API(hipModuleLoadData, module, image); return ihipLogStatus(ihipModuleLoadData(module,image)); } hipError_t hipModuleLoad(hipModule_t* module, const char* fname) { - HIP_INIT_CB_API(hipModuleLoad, module, fname); + HIP_INIT_API(hipModuleLoad, module, fname); if (!fname) return ihipLogStatus(hipErrorInvalidValue); @@ -579,12 +579,12 @@ hipError_t hipModuleLoad(hipModule_t* module, const char* fname) { hipError_t hipModuleLoadDataEx(hipModule_t* module, const void* image, unsigned int numOptions, hipJitOption* options, void** optionValues) { - HIP_INIT_CB_API(hipModuleLoadDataEx, module, image, numOptions, options, optionValues); + HIP_INIT_API(hipModuleLoadDataEx, module, image, numOptions, options, optionValues); return ihipLogStatus(ihipModuleLoadData(module, image)); } hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const char* name) { - HIP_INIT_CB_API(hipModuleGetTexRef, texRef, hmod, name); + HIP_INIT_API(hipModuleGetTexRef, texRef, hmod, name); hipError_t ret = hipErrorNotFound; if (!texRef) return ihipLogStatus(hipErrorInvalidValue); diff --git a/src/hip_peer.cpp b/src/hip_peer.cpp index 97c3fd4052..cffb895c57 100644 --- a/src/hip_peer.cpp +++ b/src/hip_peer.cpp @@ -73,7 +73,7 @@ hipError_t ihipDeviceCanAccessPeer(int* canAccessPeer, hipCtx_t thisCtx, hipCtx_ */ //--- hipError_t hipDeviceCanAccessPeer(int* canAccessPeer, hipCtx_t thisCtx, hipCtx_t peerCtx) { - HIP_INIT_API(canAccessPeer, thisCtx, peerCtx); + HIP_INIT_API(hipDeviceCanAccessPeer2, canAccessPeer, thisCtx, peerCtx); return ihipLogStatus(ihipDeviceCanAccessPeer(canAccessPeer, thisCtx, peerCtx)); } @@ -150,7 +150,7 @@ hipError_t ihipEnablePeerAccess(hipCtx_t peerCtx, unsigned int flags) { //--- hipError_t hipMemcpyPeer(void* dst, hipCtx_t dstCtx, const void* src, hipCtx_t srcCtx, size_t sizeBytes) { - HIP_INIT_API(dst, dstCtx, src, srcCtx, sizeBytes); + HIP_INIT_API(hipMemcpyPeer2, dst, dstCtx, src, srcCtx, sizeBytes); // TODO - move to ihip memory copy implementaion. // HCC has a unified memory architecture so device specifiers are not required. @@ -161,7 +161,7 @@ hipError_t hipMemcpyPeer(void* dst, hipCtx_t dstCtx, const void* src, hipCtx_t s //--- hipError_t hipMemcpyPeerAsync(void* dst, hipCtx_t dstDevice, const void* src, hipCtx_t srcDevice, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes, stream); + HIP_INIT_API(hipMemcpyPeerAsync2, dst, dstDevice, src, srcDevice, sizeBytes, stream); // TODO - move to ihip memory copy implementaion. // HCC has a unified memory architecture so device specifiers are not required. @@ -175,21 +175,21 @@ hipError_t hipMemcpyPeerAsync(void* dst, hipCtx_t dstDevice, const void* src, hi //============================================================================= hipError_t hipDeviceCanAccessPeer(int* canAccessPeer, int deviceId, int peerDeviceId) { - HIP_INIT_CB_API(hipDeviceCanAccessPeer, canAccessPeer, deviceId, peerDeviceId); + HIP_INIT_API(hipDeviceCanAccessPeer, canAccessPeer, deviceId, peerDeviceId); return ihipLogStatus(ihipDeviceCanAccessPeer(canAccessPeer, ihipGetPrimaryCtx(deviceId), ihipGetPrimaryCtx(peerDeviceId))); } hipError_t hipDeviceDisablePeerAccess(int peerDeviceId) { - HIP_INIT_CB_API(hipDeviceDisablePeerAccess, peerDeviceId); + HIP_INIT_API(hipDeviceDisablePeerAccess, peerDeviceId); return ihipLogStatus(ihipDisablePeerAccess(ihipGetPrimaryCtx(peerDeviceId))); } hipError_t hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags) { - HIP_INIT_CB_API(hipDeviceEnablePeerAccess, peerDeviceId, flags); + HIP_INIT_API(hipDeviceEnablePeerAccess, peerDeviceId, flags); return ihipLogStatus(ihipEnablePeerAccess(ihipGetPrimaryCtx(peerDeviceId), flags)); } @@ -197,7 +197,7 @@ hipError_t hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags) { hipError_t hipMemcpyPeer(void* dst, int dstDevice, const void* src, int srcDevice, size_t sizeBytes) { - HIP_INIT_CB_API(hipMemcpyPeer, dst, dstDevice, src, srcDevice, sizeBytes); + HIP_INIT_API(hipMemcpyPeer, dst, dstDevice, src, srcDevice, sizeBytes); return ihipLogStatus(hipMemcpyPeer(dst, ihipGetPrimaryCtx(dstDevice), src, ihipGetPrimaryCtx(srcDevice), sizeBytes)); } @@ -205,18 +205,18 @@ hipError_t hipMemcpyPeer(void* dst, int dstDevice, const void* src, int srcDevic hipError_t hipMemcpyPeerAsync(void* dst, int dstDevice, const void* src, int srcDevice, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_CB_API(hipMemcpyPeerAsync, dst, dstDevice, src, srcDevice, sizeBytes, stream); + HIP_INIT_API(hipMemcpyPeerAsync, dst, dstDevice, src, srcDevice, sizeBytes, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDefault, stream)); } hipError_t hipCtxEnablePeerAccess(hipCtx_t peerCtx, unsigned int flags) { - HIP_INIT_CB_API(hipCtxEnablePeerAccess, peerCtx, flags); + HIP_INIT_API(hipCtxEnablePeerAccess, peerCtx, flags); return ihipLogStatus(ihipEnablePeerAccess(peerCtx, flags)); } hipError_t hipCtxDisablePeerAccess(hipCtx_t peerCtx) { - HIP_INIT_CB_API(hipCtxDisablePeerAccess, peerCtx); + HIP_INIT_API(hipCtxDisablePeerAccess, peerCtx); return ihipLogStatus(ihipDisablePeerAccess(peerCtx)); } diff --git a/src/hip_stream.cpp b/src/hip_stream.cpp index c710aba6c8..86c323a8b6 100644 --- a/src/hip_stream.cpp +++ b/src/hip_stream.cpp @@ -90,14 +90,14 @@ hipError_t ihipStreamCreate(hipStream_t* stream, unsigned int flags, int priorit //--- hipError_t hipStreamCreateWithFlags(hipStream_t* stream, unsigned int flags) { - HIP_INIT_CB_API(hipStreamCreateWithFlags, stream, flags); + HIP_INIT_API(hipStreamCreateWithFlags, stream, flags); return ihipLogStatus(ihipStreamCreate(stream, flags, priority_normal)); } //--- hipError_t hipStreamCreate(hipStream_t* stream) { - HIP_INIT_CB_API(hipStreamCreate, stream); + HIP_INIT_API(hipStreamCreate, stream); return ihipLogStatus(ihipStreamCreate(stream, hipStreamDefault, priority_normal)); } @@ -121,7 +121,7 @@ hipError_t hipDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPrio } hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int flags) { - HIP_INIT_SPECIAL_CB_API(hipStreamWaitEvent, TRACE_SYNC, stream, event, flags); + HIP_INIT_SPECIAL_API(hipStreamWaitEvent, TRACE_SYNC, stream, event, flags); hipError_t e = hipSuccess; @@ -152,7 +152,7 @@ hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int //--- hipError_t hipStreamQuery(hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipStreamQuery, TRACE_QUERY, stream); + HIP_INIT_SPECIAL_API(hipStreamQuery, TRACE_QUERY, stream); // Use default stream if 0 specified: if (stream == hipStreamNull) { @@ -175,7 +175,7 @@ hipError_t hipStreamQuery(hipStream_t stream) { //--- hipError_t hipStreamSynchronize(hipStream_t stream) { - HIP_INIT_SPECIAL_CB_API(hipStreamSynchronize, TRACE_SYNC, stream); + HIP_INIT_SPECIAL_API(hipStreamSynchronize, TRACE_SYNC, stream); return ihipLogStatus(ihipStreamSynchronize(stream)); } @@ -186,7 +186,7 @@ hipError_t hipStreamSynchronize(hipStream_t stream) { * @return #hipSuccess, #hipErrorInvalidResourceHandle */ hipError_t hipStreamDestroy(hipStream_t stream) { - HIP_INIT_CB_API(hipStreamDestroy, stream); + HIP_INIT_API(hipStreamDestroy, stream); hipError_t e = hipSuccess; @@ -214,7 +214,7 @@ hipError_t hipStreamDestroy(hipStream_t stream) { //--- hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int* flags) { - HIP_INIT_CB_API(hipStreamGetFlags, stream, flags); + HIP_INIT_API(hipStreamGetFlags, stream, flags); if (flags == NULL) { return ihipLogStatus(hipErrorInvalidValue); @@ -250,7 +250,7 @@ hipError_t hipStreamGetPriority(hipStream_t stream, int* priority) { //--- hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback, void* userData, unsigned int flags) { - HIP_INIT_CB_API(hipStreamAddCallback, stream, callback, userData, flags); + HIP_INIT_API(hipStreamAddCallback, stream, callback, userData, flags); hipError_t e = hipSuccess; // Create a thread in detached mode to handle callback diff --git a/src/hip_surface.cpp b/src/hip_surface.cpp index 6ac0dde3e3..9acd827f73 100644 --- a/src/hip_surface.cpp +++ b/src/hip_surface.cpp @@ -41,7 +41,7 @@ void saveSurfaceInfo(const hipSurface* pSurface, const hipResourceDesc* pResDesc // Surface Object APIs hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject, const hipResourceDesc* pResDesc) { - HIP_INIT_API(pSurfObject, pResDesc); + HIP_INIT_API(hipCreateSurfaceObject, pSurfObject, pResDesc); hipError_t hip_status = hipSuccess; auto ctx = ihipGetTlsDefaultCtx(); @@ -71,7 +71,7 @@ hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject, } hipError_t hipDestroySurfaceObject(hipSurfaceObject_t surfaceObject) { - HIP_INIT_API(surfaceObject); + HIP_INIT_API(hipDestroySurfaceObject, surfaceObject); hipError_t hip_status = hipSuccess; diff --git a/src/hip_texture.cpp b/src/hip_texture.cpp index 521e0e24de..316fba20cd 100644 --- a/src/hip_texture.cpp +++ b/src/hip_texture.cpp @@ -202,7 +202,7 @@ bool getHipTextureObject(hipTextureObject_t* pTexObject, hsa_ext_image_t& image, hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResourceDesc* pResDesc, const hipTextureDesc* pTexDesc, const hipResourceViewDesc* pResViewDesc) { - HIP_INIT_API(pTexObject, pResDesc, pTexDesc, pResViewDesc); + HIP_INIT_API(hipCreateTextureObject, pTexObject, pResDesc, pTexDesc, pResViewDesc); hipError_t hip_status = hipSuccess; auto ctx = ihipGetTlsDefaultCtx(); @@ -311,7 +311,7 @@ hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResou } hipError_t hipDestroyTextureObject(hipTextureObject_t textureObject) { - HIP_INIT_API(textureObject); + HIP_INIT_API(hipDestroyTextureObject, textureObject); hipError_t hip_status = hipSuccess; @@ -335,7 +335,7 @@ hipError_t hipDestroyTextureObject(hipTextureObject_t textureObject) { hipError_t hipGetTextureObjectResourceDesc(hipResourceDesc* pResDesc, hipTextureObject_t textureObject) { - HIP_INIT_API(pResDesc, textureObject); + HIP_INIT_API(hipGetTextureObjectResourceDesc, pResDesc, textureObject); hipError_t hip_status = hipSuccess; auto ctx = ihipGetTlsDefaultCtx(); @@ -350,7 +350,7 @@ hipError_t hipGetTextureObjectResourceDesc(hipResourceDesc* pResDesc, hipError_t hipGetTextureObjectResourceViewDesc(hipResourceViewDesc* pResViewDesc, hipTextureObject_t textureObject) { - HIP_INIT_API(pResViewDesc, textureObject); + HIP_INIT_API(hipGetTextureObjectResourceViewDesc, pResViewDesc, textureObject); hipError_t hip_status = hipSuccess; auto ctx = ihipGetTlsDefaultCtx(); @@ -366,7 +366,7 @@ hipError_t hipGetTextureObjectResourceViewDesc(hipResourceViewDesc* pResViewDesc hipError_t hipGetTextureObjectTextureDesc(hipTextureDesc* pTexDesc, hipTextureObject_t textureObject) { - HIP_INIT_API(pTexDesc, textureObject); + HIP_INIT_API(hipGetTextureObjectTextureDesc, pTexDesc, textureObject); hipError_t hip_status = hipSuccess; @@ -444,7 +444,7 @@ hipError_t ihipBindTextureImpl(int dim, enum hipTextureReadMode readMode, size_t hipError_t hipBindTexture(size_t* offset, textureReference* tex, const void* devPtr, const hipChannelFormatDesc* desc, size_t size) { - HIP_INIT_API(offset, tex, devPtr, desc, size); + HIP_INIT_API(hipBindTexture, offset, tex, devPtr, desc, size); hipError_t hip_status = hipSuccess; // TODO: hipReadModeElementType is default. hip_status = ihipBindTextureImpl(hipTextureType1D, hipReadModeElementType, offset, devPtr, desc, @@ -517,7 +517,7 @@ hipError_t ihipBindTexture2DImpl(int dim, enum hipTextureReadMode readMode, size hipError_t hipBindTexture2D(size_t* offset, textureReference* tex, const void* devPtr, const hipChannelFormatDesc* desc, size_t width, size_t height, size_t pitch) { - HIP_INIT_API(offset, tex, devPtr, desc, width, height, pitch); + HIP_INIT_API(hipBindTexture2D, offset, tex, devPtr, desc, width, height, pitch); hipError_t hip_status = hipSuccess; hip_status = ihipBindTexture2DImpl(hipTextureType2D, hipReadModeElementType, offset, devPtr, desc, width, height, tex); @@ -613,7 +613,7 @@ hipError_t ihipBindTextureToArrayImpl(int dim, enum hipTextureReadMode readMode, hipError_t hipBindTextureToArray(textureReference* tex, hipArray_const_t array, const hipChannelFormatDesc* desc) { - HIP_INIT_API(tex, array, desc); + HIP_INIT_API(hipBindTextureToArray, tex, array, desc); hipError_t hip_status = hipSuccess; // TODO: hipReadModeElementType is default. hip_status = @@ -624,7 +624,7 @@ hipError_t hipBindTextureToArray(textureReference* tex, hipArray_const_t array, hipError_t hipBindTextureToMipmappedArray(textureReference* tex, hipMipmappedArray_const_t mipmappedArray, const hipChannelFormatDesc* desc) { - HIP_INIT_API(tex, mipmappedArray, desc); + HIP_INIT_API(hipBindTextureToMipmappedArray, tex, mipmappedArray, desc); hipError_t hip_status = hipSuccess; return ihipLogStatus(hip_status); } @@ -652,14 +652,14 @@ hipError_t ihipUnbindTextureImpl(const hipTextureObject_t& textureObject) { } hipError_t hipUnbindTexture(const textureReference* tex) { - HIP_INIT_API(tex); + HIP_INIT_API(hipUnbindTexture, tex); hipError_t hip_status = hipSuccess; hip_status = ihipUnbindTextureImpl(tex->textureObject); return ihipLogStatus(hip_status); } hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array) { - HIP_INIT_API(desc, array); + HIP_INIT_API(hipGetChannelDesc, desc, array); hipError_t hip_status = hipSuccess; auto ctx = ihipGetTlsDefaultCtx(); @@ -670,7 +670,7 @@ hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array) } hipError_t hipGetTextureAlignmentOffset(size_t* offset, const textureReference* tex) { - HIP_INIT_API(offset, tex); + HIP_INIT_API(hipGetTextureAlignmentOffset, offset, tex); hipError_t hip_status = hipSuccess; @@ -683,7 +683,7 @@ hipError_t hipGetTextureAlignmentOffset(size_t* offset, const textureReference* } hipError_t hipGetTextureReference(const textureReference** tex, const void* symbol) { - HIP_INIT_API(tex, symbol); + HIP_INIT_API(hipGetTextureReference, tex, symbol); hipError_t hip_status = hipSuccess; @@ -694,7 +694,7 @@ hipError_t hipGetTextureReference(const textureReference** tex, const void* symb } hipError_t hipTexRefSetFormat(textureReference* tex, hipArray_Format fmt, int NumPackedComponents) { - HIP_INIT_API(tex, fmt, NumPackedComponents); + HIP_INIT_API(hipTexRefSetFormat, tex, fmt, NumPackedComponents); hipError_t hip_status = hipSuccess; tex->format = fmt; tex->numChannels = NumPackedComponents; @@ -702,28 +702,28 @@ hipError_t hipTexRefSetFormat(textureReference* tex, hipArray_Format fmt, int Nu } hipError_t hipTexRefSetFlags(textureReference* tex, unsigned int flags) { - HIP_INIT_API(tex, flags); + HIP_INIT_API(hipTexRefSetFlags, tex, flags); hipError_t hip_status = hipSuccess; tex->normalized = flags; return ihipLogStatus(hip_status); } hipError_t hipTexRefSetFilterMode(textureReference* tex, hipTextureFilterMode fm) { - HIP_INIT_API(tex, fm); + HIP_INIT_API(hipTexRefSetFilterMode, tex, fm); hipError_t hip_status = hipSuccess; tex->filterMode = fm; return ihipLogStatus(hip_status); } hipError_t hipTexRefSetAddressMode(textureReference* tex, int dim, hipTextureAddressMode am) { - HIP_INIT_API(tex, dim, am); + HIP_INIT_API(hipTexRefSetAddressMode, tex, dim, am); hipError_t hip_status = hipSuccess; tex->addressMode[dim] = am; return ihipLogStatus(hip_status); } hipError_t hipTexRefSetArray(textureReference* tex, hipArray_const_t array, unsigned int flags) { - HIP_INIT_API(tex, array, flags); + HIP_INIT_API(hipTexRefSetArray, tex, array, flags); hipError_t hip_status = hipSuccess; hip_status = ihipBindTextureToArrayImpl(array->textureType, hipReadModeElementType, array, @@ -734,7 +734,7 @@ hipError_t hipTexRefSetArray(textureReference* tex, hipArray_const_t array, unsi hipError_t hipTexRefSetAddress(size_t* offset, textureReference* tex, hipDeviceptr_t devPtr, size_t size) { - HIP_INIT_API(offset, tex, devPtr, size); + HIP_INIT_API(hipTexRefSetAddress, offset, tex, devPtr, size); hipError_t hip_status = hipSuccess; // TODO: hipReadModeElementType is default. hip_status = ihipBindTextureImpl(hipTextureType1D, hipReadModeElementType, offset, devPtr, NULL, @@ -744,7 +744,7 @@ hipError_t hipTexRefSetAddress(size_t* offset, textureReference* tex, hipDevicep hipError_t hipTexRefSetAddress2D(textureReference* tex, const HIP_ARRAY_DESCRIPTOR* desc, hipDeviceptr_t devPtr, size_t pitch) { - HIP_INIT_API(tex, desc, devPtr, pitch); + HIP_INIT_API(hipTexRefSetAddress2D, tex, desc, devPtr, pitch); size_t offset; hipError_t hip_status = hipSuccess; // TODO: hipReadModeElementType is default. From 32c0008ef6c627c229df3b3e324292ad56982ba2 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 11 Nov 2018 23:44:16 -0600 Subject: [PATCH 24/55] specialized spawner object --- include/hip/hcc_detail/hip_prof_api.h | 17 ++++++++++------- include/hip/hcc_detail/hip_prof_str.h | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/include/hip/hcc_detail/hip_prof_api.h b/include/hip/hcc_detail/hip_prof_api.h index 8589bc0ee6..dd3c3efec9 100644 --- a/include/hip/hcc_detail/hip_prof_api.h +++ b/include/hip/hcc_detail/hip_prof_api.h @@ -127,21 +127,19 @@ typedef activity_sync_callback_t hip_act_callback_t; // HIP API callbacks spawner object macro #define HIP_CB_SPAWNER_OBJECT(CB_ID) \ - if (HIP_API_ID_##CB_ID < HIP_API_ID_NUMBER) { \ - hip_api_data_t api_data{}; \ - INIT_CB_ARGS_DATA(CB_ID, api_data); \ - api_callbacks_spawner_t __api_tracer(HIP_API_ID_##CB_ID, api_data); \ - } + hip_api_data_t api_data{}; \ + INIT_CB_ARGS_DATA(CB_ID, api_data); \ + api_callbacks_spawner_t __api_tracer(HIP_API_ID_##CB_ID, api_data); typedef api_callbacks_table_templ api_callbacks_table_t; extern api_callbacks_table_t callbacks_table; +template class api_callbacks_spawner_t { public: api_callbacks_spawner_t(const hip_api_id_t& cid, hip_api_data_t& api_data) : - cid_(cid), api_data_(api_data), record_({}) { @@ -174,7 +172,6 @@ class api_callbacks_spawner_t { return callbacks_table.entry(id); } - const hip_api_id_t cid_; hip_api_data_t& api_data_; hip_api_record_t record_; @@ -184,6 +181,12 @@ class api_callbacks_spawner_t { void* arg; }; +template <> +class api_callbacks_spawner_t { + public: + api_callbacks_spawner_t(const hip_api_id_t& cid, hip_api_data_t& api_data) {} +}; + #else #define HIP_CB_SPAWNER_OBJECT(x) do {} while(0) diff --git a/include/hip/hcc_detail/hip_prof_str.h b/include/hip/hcc_detail/hip_prof_str.h index 40cd865c2e..512e8a3188 100644 --- a/include/hip/hcc_detail/hip_prof_str.h +++ b/include/hip/hcc_detail/hip_prof_str.h @@ -5,7 +5,6 @@ #include // Dummy API callbacks definition -#define INIT_hipHccModuleLaunchKernel_CB_ARGS_DATA(cb_data) {}; #define INIT_hipHccGetAccelerator_CB_ARGS_DATA(cb_data) {}; #define INIT_hipHccGetAcceleratorView_CB_ARGS_DATA(cb_data) {}; #define INIT_hipDeviceCanAccessPeer2_CB_ARGS_DATA(cb_data) {}; @@ -177,10 +176,10 @@ enum hip_api_id_t { HIP_API_ID_hipModuleGetFunction = 135, HIP_API_ID_hipGetDevice = 136, HIP_API_ID_hipGetDeviceCount = 137, - HIP_API_ID_NUMBER = 138, - HIP_API_ID_ANY = 139, + HIP_API_ID_hipHccModuleLaunchKernel = 138, + HIP_API_ID_NUMBER = 139, + HIP_API_ID_ANY = 140, - HIP_API_ID_hipHccModuleLaunchKernel = HIP_API_ID_NUMBER, HIP_API_ID_hipHccGetAccelerator = HIP_API_ID_NUMBER, HIP_API_ID_hipHccGetAcceleratorView = HIP_API_ID_NUMBER, HIP_API_ID_hipDeviceCanAccessPeer2 = HIP_API_ID_NUMBER, @@ -340,6 +339,7 @@ static const char* hip_api_name(const uint32_t& id) { case HIP_API_ID_hipCtxEnablePeerAccess: return "hipCtxEnablePeerAccess"; case HIP_API_ID_hipMemcpyDtoHAsync: return "hipMemcpyDtoHAsync"; case HIP_API_ID_hipModuleLaunchKernel: return "hipModuleLaunchKernel"; + case HIP_API_ID_hipHccModuleLaunchKernel: return "hipHccModuleLaunchKernel"; case HIP_API_ID_hipModuleGetTexRef: return "hipModuleGetTexRef"; case HIP_API_ID_hipRemoveActivityCallback: return "hipRemoveActivityCallback"; case HIP_API_ID_hipDeviceGetLimit: return "hipDeviceGetLimit"; @@ -907,6 +907,9 @@ struct hip_api_data_t { void** kernelParams; void** extra; } hipModuleLaunchKernel; + struct { + hipFunction_t f; + } hipHccModuleLaunchKernel; struct { textureReference** texRef; hipModule_t hmod; @@ -1526,6 +1529,9 @@ struct hip_api_data_t { cb_data.args.hipModuleLaunchKernel.kernelParams = (void**)kernelParams; \ cb_data.args.hipModuleLaunchKernel.extra = (void**)extra; \ }; +#define INIT_hipHccModuleLaunchKernel_CB_ARGS_DATA(cb_data) { \ + cb_data.args.hipModuleLaunchKernel.f = (hipFunction_t)f; \ +}; #define INIT_hipModuleGetTexRef_CB_ARGS_DATA(cb_data) { \ cb_data.args.hipModuleGetTexRef.texRef = (textureReference**)texRef; \ cb_data.args.hipModuleGetTexRef.hmod = (hipModule_t)hmod; \ @@ -2396,6 +2402,11 @@ const char* hipApiString(hip_api_id_t id, const hip_api_data_t* data) { << " extra=" << data->args.hipModuleLaunchKernel.extra << ")"; break; + case HIP_API_ID_hipHccModuleLaunchKernel: + oss << "hipHccModuleLaunchKernel(" + << " f=" << data->args.hipHccModuleLaunchKernel.f << "," + << ")"; + break; case HIP_API_ID_hipModuleGetTexRef: oss << "hipModuleGetTexRef(" << " texRef=" << data->args.hipModuleGetTexRef.texRef << "," From 091124a7667c93620ca5cd46623fad5306a3b6d2 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 13 Nov 2018 15:50:34 +0000 Subject: [PATCH 25/55] rebase to master, tracer related changes --- include/hip/hcc_detail/hip_prof_str.h | 34 +++++++-------------------- src/hip_clang.cpp | 6 ++--- src/hip_stream.cpp | 6 ++--- 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/include/hip/hcc_detail/hip_prof_str.h b/include/hip/hcc_detail/hip_prof_str.h index 512e8a3188..9fe681c18d 100644 --- a/include/hip/hcc_detail/hip_prof_str.h +++ b/include/hip/hcc_detail/hip_prof_str.h @@ -5,6 +5,7 @@ #include // Dummy API callbacks definition +#define INIT_NONE_CB_ARGS_DATA(cb_data) {}; #define INIT_hipHccGetAccelerator_CB_ARGS_DATA(cb_data) {}; #define INIT_hipHccGetAcceleratorView_CB_ARGS_DATA(cb_data) {}; #define INIT_hipDeviceCanAccessPeer2_CB_ARGS_DATA(cb_data) {}; @@ -35,6 +36,9 @@ #define INIT_hipGetErrorString_CB_ARGS_DATA(cb_data) {}; #define INIT_hipCreateSurfaceObject_CB_ARGS_DATA(cb_data) {}; #define INIT_hipDestroySurfaceObject_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipStreamCreateWithPriority_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipDeviceGetStreamPriorityRange_CB_ARGS_DATA(cb_data) {}; +#define INIT_hipStreamGetPriority_CB_ARGS_DATA(cb_data) {}; // HIP API callbacks ID enumaration enum hip_api_id_t { @@ -180,6 +184,7 @@ enum hip_api_id_t { HIP_API_ID_NUMBER = 139, HIP_API_ID_ANY = 140, + HIP_API_ID_NONE = HIP_API_ID_NUMBER, HIP_API_ID_hipHccGetAccelerator = HIP_API_ID_NUMBER, HIP_API_ID_hipHccGetAcceleratorView = HIP_API_ID_NUMBER, HIP_API_ID_hipDeviceCanAccessPeer2 = HIP_API_ID_NUMBER, @@ -210,6 +215,9 @@ enum hip_api_id_t { HIP_API_ID_hipGetErrorString = HIP_API_ID_NUMBER, HIP_API_ID_hipCreateSurfaceObject = HIP_API_ID_NUMBER, HIP_API_ID_hipDestroySurfaceObject = HIP_API_ID_NUMBER, + HIP_API_ID_hipStreamCreateWithPriority = HIP_API_ID_NUMBER, + HIP_API_ID_hipDeviceGetStreamPriorityRange = HIP_API_ID_NUMBER, + HIP_API_ID_hipStreamGetPriority = HIP_API_ID_NUMBER, }; // Return HIP API string @@ -339,7 +347,6 @@ static const char* hip_api_name(const uint32_t& id) { case HIP_API_ID_hipCtxEnablePeerAccess: return "hipCtxEnablePeerAccess"; case HIP_API_ID_hipMemcpyDtoHAsync: return "hipMemcpyDtoHAsync"; case HIP_API_ID_hipModuleLaunchKernel: return "hipModuleLaunchKernel"; - case HIP_API_ID_hipHccModuleLaunchKernel: return "hipHccModuleLaunchKernel"; case HIP_API_ID_hipModuleGetTexRef: return "hipModuleGetTexRef"; case HIP_API_ID_hipRemoveActivityCallback: return "hipRemoveActivityCallback"; case HIP_API_ID_hipDeviceGetLimit: return "hipDeviceGetLimit"; @@ -2498,29 +2505,4 @@ const char* hipApiString(hip_api_id_t id, const hip_api_data_t* data) { }; #endif -// HIP API activity record type -// Base record type -struct hip_act_record_t { - uint32_t domain; // activity domain id - uint32_t op_id; // operation id, dispatch/copy/barrier - uint32_t activity_kind; // activity kind - uint64_t correlation_id; // activity correlation ID - uint64_t begin_ns; // host begin timestamp, nano-seconds - uint64_t end_ns; // host end timestamp, nano-seconds -}; -// Async record type -struct hip_async_record_t : hip_act_record_t { - int device_id; - uint64_t stream_id; -}; -// Dispatch record type -struct hip_dispatch_record_t : hip_async_record_t {}; -// Barrier record type -struct hip_barrier_record_t : hip_async_record_t {}; -// Memcpy record type -struct hip_copy_record_t : hip_async_record_t { - size_t bytes; -}; -// Generic async operation record -typedef hip_copy_record_t hip_ops_record_t; #endif // _HIP_CBSTR diff --git a/src/hip_clang.cpp b/src/hip_clang.cpp index 44080884e7..fe08bbe45c 100644 --- a/src/hip_clang.cpp +++ b/src/hip_clang.cpp @@ -159,7 +159,7 @@ extern "C" void __hipRegisterFunction( dim3* gridDim, int* wSize) { - HIP_INIT_API(modules, hostFunction, deviceFunction, deviceName); + HIP_INIT_API(NONE, modules, hostFunction, deviceFunction, deviceName); std::vector functions{g_deviceCnt}; assert(modules && modules->size() >= g_deviceCnt); @@ -214,7 +214,7 @@ hipError_t hipSetupArgument( size_t size, size_t offset) { - HIP_INIT_API(arg, size, offset); + HIP_INIT_API(hipSetupArgument, arg, size, offset); auto ctx = ihipGetTlsDefaultCtx(); LockedAccessor_CtxCrit_t crit(ctx->criticalData()); auto& arguments = crit->_execStack.top()._arguments; @@ -229,7 +229,7 @@ hipError_t hipSetupArgument( hipError_t hipLaunchByPtr(const void *hostFunction) { - HIP_INIT_API(hostFunction); + HIP_INIT_API(hipLaunchByPtr, hostFunction); ihipExec_t exec; { auto ctx = ihipGetTlsDefaultCtx(); diff --git a/src/hip_stream.cpp b/src/hip_stream.cpp index 86c323a8b6..5331b41576 100644 --- a/src/hip_stream.cpp +++ b/src/hip_stream.cpp @@ -104,7 +104,7 @@ hipError_t hipStreamCreate(hipStream_t* stream) { //--- hipError_t hipStreamCreateWithPriority(hipStream_t* stream, unsigned int flags, int priority) { - HIP_INIT_API(stream, flags, priority); + HIP_INIT_API(hipStreamCreateWithPriority, stream, flags, priority); // clamp priority to range [priority_high:priority_low] priority = (priority < priority_high ? priority_high : (priority > priority_low ? priority_low : priority)); @@ -113,7 +113,7 @@ hipError_t hipStreamCreateWithPriority(hipStream_t* stream, unsigned int flags, //--- hipError_t hipDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPriority) { - HIP_INIT_API(leastPriority, greatestPriority); + HIP_INIT_API(hipDeviceGetStreamPriorityRange, leastPriority, greatestPriority); if (leastPriority != NULL) *leastPriority = priority_low; if (greatestPriority != NULL) *greatestPriority = priority_high; @@ -229,7 +229,7 @@ hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int* flags) { //-- hipError_t hipStreamGetPriority(hipStream_t stream, int* priority) { - HIP_INIT_API(stream, priority); + HIP_INIT_API(hipStreamGetPriority, stream, priority); if (priority == NULL) { return ihipLogStatus(hipErrorInvalidValue); From 999b62b71103ea6be742fbbf982f19c27fd2574a Mon Sep 17 00:00:00 2001 From: Michael Kuron Date: Thu, 15 Nov 2018 09:48:00 +0100 Subject: [PATCH 26/55] Fix hipGetSymbolAddress/hipGetSymbolSize on nvcc --- include/hip/nvcc_detail/hip_runtime_api.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hip/nvcc_detail/hip_runtime_api.h b/include/hip/nvcc_detail/hip_runtime_api.h index 88867567c9..02c4b7ee61 100644 --- a/include/hip/nvcc_detail/hip_runtime_api.h +++ b/include/hip/nvcc_detail/hip_runtime_api.h @@ -552,11 +552,11 @@ inline static hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolN } inline static hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName) { - return hipCUDAErrorTohipError(cudaGetSymbolAddress(devPtr, symbolName); + return hipCUDAErrorTohipError(cudaGetSymbolAddress(devPtr, symbolName)); } inline static hipError_t hipGetSymbolSize(size_t* size, const void* symbolName) { - return hipCUDAErrorTohipError(cudaGetSymbolSize(size, symbolName); + return hipCUDAErrorTohipError(cudaGetSymbolSize(size, symbolName)); } inline static hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, From aad5858cb16c2dfa95557ff86fd3187dca6cbca4 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 16 Nov 2018 01:23:25 +0300 Subject: [PATCH 27/55] [HIPIFY][LLVMCompat] support of upcoming LLVM 8.0 + StringRef issue, which is finally moved to LLVM from Clang + Renamed getBeginLoc() and getEndLoc() resolution for Expr and TypeLoc classes + Support all the previous LLVM versions via LLVCompat --- hipify-clang/src/HipifyAction.cpp | 10 ++++----- hipify-clang/src/HipifyAction.h | 1 + hipify-clang/src/LLVMCompat.cpp | 36 +++++++++++++++++++++++++++++-- hipify-clang/src/LLVMCompat.h | 10 ++++++++- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/hipify-clang/src/HipifyAction.cpp b/hipify-clang/src/HipifyAction.cpp index ce185c39a8..b370df794e 100644 --- a/hipify-clang/src/HipifyAction.cpp +++ b/hipify-clang/src/HipifyAction.cpp @@ -270,14 +270,14 @@ bool HipifyAction::cudaLaunchKernel(const clang::ast_matchers::MatchFinder::Matc if (numArgs > 0) { OS << ", "; // Start of the first argument. - clang::SourceLocation argStart = launchKernel->getArg(0)->getLocStart(); + clang::SourceLocation argStart = llcompat::getBeginLoc(launchKernel->getArg(0)); // End of the last argument. - clang::SourceLocation argEnd = launchKernel->getArg(numArgs - 1)->getLocEnd(); + clang::SourceLocation argEnd = llcompat::getEndLoc(launchKernel->getArg(numArgs - 1)); OS << readSourceText(*SM, {argStart, argEnd}); } OS << ")"; - clang::SourceRange replacementRange = getWriteRange(*SM, {launchKernel->getLocStart(), launchKernel->getLocEnd()}); + clang::SourceRange replacementRange = getWriteRange(*SM, {llcompat::getBeginLoc(launchKernel), llcompat::getEndLoc(launchKernel)}); clang::SourceLocation launchStart = replacementRange.getBegin(); clang::SourceLocation launchEnd = replacementRange.getEnd(); size_t length = SM->getCharacterData(clang::Lexer::getLocForEndOfToken(launchEnd, 0, *SM, DefaultLangOptions)) - SM->getCharacterData(launchStart); @@ -320,8 +320,8 @@ bool HipifyAction::cudaSharedIncompleteArrayVar(const clang::ast_matchers::Match } if (!typeName.empty()) { - clang::SourceLocation slStart = sharedVar->getLocStart(); - clang::SourceLocation slEnd = sharedVar->getLocEnd(); + clang::SourceLocation slStart = llcompat::getBeginLoc(sharedVar->getTypeSourceInfo()->getTypeLoc()); + clang::SourceLocation slEnd = llcompat::getEndLoc(sharedVar->getTypeSourceInfo()->getTypeLoc()); clang::SourceManager* SM = Result.SourceManager; size_t repLength = SM->getCharacterData(slEnd) - SM->getCharacterData(slStart) + 1; std::string varName = sharedVar->getNameAsString(); diff --git a/hipify-clang/src/HipifyAction.h b/hipify-clang/src/HipifyAction.h index 7b54dddf54..9d30a72592 100644 --- a/hipify-clang/src/HipifyAction.h +++ b/hipify-clang/src/HipifyAction.h @@ -9,6 +9,7 @@ #include "Statistics.h" namespace ct = clang::tooling; +using namespace llvm; /** * A FrontendAction that hipifies CUDA programs. diff --git a/hipify-clang/src/LLVMCompat.cpp b/hipify-clang/src/LLVMCompat.cpp index 4ab62310d6..611bb28cbe 100644 --- a/hipify-clang/src/LLVMCompat.cpp +++ b/hipify-clang/src/LLVMCompat.cpp @@ -8,11 +8,11 @@ void PrintStackTraceOnErrorSignal() { #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 8) llvm::sys::PrintStackTraceOnErrorSignal(); #else - llvm::sys::PrintStackTraceOnErrorSignal(clang::StringRef()); + llvm::sys::PrintStackTraceOnErrorSignal(StringRef()); #endif } -ct::Replacements& getReplacements(ct::RefactoringTool& Tool, clang::StringRef file) { +ct::Replacements& getReplacements(ct::RefactoringTool& Tool, StringRef file) { #if LLVM_VERSION_MAJOR > 3 // getReplacements() now returns a map from filename to Replacements - so create an entry // for this source file and return a reference to it. @@ -40,4 +40,36 @@ void EnterPreprocessorTokenStream(clang::Preprocessor& _pp, const clang::Token * #endif } +clang::SourceLocation getBeginLoc(const clang::Stmt* stmt) { +#if LLVM_VERSION_MAJOR < 8 + return stmt->getLocStart(); +#else + return stmt->getBeginLoc(); +#endif +} + +clang::SourceLocation getBeginLoc(const clang::TypeLoc& typeLoc) { +#if LLVM_VERSION_MAJOR < 8 + return typeLoc.getLocStart(); +#else + return typeLoc.getBeginLoc(); +#endif +} + +clang::SourceLocation getEndLoc(const clang::Stmt* stmt) { +#if LLVM_VERSION_MAJOR < 8 + return stmt->getLocEnd(); +#else + return stmt->getEndLoc(); +#endif +} + +clang::SourceLocation getEndLoc(const clang::TypeLoc& typeLoc) { +#if LLVM_VERSION_MAJOR < 8 + return typeLoc.getLocEnd(); +#else + return typeLoc.getEndLoc(); +#endif +} + } // namespace llcompat diff --git a/hipify-clang/src/LLVMCompat.h b/hipify-clang/src/LLVMCompat.h index 9f82e36a1f..a43af857bf 100644 --- a/hipify-clang/src/LLVMCompat.h +++ b/hipify-clang/src/LLVMCompat.h @@ -25,15 +25,23 @@ namespace llcompat { #define LLVM_DEBUG(X) DEBUG(X) #endif +clang::SourceLocation getBeginLoc(const clang::Stmt* stmt); +clang::SourceLocation getBeginLoc(const clang::TypeLoc& typeLoc); + +clang::SourceLocation getEndLoc(const clang::Stmt* stmt); +clang::SourceLocation getEndLoc(const clang::TypeLoc& typeLoc); + void PrintStackTraceOnErrorSignal(); +using namespace llvm; + /** * Get the replacement map for a given filename in a RefactoringTool. * * Older LLVM versions don't actually support multiple filenames, so everything all gets * smushed together. It is the caller's responsibility to cope with this. */ -ct::Replacements& getReplacements(ct::RefactoringTool& Tool, clang::StringRef file); +ct::Replacements& getReplacements(ct::RefactoringTool& Tool, StringRef file); /** * Add a Replacement to a Replacements. From 1a038879a9dc135e6ce033a8df71c4ba69402b7e Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Sat, 17 Nov 2018 05:38:35 +0530 Subject: [PATCH 28/55] Fix hipHostRegister --- src/hip_memory.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/hip_memory.cpp b/src/hip_memory.cpp index 7c25b714f8..2688307017 100644 --- a/src/hip_memory.cpp +++ b/src/hip_memory.cpp @@ -909,14 +909,22 @@ hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags) } am_status = hc::am_memory_host_lock(device->_acc, hostPtr, sizeBytes, &vecAcc[0], vecAcc.size()); -#if USE_APP_PTR_FOR_CTX - hc::am_memtracker_update(hostPtr, device->_deviceId, flags, ctx); -#else - hc::am_memtracker_update(hostPtr, device->_deviceId, flags); -#endif + if ( am_status == AM_SUCCESS ) { + am_status = hc::am_memtracker_getinfo(&amPointerInfo, hostPtr); - tprintf(DB_MEM, " %s registered ptr=%p and allowed access to %zu peers\n", __func__, - hostPtr, vecAcc.size()); + if ( am_status == AM_SUCCESS ) { + void *devPtr = amPointerInfo._devicePointer; + #if USE_APP_PTR_FOR_CTX + hc::am_memtracker_update(hostPtr, device->_deviceId, flags, ctx); + hc::am_memtracker_update(devPtr, device->_deviceId, flags, ctx); + #else + hc::am_memtracker_update(hostPtr, device->_deviceId, flags); + hc::am_memtracker_update(devPtr, device->_deviceId, flags); + #endif + tprintf(DB_MEM, " %s registered ptr=%p and allowed access to %zu peers\n", __func__, + hostPtr, vecAcc.size()); + }; + }; if (am_status == AM_SUCCESS) { hip_status = hipSuccess; } else { From 884a5f1ca7f7c529d96ba1edde9272e9e48faf96 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 19 Nov 2018 14:31:40 +0530 Subject: [PATCH 29/55] [ci] Renable excluded tests Regressions caused by dependent components have been fixed or workaround put in place. Change-Id: I9ecaf0a4a645d9222f12d2c45291f2b23984b72b --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6d37f10e3c..e6b60f398e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -167,8 +167,6 @@ def docker_build_inside_image( def build_image, String inside_args, String platf } // Cap the maximum amount of testing, in case of hangs - // Excluding hipVectorTypes test from automation; due to regression from HCC commit 2367133 - // Excluding hipFloatMath test from automation; due to regression from ROCDL commit 2fc04e1 timeout(time: 1, unit: 'HOURS') { stage("${platform} unit testing") @@ -178,7 +176,7 @@ def docker_build_inside_image( def build_image, String inside_args, String platf cd ${build_dir_rel} make install -j\$(nproc) make build_tests -i -j\$(nproc) - ctest -E "(hipVectorTypes.tst|hipVectorTypesDevice.tst|hipFloatMath.tst)" + ctest """ // If unit tests output a junit or xunit file in the future, jenkins can parse that file // to display test results on the dashboard From cfabad43540a6d04c8ce7fcd7a102edf718eaaf2 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 19 Nov 2018 20:00:05 +0300 Subject: [PATCH 30/55] [HIPIFY] CUDA Driver API functions total revise (up to CUDA 10.0) + for all CUDA versions + add missing types + fix typos + sync with HIP + update CUDA_Driver_API_functions_supported_by_HIP.md + formatting, annotating --- ...A_Driver_API_functions_supported_by_HIP.md | 43 +- ..._Runtime_API_functions_supported_by_HIP.md | 20 +- .../src/CUDA2HIP_Driver_API_functions.cpp | 1070 +++++++++++------ .../src/CUDA2HIP_Driver_API_types.cpp | 6 +- .../src/CUDA2HIP_Runtime_API_functions.cpp | 124 +- 5 files changed, 858 insertions(+), 405 deletions(-) diff --git a/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md b/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md index 9906ca6fa6..b4f379879b 100644 --- a/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md +++ b/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md @@ -22,8 +22,8 @@ | typedef |`CUDA_RESOURCE_VIEW_DESC_st` | | | struct |`CUDA_TEXTURE_DESC` | | | typedef |`CUDA_TEXTURE_DESC_st` | | -| struct |`CUdevprop` |`hipDeviceProp_t` | -| typedef |`CUdevprop_st` |`hipDeviceProp_t` | +| struct |`CUdevprop` | | +| typedef |`CUdevprop_st` | | | struct |`CUipcEventHandle` |`ihipIpcEventHandle_t` | | typedef |`CUipcEventHandle_st` |`ihipIpcEventHandle_t` | | struct |`CUipcMemHandle` |`hipIpcMemHandle_t` | @@ -763,6 +763,7 @@ | `cuDeviceGetName` | `hipDeviceGetName` | | `cuDeviceTotalMem` | `hipDeviceTotalMem` | | `cuDeviceGetLuid` | | +| `cuDeviceGetUuid` | | ## **6. Device Management [DEPRECATED]** @@ -792,9 +793,9 @@ | `cuCtxGetCurrent` | `hipCtxGetCurrent` | | `cuCtxGetDevice` | `hipCtxGetDevice` | | `cuCtxGetFlags` | `hipCtxGetFlags` | -| `cuCtxGetLimit` | | +| `cuCtxGetLimit` | `hipDeviceGetLimit` | | `cuCtxGetSharedMemConfig` | `hipCtxGetSharedMemConfig` | -| `cuCtxGetStreamPriorityRange` | | +| `cuCtxGetStreamPriorityRange` | `hipDeviceGetStreamPriorityRange`| | `cuCtxPopCurrent` | `hipCtxPopCurrent` | | `cuCtxPushCurrent` | `hipCtxPushCurrent` | | `cuCtxSetCacheConfig` | `hipCtxSetCacheConfig` | @@ -835,16 +836,16 @@ |-----------------------------------------------------------|-------------------------------| | `cuArray3DCreate` | `hipArray3DCreate` | | `cuArray3DGetDescriptor` | | -| `cuArrayCreate` | | +| `cuArrayCreate` | `hipArrayCreate` | | `cuArrayDestroy` | | | `cuArrayGetDescriptor` | | | `cuDeviceGetByPCIBusId` | `hipDeviceGetByPCIBusId` | | `cuDeviceGetPCIBusId` | `hipDeviceGetPCIBusId` | -| `cuIpcCloseMemHandle` | | +| `cuIpcCloseMemHandle` | `hipIpcCloseMemHandle` | | `cuIpcGetEventHandle` | | -| `cuIpcGetMemHandle` | | +| `cuIpcGetMemHandle` | `hipIpcGetMemHandle` | | `cuIpcOpenEventHandle` | | -| `cuIpcOpenMemHandle` | | +| `cuIpcOpenMemHandle` | `hipIpcOpenMemHandle` | | `cuMemAlloc` | `hipMalloc` | | `cuMemAllocHost` | | | `cuMemAllocManaged` | | @@ -867,7 +868,7 @@ | `cuMemcpyDtoDAsync` | `hipMemcpyDtoDAsync` | | `cuMemcpyDtoH` | `hipMemcpyDtoH` | | `cuMemcpyDtoHAsync` | `hipMemcpyDtoHAsync` | -| `cuMemcpyHtoA` | | +| `cuMemcpyHtoA` | `hipMemcpyHtoA` | | `cuMemcpyHtoAAsync` | | | `cuMemcpyHtoD` | `hipMemcpyHtoD` | | `cuMemcpyHtoDAsync` | `hipMemcpyHtoDAsync` | @@ -875,11 +876,11 @@ | `cuMemcpyPeerAsync` | | | `cuMemFree` | `hipFree` | | `cuMemFreeHost` | `hipFreeHost` | -| `cuMemGetAddressRange` | | +| `cuMemGetAddressRange` | `hipMemGetAddressRange` | | `cuMemGetInfo` | `hipMemGetInfo` | | `cuMemHostAlloc` | `hipHostMalloc` | -| `cuMemHostGetDevicePointer` | | -| `cuMemHostGetFlags` | | +| `cuMemHostGetDevicePointer` | `hipHostGetDevicePointer` | +| `cuMemHostGetFlags` | `hipHostGetFlags` | | `cuMemHostRegister` | `hipHostRegister` | | `cuMemHostUnregister` | `hipHostUnregister` | | `cuMemsetD16` | | @@ -892,8 +893,8 @@ | `cuMemsetD2D8Async` | | | `cuMemsetD32` | `hipMemset` | | `cuMemsetD32Async` | `hipMemsetAsync` | -| `cuMemsetD2D8` | | -| `cuMemsetD2D8Async` | | +| `cuMemsetD8` | `hipMemsetD8` | +| `cuMemsetD8Async` | | | `cuMipmappedArrayCreate` | | | `cuMipmappedArrayDestroy` | | | `cuMipmappedArrayGetLevel` | | @@ -916,8 +917,8 @@ |-----------------------------------------------------------|-------------------------------| | `cuStreamAddCallback` | `hipStreamAddCallback` | | `cuStreamAttachMemAsync` | | -| `cuStreamCreate` | | -| `cuStreamCreateWithPriority` | | +| `cuStreamCreate` | `hipStreamCreateWithFlags` | +| `cuStreamCreateWithPriority` | `hipStreamCreateWithPriority` | | `cuStreamDestroy` | `hipStreamDestroy` | | `cuStreamGetFlags` | `hipStreamGetFlags` | | `cuStreamGetPriority` | `hipStreamGetPriority` | @@ -932,7 +933,7 @@ | **CUDA** | **HIP** | |-----------------------------------------------------------|-------------------------------| -| `cuEventCreate` | `hipEventCreate` | +| `cuEventCreate` | `hipEventCreateWithFlags` | | `cuEventDestroy` | `hipEventDestroy` | | `cuEventElapsedTime` | `hipEventElapsedTime` | | `cuEventQuery` | `hipEventQuery` | @@ -967,10 +968,13 @@ | **CUDA** | **HIP** | |-----------------------------------------------------------|-------------------------------| | `cuFuncGetAttribute` | | +| `cuFuncSetAttribute` | | | `cuFuncSetCacheConfig` | `hipFuncSetCacheConfig` | | `cuFuncSetSharedMemConfig` | | | `cuLaunchKernel` | `hipModuleLaunchKernel` | | `cuLaunchHostFunc` | | +| `cuLaunchCooperativeKernel` | | +| `cuLaunchCooperativeKernelMultiDevice` | | ## **18. Execution Control [DEPRECATED]** @@ -1047,8 +1051,8 @@ | `cuTexRefGetMipmapLevelBias` | | | `cuTexRefGetMipmapLevelClamp` | | | `cuTexRefGetMipmappedArray` | | -| `cuTexRefSetAddress` | | -| `cuTexRefSetAddress2D` | | +| `cuTexRefSetAddress` | `hipTexRefSetAddress` | +| `cuTexRefSetAddress2D` | `hipTexRefSetAddress2D` | | `cuTexRefSetAddressMode` | `hipTexRefSetAddressMode` | | `cuTexRefSetArray` | `hipTexRefSetArray` | | `cuTexRefSetBorderColor` | | @@ -1233,3 +1237,4 @@ | `cuEGLStreamProducerReturnFrame` | | | `cuGraphicsEGLRegisterImage` | | | `cuGraphicsResourceGetMappedEglFrame` | | +| `cuEventCreateFromEGLSync` | | diff --git a/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md b/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md index 1a55667f82..6190f6565a 100644 --- a/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md +++ b/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md @@ -11,7 +11,7 @@ | `cudaDeviceGetLimit` | `hipDeviceGetLimit` | | `cudaDeviceGetPCIBusId` | `hipDeviceGetPCIBusId` | | `cudaDeviceGetSharedMemConfig` | `hipDeviceGetSharedMemConfig` | -| `cudaDeviceGetStreamPriorityRange` | | +| `cudaDeviceGetStreamPriorityRange` | `hipDeviceGetStreamPriorityRange` | | `cudaDeviceReset` | `hipDeviceReset` | | `cudaDeviceSetCacheConfig` | `hipDeviceSetCacheConfig` | | `cudaDeviceSetLimit` | `hipDeviceSetLimit` | @@ -19,7 +19,7 @@ | `cudaDeviceSynchronize` | `hipDeviceSynchronize` | | `cudaGetDevice` | `hipGetDevice` | | `cudaGetDeviceCount` | `hipGetDeviceCount` | -| `cudaGetDeviceFlags` | | +| `cudaGetDeviceFlags` | `hipCtxGetFlags` | | `cudaGetDeviceProperties` | `hipGetDeviceProperties` | | `cudaIpcCloseMemHandle` | `hipIpcCloseMemHandle` | | `cudaIpcGetEventHandle` | `hipIpcGetEventHandle` | @@ -56,12 +56,15 @@ |-----------------------------------------------------------|-------------------------------| | `cudaStreamAddCallback` | `hipStreamAddCallback` | | `cudaStreamAttachMemAsync` | | +| `cudaStreamBeginCapture` | | +| `cudaStreamEndCapture` | | +| `cudaStreamIsCapturing` | | | `cudaStreamCreate` | `hipStreamCreate` | | `cudaStreamCreateWithFlags` | `hipStreamCreateWithFlags` | -| `cudaStreamCreateWithPriority` | | +| `cudaStreamCreateWithPriority` | `hipStreamCreateWithPriority` | | `cudaStreamDestroy` | `hipStreamDestroy` | | `cudaStreamGetFlags` | `hipStreamGetFlags` | -| `cudaStreamGetPriority` | | +| `cudaStreamGetPriority` | `hipStreamGetPriority` | | `cudaStreamQuery` | `hipStreamQuery` | | `cudaStreamSynchronize` | `hipStreamSynchronize` | | `cudaStreamWaitEvent` | `hipStreamWaitEvent` | @@ -82,7 +85,14 @@ | **CUDA** | **HIP** | |-----------------------------------------------------------|-------------------------------| - +| `cudaSignalExternalSemaphoresAsync` | | +| `cudaWaitExternalSemaphoresAsync` | | +| `cudaImportExternalMemory` | | +| `cudaExternalMemoryGetMappedBuffer` | | +| `cudaExternalMemoryGetMappedMipmappedArray` | | +| `cudaDestroyExternalMemory` | | +| `cudaImportExternalSemaphore` | | +| `cudaDestroyExternalSemaphore` | | ## **7. Execution Control** diff --git a/hipify-clang/src/CUDA2HIP_Driver_API_functions.cpp b/hipify-clang/src/CUDA2HIP_Driver_API_functions.cpp index d74c4d4f1a..77dd67fd03 100644 --- a/hipify-clang/src/CUDA2HIP_Driver_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_Driver_API_functions.cpp @@ -1,399 +1,753 @@ #include "CUDA2HIP.h" - -// Map of all functions +// Map of all CUDA Driver API functions const std::map CUDA_DRIVER_FUNCTION_MAP{ + // 5.2. Error Handling + // no analogue + // NOTE: cudaGetErrorName and hipGetErrorName have different signature + {"cuGetErrorName", {"hipGetErrorName_", CONV_ERROR, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: cudaGetErrorString and hipGetErrorString have different signature + {"cuGetErrorString", {"hipGetErrorString_", CONV_ERROR, API_DRIVER, HIP_UNSUPPORTED}}, - ///////////////////////////// CUDA DRIVER API ///////////////////////////// + // 5.3. Initialization + // no analogue + {"cuInit", {"hipInit", CONV_INIT, API_DRIVER}}, - // Error Handling - {"cuGetErrorName", {"hipGetErrorName___", CONV_ERROR, API_DRIVER, HIP_UNSUPPORTED}}, // cudaGetErrorName (hipGetErrorName) has different signature - {"cuGetErrorString", {"hipGetErrorString___", CONV_ERROR, API_DRIVER, HIP_UNSUPPORTED}}, // cudaGetErrorString (hipGetErrorString) has different signature + // 5.4 Version Management + // cudaDriverGetVersion + {"cuDriverGetVersion", {"hipDriverGetVersion", CONV_VERSION, API_DRIVER}}, - // Init - {"cuInit", {"hipInit", CONV_INIT, API_DRIVER}}, + // 5.5. Device Management + // cudaGetDevice + // NOTE: cudaGetDevice has additional attr: int ordinal + {"cuDeviceGet", {"hipGetDevice", CONV_DEVICE, API_DRIVER}}, + // cudaDeviceGetAttribute + {"cuDeviceGetAttribute", {"hipDeviceGetAttribute", CONV_DEVICE, API_DRIVER}}, + // cudaGetDeviceCount + {"cuDeviceGetCount", {"hipGetDeviceCount", CONV_DEVICE, API_DRIVER}}, + // no analogue + {"cuDeviceGetLuid", {"hipDeviceGetLuid", CONV_DEVICE, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuDeviceGetName", {"hipDeviceGetName", CONV_DEVICE, API_DRIVER}}, + // no analogue + {"cuDeviceGetUuid", {"hipDeviceGetUuid", CONV_DEVICE, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuDeviceTotalMem", {"hipDeviceTotalMem", CONV_DEVICE, API_DRIVER}}, + {"cuDeviceTotalMem_v2", {"hipDeviceTotalMem", CONV_DEVICE, API_DRIVER}}, - // Driver - {"cuDriverGetVersion", {"hipDriverGetVersion", CONV_VERSION, API_DRIVER}}, + // 5.6. Device Management [DEPRECATED] + {"cuDeviceComputeCapability", {"hipDeviceComputeCapability", CONV_DEVICE, API_DRIVER}}, + {"cuDeviceGetProperties", {"hipGetDeviceProperties", CONV_DEVICE, API_DRIVER}}, - // Context Management - {"cuCtxCreate_v2", {"hipCtxCreate", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxDestroy_v2", {"hipCtxDestroy", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxGetApiVersion", {"hipCtxGetApiVersion", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxGetCacheConfig", {"hipCtxGetCacheConfig", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxGetCurrent", {"hipCtxGetCurrent", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxGetDevice", {"hipCtxGetDevice", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxGetFlags", {"hipCtxGetFlags", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxGetLimit", {"hipCtxGetLimit", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuCtxGetSharedMemConfig", {"hipCtxGetSharedMemConfig", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxGetStreamPriorityRange", {"hipCtxGetStreamPriorityRange", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuCtxPopCurrent_v2", {"hipCtxPopCurrent", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxPushCurrent_v2", {"hipCtxPushCurrent", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxSetCacheConfig", {"hipCtxSetCacheConfig", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxSetCurrent", {"hipCtxSetCurrent", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxSetLimit", {"hipCtxSetLimit", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuCtxSetSharedMemConfig", {"hipCtxSetSharedMemConfig", CONV_CONTEXT, API_DRIVER}}, - {"cuCtxSynchronize", {"hipCtxSynchronize", CONV_CONTEXT, API_DRIVER}}, - // Context Management [DEPRECATED] - {"cuCtxAttach", {"hipCtxAttach", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuCtxDetach", {"hipCtxDetach", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.7. Primary Context Management + // no analogues + {"cuDevicePrimaryCtxGetState", {"hipDevicePrimaryCtxGetState", CONV_CONTEXT, API_DRIVER}}, + {"cuDevicePrimaryCtxRelease", {"hipDevicePrimaryCtxRelease", CONV_CONTEXT, API_DRIVER}}, + {"cuDevicePrimaryCtxReset", {"hipDevicePrimaryCtxReset", CONV_CONTEXT, API_DRIVER}}, + {"cuDevicePrimaryCtxRetain", {"hipDevicePrimaryCtxRetain", CONV_CONTEXT, API_DRIVER}}, + {"cuDevicePrimaryCtxSetFlags", {"hipDevicePrimaryCtxSetFlags", CONV_CONTEXT, API_DRIVER}}, - // Primary Context Management - {"cuDevicePrimaryCtxGetState", {"hipDevicePrimaryCtxGetState", CONV_CONTEXT, API_DRIVER}}, - {"cuDevicePrimaryCtxRelease", {"hipDevicePrimaryCtxRelease", CONV_CONTEXT, API_DRIVER}}, - {"cuDevicePrimaryCtxReset", {"hipDevicePrimaryCtxReset", CONV_CONTEXT, API_DRIVER}}, - {"cuDevicePrimaryCtxRetain", {"hipDevicePrimaryCtxRetain", CONV_CONTEXT, API_DRIVER}}, - {"cuDevicePrimaryCtxSetFlags", {"hipDevicePrimaryCtxSetFlags", CONV_CONTEXT, API_DRIVER}}, + // 5.8. Context Management + // no analogues, except a few + {"cuCtxCreate", {"hipCtxCreate", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxCreate_v2", {"hipCtxCreate", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxDestroy", {"hipCtxDestroy", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxDestroy_v2", {"hipCtxDestroy", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxGetApiVersion", {"hipCtxGetApiVersion", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxGetCacheConfig", {"hipCtxGetCacheConfig", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxGetCurrent", {"hipCtxGetCurrent", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxGetDevice", {"hipCtxGetDevice", CONV_CONTEXT, API_DRIVER}}, + // cudaGetDeviceFlags + // TODO: rename to hipGetDeviceFlags + {"cuCtxGetFlags", {"hipCtxGetFlags", CONV_CONTEXT, API_DRIVER}}, + // cudaDeviceGetLimit + {"cuCtxGetLimit", {"hipDeviceGetLimit", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxGetSharedMemConfig", {"hipCtxGetSharedMemConfig", CONV_CONTEXT, API_DRIVER}}, + // cudaDeviceGetStreamPriorityRange + {"cuCtxGetStreamPriorityRange", {"hipDeviceGetStreamPriorityRange", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxPopCurrent", {"hipCtxPopCurrent", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxPopCurrent_v2", {"hipCtxPopCurrent", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxPushCurrent", {"hipCtxPushCurrent", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxPushCurrent_v2", {"hipCtxPushCurrent", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxSetCacheConfig", {"hipCtxSetCacheConfig", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxSetCurrent", {"hipCtxSetCurrent", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxSetLimit", {"hipCtxSetLimit", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuCtxSetSharedMemConfig", {"hipCtxSetSharedMemConfig", CONV_CONTEXT, API_DRIVER}}, + {"cuCtxSynchronize", {"hipCtxSynchronize", CONV_CONTEXT, API_DRIVER}}, - // 1. Device Management - {"cuDeviceGet", {"hipGetDevice", CONV_DEVICE, API_DRIVER}}, - {"cuDeviceGetName", {"hipDeviceGetName", CONV_DEVICE, API_DRIVER}}, - {"cuDeviceGetCount", {"hipGetDeviceCount", CONV_DEVICE, API_DRIVER}}, - {"cuDeviceGetAttribute", {"hipDeviceGetAttribute", CONV_DEVICE, API_DRIVER}}, - {"cuDeviceGetPCIBusId", {"hipDeviceGetPCIBusId", CONV_DEVICE, API_DRIVER}}, - {"cuDeviceGetByPCIBusId", {"hipDeviceGetByPCIBusId", CONV_DEVICE, API_DRIVER}}, - {"cuDeviceTotalMem_v2", {"hipDeviceTotalMem", CONV_DEVICE, API_DRIVER}}, - {"cuDeviceGetLuid", {"hipDeviceGetLuid", CONV_DEVICE, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.9. Context Management [DEPRECATED] + // no analogues + {"cuCtxAttach", {"hipCtxAttach", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuCtxDetach", {"hipCtxDetach", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}}, - // 12. Peer Context Memory Access - {"cuCtxEnablePeerAccess", {"hipCtxEnablePeerAccess", CONV_PEER, API_DRIVER}}, - {"cuCtxDisablePeerAccess", {"hipCtxDisablePeerAccess", CONV_PEER, API_DRIVER}}, - {"cuDeviceCanAccessPeer", {"hipDeviceCanAccessPeer", CONV_PEER, API_DRIVER}}, - {"cuDeviceGetP2PAttribute", {"hipDeviceGetP2PAttribute", CONV_PEER, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaDeviceGetP2PAttribute) + // 5.10. Module Management + // no analogues + {"cuLinkAddData", {"hipLinkAddData", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuLinkAddData_v2", {"hipLinkAddData", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuLinkAddFile", {"hipLinkAddFile", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuLinkAddFile_v2", {"hipLinkAddFile", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuLinkComplete", {"hipLinkComplete", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuLinkCreate", {"hipLinkCreate", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuLinkCreate_v2", {"hipLinkCreate", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuLinkDestroy", {"hipLinkDestroy", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuModuleGetFunction", {"hipModuleGetFunction", CONV_MODULE, API_DRIVER}}, + {"cuModuleGetGlobal", {"hipModuleGetGlobal", CONV_MODULE, API_DRIVER}}, + {"cuModuleGetGlobal_v2", {"hipModuleGetGlobal", CONV_MODULE, API_DRIVER}}, + {"cuModuleGetSurfRef", {"hipModuleGetSurfRef", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuModuleGetTexRef", {"hipModuleGetTexRef", CONV_MODULE, API_DRIVER}}, + {"cuModuleLoad", {"hipModuleLoad", CONV_MODULE, API_DRIVER}}, + {"cuModuleLoadData", {"hipModuleLoadData", CONV_MODULE, API_DRIVER}}, + {"cuModuleLoadDataEx", {"hipModuleLoadDataEx", CONV_MODULE, API_DRIVER}}, + {"cuModuleLoadFatBinary", {"hipModuleLoadFatBinary", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuModuleUnload", {"hipModuleUnload", CONV_MODULE, API_DRIVER}}, - // Device Management [DEPRECATED] - {"cuDeviceComputeCapability", {"hipDeviceComputeCapability", CONV_DEVICE, API_DRIVER}}, - {"cuDeviceGetProperties", {"hipGetDeviceProperties", CONV_DEVICE, API_DRIVER}}, + // 5.11. Memory Management + // no analogue + {"cuArray3DCreate", {"hipArray3DCreate", CONV_MEMORY, API_DRIVER}}, + {"cuArray3DCreate_v2", {"hipArray3DCreate", CONV_MEMORY, API_DRIVER}}, + {"cuArray3DGetDescriptor", {"hipArray3DGetDescriptor", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuArray3DGetDescriptor_v2", {"hipArray3DGetDescriptor", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuArrayCreate", {"hipArrayCreate", CONV_MEMORY, API_DRIVER}}, + {"cuArrayCreate_v2", {"hipArrayCreate", CONV_MEMORY, API_DRIVER}}, + {"cuArrayDestroy", {"hipArrayDestroy", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuArrayGetDescriptor", {"hipArrayGetDescriptor", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuArrayGetDescriptor_v2", {"hipArrayGetDescriptor", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaDeviceGetByPCIBusId + {"cuDeviceGetByPCIBusId", {"hipDeviceGetByPCIBusId", CONV_MEMORY, API_DRIVER}}, + // cudaDeviceGetPCIBusId + {"cuDeviceGetPCIBusId", {"hipDeviceGetPCIBusId", CONV_MEMORY, API_DRIVER}}, + // cudaIpcCloseMemHandle + {"cuIpcCloseMemHandle", {"hipIpcCloseMemHandle", CONV_MEMORY, API_DRIVER}}, + // cudaIpcGetEventHandle + {"cuIpcGetEventHandle", {"hipIpcGetEventHandle", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaIpcGetMemHandle + {"cuIpcGetMemHandle", {"hipIpcGetMemHandle", CONV_MEMORY, API_DRIVER}}, + // cudaIpcOpenEventHandle + {"cuIpcOpenEventHandle", {"hipIpcOpenEventHandle", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaIpcOpenMemHandle + {"cuIpcOpenMemHandle", {"hipIpcOpenMemHandle", CONV_MEMORY, API_DRIVER}}, + // cudaMalloc + {"cuMemAlloc", {"hipMalloc", CONV_MEMORY, API_DRIVER}}, + {"cuMemAlloc_v2", {"hipMalloc", CONV_MEMORY, API_DRIVER}}, + // cudaHostAlloc + {"cuMemAllocHost", {"hipMemAllocHost", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemAllocHost_v2", {"hipMemAllocHost", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemAllocManaged", {"hipMemAllocManaged", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemAllocPitch", {"hipMemAllocPitch", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemAllocPitch_v2", {"hipMemAllocPitch", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMemcpy due to different signatures + {"cuMemcpy", {"hipMemcpy_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMemcpy2D due to different signatures + {"cuMemcpy2D", {"hipMemcpy2D_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpy2D_v2", {"hipMemcpy2D_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMemcpy2DAsync due to different signatures + {"cuMemcpy2DAsync", {"hipMemcpy2DAsync_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpy2DAsync_v2", {"hipMemcpy2DAsync_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemcpy2DUnaligned", {"hipMemcpy2DUnaligned", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpy2DUnaligned_v2", {"hipMemcpy2DUnaligned", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMemcpy3D due to different signatures + {"cuMemcpy3D", {"hipMemcpy3D_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpy3D_v2", {"hipMemcpy3D_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMemcpy3DAsync due to different signatures + {"cuMemcpy3DAsync", {"hipMemcpy3DAsync_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpy3DAsync_v2", {"hipMemcpy3DAsync_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMemcpy3DPeer due to different signatures + {"cuMemcpy3DPeer", {"hipMemcpy3DPeer_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMemcpy3DPeerAsync due to different signatures + {"cuMemcpy3DPeerAsync", {"hipMemcpy3DPeerAsync_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMemcpyAsync due to different signatures + {"cuMemcpyAsync", {"hipMemcpyAsync_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMemcpyArrayToArray due to different signatures + {"cuMemcpyAtoA", {"hipMemcpyAtoA", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpyAtoA_v2", {"hipMemcpyAtoA", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemcpyAtoD", {"hipMemcpyAtoD", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpyAtoD_v2", {"hipMemcpyAtoD", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemcpyAtoH", {"hipMemcpyAtoH", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpyAtoH_v2", {"hipMemcpyAtoH", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemcpyAtoHAsync", {"hipMemcpyAtoHAsync", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpyAtoHAsync_v2", {"hipMemcpyAtoHAsync", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemcpyDtoA", {"hipMemcpyDtoA", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpyDtoA_v2", {"hipMemcpyDtoA", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemcpyDtoD", {"hipMemcpyDtoD", CONV_MEMORY, API_DRIVER}}, + {"cuMemcpyDtoD_v2", {"hipMemcpyDtoD", CONV_MEMORY, API_DRIVER}}, + // no analogue + {"cuMemcpyDtoDAsync", {"hipMemcpyDtoDAsync", CONV_MEMORY, API_DRIVER}}, + {"cuMemcpyDtoDAsync_v2", {"hipMemcpyDtoDAsync", CONV_MEMORY, API_DRIVER}}, + // no analogue + {"cuMemcpyDtoH", {"hipMemcpyDtoH", CONV_MEMORY, API_DRIVER}}, + {"cuMemcpyDtoH_v2", {"hipMemcpyDtoH", CONV_MEMORY, API_DRIVER}}, + // no analogue + {"cuMemcpyDtoHAsync", {"hipMemcpyDtoHAsync", CONV_MEMORY, API_DRIVER}}, + {"cuMemcpyDtoHAsync_v2", {"hipMemcpyDtoHAsync", CONV_MEMORY, API_DRIVER}}, + // no analogue + {"cuMemcpyHtoA", {"hipMemcpyHtoA", CONV_MEMORY, API_DRIVER}}, + {"cuMemcpyHtoA_v2", {"hipMemcpyHtoA", CONV_MEMORY, API_DRIVER}}, + // no analogue + {"cuMemcpyHtoAAsync", {"hipMemcpyHtoAAsync", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemcpyHtoAAsync_v2", {"hipMemcpyHtoAAsync", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemcpyHtoD", {"hipMemcpyHtoD", CONV_MEMORY, API_DRIVER}}, + {"cuMemcpyHtoD_v2", {"hipMemcpyHtoD", CONV_MEMORY, API_DRIVER}}, + // no analogue + {"cuMemcpyHtoDAsync", {"hipMemcpyHtoDAsync", CONV_MEMORY, API_DRIVER}}, + {"cuMemcpyHtoDAsync_v2", {"hipMemcpyHtoDAsync", CONV_MEMORY, API_DRIVER}}, + // no analogue + // NOTE: Not equal to cudaMemcpyPeer due to different signatures + {"cuMemcpyPeer", {"hipMemcpyPeer_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMemcpyPeerAsync due to different signatures + {"cuMemcpyPeerAsync", {"hipMemcpyPeerAsync_", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaFree + {"cuMemFree", {"hipFree", CONV_MEMORY, API_DRIVER}}, + {"cuMemFree_v2", {"hipFree", CONV_MEMORY, API_DRIVER}}, + // cudaFreeHost + {"cuMemFreeHost", {"hipHostFree", CONV_MEMORY, API_DRIVER}}, + // no analogue + {"cuMemGetAddressRange", {"hipMemGetAddressRange", CONV_MEMORY, API_DRIVER}}, + {"cuMemGetAddressRange_v2", {"hipMemGetAddressRange", CONV_MEMORY, API_DRIVER}}, + // cudaMemGetInfo + {"cuMemGetInfo", {"hipMemGetInfo", CONV_MEMORY, API_DRIVER}}, + {"cuMemGetInfo_v2", {"hipMemGetInfo", CONV_MEMORY, API_DRIVER}}, + // cudaHostAlloc + {"cuMemHostAlloc", {"hipHostMalloc", CONV_MEMORY, API_DRIVER}}, + // cudaHostGetDevicePointer + {"cuMemHostGetDevicePointer", {"hipHostGetDevicePointer", CONV_MEMORY, API_DRIVER}}, + {"cuMemHostGetDevicePointer_v2", {"hipHostGetDevicePointer", CONV_MEMORY, API_DRIVER}}, + // cudaHostGetFlags + {"cuMemHostGetFlags", {"hipMemHostGetFlags", CONV_MEMORY, API_DRIVER}}, + // cudaHostRegister + {"cuMemHostRegister", {"hipHostRegister", CONV_MEMORY, API_DRIVER}}, + {"cuMemHostRegister_v2", {"hipHostRegister", CONV_MEMORY, API_DRIVER}}, + // cudaHostUnregister + {"cuMemHostUnregister", {"hipHostUnregister", CONV_MEMORY, API_DRIVER}}, + // no analogue + {"cuMemsetD16", {"hipMemsetD16", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemsetD16_v2", {"hipMemsetD16", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemsetD16Async", {"hipMemsetD16Async", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemsetD2D16", {"hipMemsetD2D16", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemsetD2D16_v2", {"hipMemsetD2D16", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemsetD2D16Async", {"hipMemsetD2D16Async", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemsetD2D32", {"hipMemsetD2D32", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemsetD2D32_v2", {"hipMemsetD2D32", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemsetD2D32Async", {"hipMemsetD2D32Async", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemsetD2D8", {"hipMemsetD2D8", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuMemsetD2D8_v2", {"hipMemsetD2D8", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuMemsetD2D8Async", {"hipMemsetD2D8Async", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaMemset + {"cuMemsetD32", {"hipMemset", CONV_MEMORY, API_DRIVER}}, + {"cuMemsetD32_v2", {"hipMemset", CONV_MEMORY, API_DRIVER}}, + // cudaMemsetAsync + {"cuMemsetD32Async", {"hipMemsetAsync", CONV_MEMORY, API_DRIVER}}, + // no analogue + {"cuMemsetD8", {"hipMemsetD8", CONV_MEMORY, API_DRIVER}}, + {"cuMemsetD8_v2", {"hipMemsetD8", CONV_MEMORY, API_DRIVER}}, + // no analogue + {"cuMemsetD8Async", {"hipMemsetD8Async", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaMallocMipmappedArray due to different signatures + {"cuMipmappedArrayCreate", {"hipMipmappedArrayCreate", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaFreeMipmappedArray due to different signatures + {"cuMipmappedArrayDestroy", {"hipMipmappedArrayDestroy", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaGetMipmappedArrayLevel due to different signatures + {"cuMipmappedArrayGetLevel", {"hipMipmappedArrayGetLevel", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - // Module Management - {"cuLinkAddData", {"hipLinkAddData", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuLinkAddFile", {"hipLinkAddFile", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuLinkComplete", {"hipLinkComplete", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuLinkCreate", {"hipLinkCreate", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuLinkDestroy", {"hipLinkDestroy", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuModuleGetFunction", {"hipModuleGetFunction", CONV_MODULE, API_DRIVER}}, - {"cuModuleGetGlobal_v2", {"hipModuleGetGlobal", CONV_MODULE, API_DRIVER}}, - {"cuModuleGetSurfRef", {"hipModuleGetSurfRef", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuModuleGetTexRef", {"hipModuleGetTexRef", CONV_MODULE, API_DRIVER}}, - {"cuModuleLoad", {"hipModuleLoad", CONV_MODULE, API_DRIVER}}, - {"cuModuleLoadData", {"hipModuleLoadData", CONV_MODULE, API_DRIVER}}, - {"cuModuleLoadDataEx", {"hipModuleLoadDataEx", CONV_MODULE, API_DRIVER}}, - {"cuModuleLoadFatBinary", {"hipModuleLoadFatBinary", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuModuleUnload", {"hipModuleUnload", CONV_MODULE, API_DRIVER}}, + // 5.12. Unified Addressing + // cudaMemAdvise + {"cuMemAdvise", {"hipMemAdvise", CONV_ADDRESSING, API_DRIVER, HIP_UNSUPPORTED}}, + // TODO: double check cudaMemPrefetchAsync + {"cuMemPrefetchAsync", {"hipMemPrefetchAsync_", CONV_ADDRESSING, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaMemRangeGetAttribute + {"cuMemRangeGetAttribute", {"hipMemRangeGetAttribute", CONV_ADDRESSING, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaMemRangeGetAttributes + {"cuMemRangeGetAttributes", {"hipMemRangeGetAttributes", CONV_ADDRESSING, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuPointerGetAttribute", {"hipPointerGetAttribute", CONV_ADDRESSING, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaPointerGetAttributes due to different signatures + {"cuPointerGetAttributes", {"hipPointerGetAttributes", CONV_ADDRESSING, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuPointerSetAttribute", {"hipPointerSetAttribute", CONV_ADDRESSING, API_DRIVER, HIP_UNSUPPORTED}}, - // Event functions - {"cuEventCreate", {"hipEventCreate", CONV_EVENT, API_DRIVER}}, - {"cuEventDestroy_v2", {"hipEventDestroy", CONV_EVENT, API_DRIVER}}, - {"cuEventElapsedTime", {"hipEventElapsedTime", CONV_EVENT, API_DRIVER}}, - {"cuEventQuery", {"hipEventQuery", CONV_EVENT, API_DRIVER}}, - {"cuEventRecord", {"hipEventRecord", CONV_EVENT, API_DRIVER}}, - {"cuEventSynchronize", {"hipEventSynchronize", CONV_EVENT, API_DRIVER}}, + // 5.13. Stream Management + // cudaStreamAddCallback + {"cuStreamAddCallback", {"hipStreamAddCallback", CONV_STREAM, API_DRIVER}}, + // cudaStreamAttachMemAsync + {"cuStreamAttachMemAsync", {"hipStreamAttachMemAsync", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaStreamBeginCapture + {"cuStreamBeginCapture", {"hipStreamBeginCapture", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaStreamCreateWithFlags + {"cuStreamCreate", {"hipStreamCreateWithFlags", CONV_STREAM, API_DRIVER}}, + // cudaStreamCreateWithPriority + {"cuStreamCreateWithPriority", {"hipStreamCreateWithPriority", CONV_STREAM, API_DRIVER}}, + // cudaStreamDestroy + {"cuStreamDestroy", {"hipStreamDestroy", CONV_STREAM, API_DRIVER}}, + {"cuStreamDestroy_v2", {"hipStreamDestroy", CONV_STREAM, API_DRIVER}}, + // cudaStreamEndCapture + {"cuStreamEndCapture", {"hipStreamEndCapture", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuStreamGetCtx", {"hipStreamGetContext", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaStreamGetFlags + {"cuStreamGetFlags", {"hipStreamGetFlags", CONV_STREAM, API_DRIVER}}, + // cudaStreamGetPriority + {"cuStreamGetPriority", {"hipStreamGetPriority", CONV_STREAM, API_DRIVER}}, + // cudaStreamIsCapturing + {"cuStreamIsCapturing", {"hipStreamIsCapturing", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaStreamQuery + {"cuStreamQuery", {"hipStreamQuery", CONV_STREAM, API_DRIVER}}, + // cudaStreamSynchronize + {"cuStreamSynchronize", {"hipStreamSynchronize", CONV_STREAM, API_DRIVER}}, + // cudaStreamWaitEvent + {"cuStreamWaitEvent", {"hipStreamWaitEvent", CONV_STREAM, API_DRIVER}}, - // External Resource Interoperability - {"cuSignalExternalSemaphoresAsync", {"hipSignalExternalSemaphoresAsync", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuWaitExternalSemaphoresAsync", {"hipWaitExternalSemaphoresAsync", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuImportExternalMemory", {"hipImportExternalMemory", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuExternalMemoryGetMappedBuffer", {"hipExternalMemoryGetMappedBuffer", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuExternalMemoryGetMappedMipmappedArray", {"hipExternalMemoryGetMappedMipmappedArray", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuDestroyExternalMemory", {"hipDestroyExternalMemory", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuImportExternalSemaphore", {"hipImportExternalSemaphore", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuDestroyExternalSemaphore", {"hipDestroyExternalSemaphore", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.14. Event Management + // cudaEventCreateWithFlags + {"cuEventCreate", {"hipEventCreateWithFlags", CONV_EVENT, API_DRIVER}}, + // cudaEventDestroy + {"cuEventDestroy", {"hipEventDestroy", CONV_EVENT, API_DRIVER}}, + {"cuEventDestroy_v2", {"hipEventDestroy", CONV_EVENT, API_DRIVER}}, + // cudaEventElapsedTime + {"cuEventElapsedTime", {"hipEventElapsedTime", CONV_EVENT, API_DRIVER}}, + // cudaEventQuery + {"cuEventQuery", {"hipEventQuery", CONV_EVENT, API_DRIVER}}, + // cudaEventRecord + {"cuEventRecord", {"hipEventRecord", CONV_EVENT, API_DRIVER}}, + // cudaEventSynchronize + {"cuEventSynchronize", {"hipEventSynchronize", CONV_EVENT, API_DRIVER}}, - // Execution Control - {"cuFuncGetAttribute", {"hipFuncGetAttribute", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuFuncSetCacheConfig", {"hipFuncSetCacheConfig", CONV_EXECUTION, API_DRIVER}}, - {"cuFuncSetSharedMemConfig", {"hipFuncSetSharedMemConfig", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuLaunchKernel", {"hipModuleLaunchKernel", CONV_EXECUTION, API_DRIVER}}, - {"cuLaunchHostFunc", {"hipLaunchHostFunc", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.15. External Resource Interoperability + // cudaDestroyExternalMemory + {"cuDestroyExternalMemory", {"hipDestroyExternalMemory", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaDestroyExternalSemaphore + {"cuDestroyExternalSemaphore", {"hipDestroyExternalSemaphore", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaExternalMemoryGetMappedBuffer + {"cuExternalMemoryGetMappedBuffer", {"hipExternalMemoryGetMappedBuffer", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaExternalMemoryGetMappedMipmappedArray + {"cuExternalMemoryGetMappedMipmappedArray", {"hipExternalMemoryGetMappedMipmappedArray", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaImportExternalMemory + {"cuImportExternalMemory", {"hipImportExternalMemory", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaImportExternalSemaphore + {"cuImportExternalSemaphore", {"hipImportExternalSemaphore", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaSignalExternalSemaphoresAsync + {"cuSignalExternalSemaphoresAsync", {"hipSignalExternalSemaphoresAsync", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaWaitExternalSemaphoresAsync + {"cuWaitExternalSemaphoresAsync", {"hipWaitExternalSemaphoresAsync", CONV_EXT_RES, API_DRIVER, HIP_UNSUPPORTED}}, - // Execution Control [DEPRECATED] - {"cuFuncSetBlockShape", {"hipFuncSetBlockShape", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuFuncSetSharedSize", {"hipFuncSetSharedSize", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuLaunch", {"hipLaunch", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaLaunch) - {"cuLaunchGrid", {"hipLaunchGrid", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuLaunchGridAsync", {"hipLaunchGridAsync", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuParamSetf", {"hipParamSetf", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuParamSeti", {"hipParamSeti", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuParamSetSize", {"hipParamSetSize", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuParamSetSize", {"hipParamSetSize", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuParamSetv", {"hipParamSetv", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.16. Stream Memory Operations + // no analogues + {"cuStreamBatchMemOp", {"hipStreamBatchMemOp", CONV_STREAM_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuStreamWaitValue32", {"hipStreamWaitValue32", CONV_STREAM_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuStreamWaitValue64", {"hipStreamWaitValue64", CONV_STREAM_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuStreamWriteValue32", {"hipStreamWriteValue32", CONV_STREAM_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuStreamWriteValue64", {"hipStreamWriteValue64", CONV_STREAM_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - // Graph Management - {"cuGraphCreate", {"hipGraphCreate", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphLaunch", {"hipGraphLaunch", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphAddKernelNode", {"hipGraphAddKernelNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphKernelNodeGetParams", {"hipGraphKernelNodeGetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphKernelNodeSetParams", {"hipGraphKernelNodeSetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphAddMemcpyNode", {"hipGraphAddMemcpyNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphMemcpyNodeGetParams", {"hipGraphMemcpyNodeGetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphMemcpyNodeSetParams", {"hipGraphMemcpyNodeSetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphAddMemsetNode", {"hipGraphAddMemsetNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphMemsetNodeGetParams", {"hipGraphMemsetNodeGetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphMemsetNodeSetParams", {"hipGraphMemsetNodeSetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphAddHostNode", {"hipGraphAddHostNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphHostNodeGetParams", {"hipGraphHostNodeGetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphHostNodeSetParams", {"hipGraphHostNodeSetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphAddChildGraphNode", {"hipGraphAddChildGraphNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphChildGraphNodeGetGraph", {"hipGraphChildGraphNodeGetGraph", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphAddEmptyNode", {"hipGraphAddEmptyNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphClone", {"hipGraphClone", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphNodeFindInClone", {"hipGraphNodeFindInClone", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphNodeGetType", {"hipGraphNodeGetType", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphGetNodes", {"hipGraphGetNodes", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphGetRootNodes", {"hipGraphGetRootNodes", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphGetEdges", {"hipGraphGetEdges", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphNodeGetDependencies", {"hipGraphNodeGetDependencies", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphNodeGetDependentNodes", {"hipGraphNodeGetDependentNodes", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphAddDependencies", {"hipGraphAddDependencies", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphRemoveDependencies", {"hipGraphRemoveDependencies", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphDestroyNode", {"hipGraphDestroyNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphInstantiate", {"hipGraphInstantiate", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphExecDestroy", {"hipGraphExecDestroy", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGraphDestroy", {"hipGraphDestroy", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.17.Execution Control + // no analogue + {"cuFuncGetAttribute", {"hipFuncGetAttribute", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaFuncSetAttribute due to different signatures + {"cuFuncSetAttribute", {"hipFuncSetAttribute", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaFuncSetCacheConfig due to different signatures + {"cuFuncSetCacheConfig", {"hipFuncSetCacheConfig", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaFuncSetCacheConfig due to different signatures + {"cuFuncSetSharedMemConfig", {"hipFuncSetSharedMemConfig", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaLaunchCooperativeKernel due to different signatures + {"cuLaunchCooperativeKernel", {"hipLaunchCooperativeKernel", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaLaunchCooperativeKernelMultiDevice due to different signatures + {"cuLaunchCooperativeKernelMultiDevice", {"hipLaunchCooperativeKernelMultiDevice", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaLaunchHostFunc + {"cuLaunchHostFunc", {"hipLaunchHostFunc", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaLaunchKernel due to different signatures + {"cuLaunchKernel", {"hipModuleLaunchKernel", CONV_EXECUTION, API_DRIVER}}, - // Occupancy - {"cuOccupancyMaxActiveBlocksPerMultiprocessor", {"hipOccupancyMaxActiveBlocksPerMultiprocessor", CONV_OCCUPANCY, API_DRIVER}}, // API_Runtime ANALOGUE (cudaOccupancyMaxActiveBlocksPerMultiprocessor) - {"cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", {"hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags) - {"cuOccupancyMaxPotentialBlockSize", {"hipOccupancyMaxPotentialBlockSize", CONV_OCCUPANCY, API_DRIVER}}, // API_Runtime ANALOGUE (cudaOccupancyMaxPotentialBlockSize) - {"cuOccupancyMaxPotentialBlockSizeWithFlags", {"hipOccupancyMaxPotentialBlockSizeWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaOccupancyMaxPotentialBlockSizeWithFlags) + // 5.18.Execution Control [DEPRECATED] + // no analogue + {"cuFuncSetBlockShape", {"hipFuncSetBlockShape", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuFuncSetSharedSize", {"hipFuncSetSharedSize", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaLaunch due to different signatures + {"cuLaunch", {"hipLaunch", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuLaunchGrid", {"hipLaunchGrid", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuLaunchGridAsync", {"hipLaunchGridAsync", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuParamSetf", {"hipParamSetf", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuParamSeti", {"hipParamSeti", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuParamSetSize", {"hipParamSetSize", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuParamSetTexRef", {"hipParamSetTexRef", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuParamSetv", {"hipParamSetv", CONV_EXECUTION, API_DRIVER, HIP_UNSUPPORTED}}, - // Streams - {"cuStreamAddCallback", {"hipStreamAddCallback", CONV_STREAM, API_DRIVER}}, - {"cuStreamAttachMemAsync", {"hipStreamAttachMemAsync", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuStreamCreate", {"hipStreamCreate__", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaStreamCreate due to different signatures - {"cuStreamCreateWithPriority", {"hipStreamCreateWithPriority", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuStreamDestroy_v2", {"hipStreamDestroy", CONV_STREAM, API_DRIVER}}, - {"cuStreamGetFlags", {"hipStreamGetFlags", CONV_STREAM, API_DRIVER}}, - {"cuStreamGetPriority", {"hipStreamGetPriority", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuStreamQuery", {"hipStreamQuery", CONV_STREAM, API_DRIVER}}, - {"cuStreamSynchronize", {"hipStreamSynchronize", CONV_STREAM, API_DRIVER}}, - {"cuStreamWaitEvent", {"hipStreamWaitEvent", CONV_STREAM, API_DRIVER}}, - {"cuStreamWaitValue32", {"hipStreamWaitValue32", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuStreamWaitValue64", {"hipStreamWaitValue64", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuStreamWriteValue32", {"hipStreamWriteValue32", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuStreamWriteValue64", {"hipStreamWriteValue64", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuStreamBatchMemOp", {"hipStreamBatchMemOp", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuStreamBeginCapture", {"hipStreamBeginCapture", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuStreamEndCapture", {"hipStreamEndCapture", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuStreamIsCapturing", {"hipStreamIsCapturing", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.19. Graph Management + // cudaGraphAddChildGraphNode + {"cuGraphAddChildGraphNode", {"hipGraphAddChildGraphNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphAddDependencies + {"cuGraphAddDependencies", {"hipGraphAddDependencies", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphAddEmptyNode + {"cuGraphAddEmptyNode", {"hipGraphAddEmptyNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphAddHostNode + {"cuGraphAddHostNode", {"hipGraphAddHostNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphAddKernelNode + {"cuGraphAddKernelNode", {"hipGraphAddKernelNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphAddMemcpyNode + {"cuGraphAddMemcpyNode", {"hipGraphAddMemcpyNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphAddMemsetNode + {"cuGraphAddMemsetNode", {"hipGraphAddMemsetNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphChildGraphNodeGetGraph + {"cuGraphChildGraphNodeGetGraph", {"hipGraphChildGraphNodeGetGraph", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphClone + {"cuGraphClone", {"hipGraphClone", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphCreate + {"cuGraphCreate", {"hipGraphCreate", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphDestroy + {"cuGraphDestroy", {"hipGraphDestroy", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphDestroyNode + {"cuGraphDestroyNode", {"hipGraphDestroyNode", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphExecDestroy + {"cuGraphExecDestroy", {"hipGraphExecDestroy", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphGetEdges + {"cuGraphGetEdges", {"hipGraphGetEdges", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphGetNodes + {"cuGraphGetNodes", {"hipGraphGetNodes", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphGetRootNodes + {"cuGraphGetRootNodes", {"hipGraphGetRootNodes", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphHostNodeGetParams + {"cuGraphHostNodeGetParams", {"hipGraphHostNodeGetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphHostNodeSetParams + {"cuGraphHostNodeSetParams", {"hipGraphHostNodeSetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphInstantiate + {"cuGraphInstantiate", {"hipGraphInstantiate", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphKernelNodeGetParams + {"cuGraphKernelNodeGetParams", {"hipGraphKernelNodeGetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphKernelNodeSetParams + {"cuGraphKernelNodeSetParams", {"hipGraphKernelNodeSetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphLaunch + {"cuGraphLaunch", {"hipGraphLaunch", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphMemcpyNodeGetParams + {"cuGraphMemcpyNodeGetParams", {"hipGraphMemcpyNodeGetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphMemcpyNodeSetParams + {"cuGraphMemcpyNodeSetParams", {"hipGraphMemcpyNodeSetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphMemsetNodeGetParams + {"cuGraphMemsetNodeGetParams", {"hipGraphMemsetNodeGetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphMemsetNodeSetParams + {"cuGraphMemsetNodeSetParams", {"hipGraphMemsetNodeSetParams", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphNodeFindInClone + {"cuGraphNodeFindInClone", {"hipGraphNodeFindInClone", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphNodeGetDependencies + {"cuGraphNodeGetDependencies", {"hipGraphNodeGetDependencies", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphNodeGetDependentNodes + {"cuGraphNodeGetDependentNodes", {"hipGraphNodeGetDependentNodes", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphNodeGetType + {"cuGraphNodeGetType", {"hipGraphNodeGetType", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphRemoveDependencies + {"cuGraphRemoveDependencies", {"hipGraphRemoveDependencies", CONV_GRAPH, API_DRIVER, HIP_UNSUPPORTED}}, - // Memory management - {"cuArray3DCreate", {"hipArray3DCreate", CONV_MEMORY, API_DRIVER}}, - {"cuArray3DGetDescriptor", {"hipArray3DGetDescriptor", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuArrayCreate", {"hipArrayCreate", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuArrayDestroy", {"hipArrayDestroy", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuArrayGetDescriptor", {"hipArrayGetDescriptor", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuIpcCloseMemHandle", {"hipIpcCloseMemHandle", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuIpcGetEventHandle", {"hipIpcGetEventHandle", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuIpcGetMemHandle", {"hipIpcGetMemHandle", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuIpcOpenEventHandle", {"hipIpcOpenEventHandle", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuIpcOpenMemHandle", {"hipIpcOpenMemHandle", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemAlloc_v2", {"hipMalloc", CONV_MEMORY, API_DRIVER}}, - {"cuMemAllocHost", {"hipMemAllocHost", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemAllocManaged", {"hipMemAllocManaged", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemAllocPitch", {"hipMemAllocPitch__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemAllocPitch due to different signatures - {"cuMemcpy", {"hipMemcpy__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemcpy due to different signatures - {"cuMemcpy2D", {"hipMemcpy2D__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemcpy2D due to different signatures - {"cuMemcpy2DAsync", {"hipMemcpy2DAsync__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemcpy2DAsync due to different signatures - {"cuMemcpy2DUnaligned", {"hipMemcpy2DUnaligned", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemcpy3D", {"hipMemcpy3D__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemcpy3D due to different signatures - {"cuMemcpy3DAsync", {"hipMemcpy3DAsync__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemcpy3DAsync due to different signatures - {"cuMemcpy3DPeer", {"hipMemcpy3DPeer__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemcpy3DPeer due to different signatures - {"cuMemcpy3DPeerAsync", {"hipMemcpy3DPeerAsync__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemcpy3DPeerAsync due to different signatures - {"cuMemcpyAsync", {"hipMemcpyAsync__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemcpyAsync due to different signatures - {"cuMemcpyAtoA", {"hipMemcpyAtoA", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemcpyAtoD", {"hipMemcpyAtoD", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemcpyAtoH", {"hipMemcpyAtoH", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemcpyAtoHAsync", {"hipMemcpyAtoHAsync", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemcpyDtoA", {"hipMemcpyDtoA", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemcpyDtoD_v2", {"hipMemcpyDtoD", CONV_MEMORY, API_DRIVER}}, - {"cuMemcpyDtoDAsync_v2", {"hipMemcpyDtoDAsync", CONV_MEMORY, API_DRIVER}}, - {"cuMemcpyDtoH_v2", {"hipMemcpyDtoH", CONV_MEMORY, API_DRIVER}}, - {"cuMemcpyDtoHAsync_v2", {"hipMemcpyDtoHAsync", CONV_MEMORY, API_DRIVER}}, - {"cuMemcpyHtoA", {"hipMemcpyHtoA", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemcpyHtoAAsync", {"hipMemcpyHtoAAsync", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemcpyHtoD_v2", {"hipMemcpyHtoD", CONV_MEMORY, API_DRIVER}}, - {"cuMemcpyHtoDAsync_v2", {"hipMemcpyHtoDAsync", CONV_MEMORY, API_DRIVER}}, - {"cuMemcpyPeerAsync", {"hipMemcpyPeerAsync__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemcpyPeerAsync due to different signatures - {"cuMemcpyPeer", {"hipMemcpyPeer__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaMemcpyPeer due to different signatures - {"cuMemFree_v2", {"hipFree", CONV_MEMORY, API_DRIVER}}, - {"cuMemFreeHost", {"hipHostFree", CONV_MEMORY, API_DRIVER}}, - {"cuMemGetAddressRange", {"hipMemGetAddressRange", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemGetInfo_v2", {"hipMemGetInfo", CONV_MEMORY, API_DRIVER}}, - {"cuMemHostAlloc", {"hipHostMalloc", CONV_MEMORY, API_DRIVER}}, // API_Runtime ANALOGUE (cudaHostAlloc) - {"cuMemHostGetDevicePointer", {"hipMemHostGetDevicePointer", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemHostGetFlags", {"hipMemHostGetFlags", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemHostRegister_v2", {"hipHostRegister", CONV_MEMORY, API_DRIVER}}, // API_Runtime ANALOGUE (cudaHostAlloc) - {"cuMemHostUnregister", {"hipHostUnregister", CONV_MEMORY, API_DRIVER}}, // API_Runtime ANALOGUE (cudaHostUnregister) - {"cuMemsetD16_v2", {"hipMemsetD16", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemsetD16Async", {"hipMemsetD16Async", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemsetD2D16_v2", {"hipMemsetD2D16", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemsetD2D16Async", {"hipMemsetD2D16Async", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemsetD2D32_v2", {"hipMemsetD2D32", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemsetD2D32Async", {"hipMemsetD2D32Async", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemsetD2D8_v2", {"hipMemsetD2D8", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemsetD2D8Async", {"hipMemsetD2D8Async", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemsetD32_v2", {"hipMemset", CONV_MEMORY, API_DRIVER}}, // API_Runtime ANALOGUE (cudaMemset) - {"cuMemsetD32Async", {"hipMemsetAsync", CONV_MEMORY, API_DRIVER}}, // API_Runtime ANALOGUE (cudaMemsetAsync) - {"cuMemsetD8_v2", {"hipMemsetD8", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMemsetD8Async", {"hipMemsetD8Async", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMipmappedArrayCreate", {"hipMipmappedArrayCreate", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMipmappedArrayDestroy", {"hipMipmappedArrayDestroy", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuMipmappedArrayGetLevel", {"hipMipmappedArrayGetLevel", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.20. Occupancy + // cudaOccupancyMaxActiveBlocksPerMultiprocessor + {"cuOccupancyMaxActiveBlocksPerMultiprocessor", {"hipOccupancyMaxActiveBlocksPerMultiprocessor", CONV_OCCUPANCY, API_DRIVER}}, + // cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags + {"cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", {"hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaOccupancyMaxPotentialBlockSize + {"cuOccupancyMaxPotentialBlockSize", {"hipOccupancyMaxPotentialBlockSize", CONV_OCCUPANCY, API_DRIVER}}, + // cudaOccupancyMaxPotentialBlockSizeWithFlags + {"cuOccupancyMaxPotentialBlockSizeWithFlags", {"hipOccupancyMaxPotentialBlockSizeWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}}, - // Unified Addressing - {"cuMemPrefetchAsync", {"hipMemPrefetchAsync__", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // // no API_Runtime ANALOGUE (cudaMemPrefetchAsync has different signature) - {"cuMemAdvise", {"hipMemAdvise", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // // API_Runtime ANALOGUE (cudaMemAdvise) - {"cuMemRangeGetAttribute", {"hipMemRangeGetAttribute", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // // API_Runtime ANALOGUE (cudaMemRangeGetAttribute) - {"cuMemRangeGetAttributes", {"hipMemRangeGetAttributes", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, // // API_Runtime ANALOGUE (cudaMemRangeGetAttributes) - {"cuPointerGetAttribute", {"hipPointerGetAttribute", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuPointerGetAttributes", {"hipPointerGetAttributes", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuPointerSetAttribute", {"hipPointerSetAttribute", CONV_MEMORY, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.21. Texture Reference Management + // no analogues + {"cuTexRefGetAddress", {"hipTexRefGetAddress", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetAddress_v2", {"hipTexRefGetAddress", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetAddressMode", {"hipTexRefGetAddressMode", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetArray", {"hipTexRefGetArray", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetBorderColor", {"hipTexRefGetBorderColor", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetFilterMode", {"hipTexRefGetFilterMode", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetFlags", {"hipTexRefGetFlags", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetFormat", {"hipTexRefGetFormat", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetMaxAnisotropy", {"hipTexRefGetMaxAnisotropy", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetMipmapFilterMode", {"hipTexRefGetMipmapFilterMode", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetMipmapLevelBias", {"hipTexRefGetMipmapLevelBias", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetMipmapLevelClamp", {"hipTexRefGetMipmapLevelClamp", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefGetMipmappedArray", {"hipTexRefGetMipmappedArray", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefSetAddress", {"hipTexRefSetAddress", CONV_TEXTURE, API_DRIVER}}, + {"cuTexRefSetAddress_v2", {"hipTexRefSetAddress", CONV_TEXTURE, API_DRIVER}}, + {"cuTexRefSetAddress2D", {"hipTexRefSetAddress2D", CONV_TEXTURE, API_DRIVER}}, + {"cuTexRefSetAddress2D_v2", {"hipTexRefSetAddress2D", CONV_TEXTURE, API_DRIVER}}, + {"cuTexRefSetAddress2D_v3", {"hipTexRefSetAddress2D", CONV_TEXTURE, API_DRIVER}}, + {"cuTexRefSetAddressMode", {"hipTexRefSetAddressMode", CONV_TEXTURE, API_DRIVER}}, + {"cuTexRefSetArray", {"hipTexRefSetArray", CONV_TEXTURE, API_DRIVER}}, + {"cuTexRefSetBorderColor", {"hipTexRefSetBorderColor", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefSetFilterMode", {"hipTexRefSetFilterMode", CONV_TEXTURE, API_DRIVER}}, + {"cuTexRefSetFlags", {"hipTexRefSetFlags", CONV_TEXTURE, API_DRIVER}}, + {"cuTexRefSetFormat", {"hipTexRefSetFormat", CONV_TEXTURE, API_DRIVER}}, + {"cuTexRefSetMaxAnisotropy", {"hipTexRefSetMaxAnisotropy", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefSetMipmapFilterMode", {"hipTexRefSetMipmapFilterMode", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefSetMipmapLevelBias", {"hipTexRefSetMipmapLevelBias", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefSetMipmapLevelClamp", {"hipTexRefSetMipmapLevelClamp", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefSetMipmappedArray", {"hipTexRefSetMipmappedArray", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - // Texture Reference Mngmnt + // 5.22. Texture Reference Management [DEPRECATED] + // no analogues + {"cuTexRefCreate", {"hipTexRefCreate", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuTexRefDestroy", {"hipTexRefDestroy", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetAddress", {"hipTexRefGetAddress", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetAddressMode", {"hipTexRefGetAddressMode", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetArray", {"hipTexRefGetArray", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetBorderColor", {"hipTexRefGetBorderColor", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, // // no API_Runtime ANALOGUE - {"cuTexRefGetFilterMode", {"hipTexRefGetFilterMode", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetFlags", {"hipTexRefGetFlags", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetFormat", {"hipTexRefGetFormat", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetMaxAnisotropy", {"hipTexRefGetMaxAnisotropy", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetMipmapFilterMode", {"hipTexRefGetMipmapFilterMode", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetMipmapLevelBias", {"hipTexRefGetMipmapLevelBias", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetMipmapLevelClamp", {"hipTexRefGetMipmapLevelClamp", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefGetMipmappedArray", {"hipTexRefGetMipmappedArray", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefSetAddress", {"hipTexRefSetAddress", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefSetAddress2D", {"hipTexRefSetAddress2D", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefSetAddressMode", {"hipTexRefSetAddressMode", CONV_TEXTURE, API_DRIVER}}, - {"cuTexRefSetArray", {"hipTexRefSetArray", CONV_TEXTURE, API_DRIVER}}, - {"cuTexRefSetBorderColor", {"hipTexRefSetBorderColor", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, // // no API_Runtime ANALOGUE - {"cuTexRefSetFilterMode", {"hipTexRefSetFilterMode", CONV_TEXTURE, API_DRIVER}}, - {"cuTexRefSetFlags", {"hipTexRefSetFlags", CONV_TEXTURE, API_DRIVER}}, - {"cuTexRefSetFormat", {"hipTexRefSetFormat", CONV_TEXTURE, API_DRIVER}}, - {"cuTexRefSetMaxAnisotropy", {"hipTexRefSetMaxAnisotropy", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefSetMipmapFilterMode", {"hipTexRefSetMipmapFilterMode", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefSetMipmapLevelBias", {"hipTexRefSetMipmapLevelBias", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefSetMipmapLevelClamp", {"hipTexRefSetMipmapLevelClamp", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefSetMipmappedArray", {"hipTexRefSetMipmappedArray", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.23. Surface Reference Management + // no analogues + {"cuSurfRefGetArray", {"hipSurfRefGetArray", CONV_SURFACE, API_DRIVER, HIP_UNSUPPORTED}}, + {"cuSurfRefSetArray", {"hipSurfRefSetArray", CONV_SURFACE, API_DRIVER, HIP_UNSUPPORTED}}, - // Texture Reference Mngmnt [DEPRECATED] - {"cuTexRefCreate", {"hipTexRefCreate", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexRefDestroy", {"hipTexRefDestroy", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.24. Texture Object Management + // no analogue + // NOTE: Not equal to cudaCreateTextureObject due to different signatures + {"cuTexObjectCreate", {"hipTexObjectCreate", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaDestroyTextureObject + {"cuTexObjectDestroy", {"hipTexObjectDestroy", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaGetTextureObjectResourceDesc due to different signatures + {"cuTexObjectGetResourceDesc", {"hipTexObjectGetResourceDesc", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGetTextureObjectResourceViewDesc + {"cuTexObjectGetResourceViewDesc", {"hipTexObjectGetResourceViewDesc", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaGetTextureObjectTextureDesc due to different signatures + {"cuTexObjectGetTextureDesc", {"hipTexObjectGetTextureDesc", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - // Surface Reference Mngmnt - {"cuSurfRefGetArray", {"hipSurfRefGetArray", CONV_SURFACE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuSurfRefSetArray", {"hipSurfRefSetArray", CONV_SURFACE, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.25. Surface Object Management + // no analogue + // NOTE: Not equal to cudaCreateSurfaceObject due to different signatures + {"cuSurfObjectCreate", {"hipSurfObjectCreate", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaDestroySurfaceObject + {"cuSurfObjectDestroy", {"hipSurfObjectDestroy", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cudaGetSurfaceObjectResourceDesc due to different signatures + {"cuSurfObjectGetResourceDesc", {"hipSurfObjectGetResourceDesc", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - // Texture Object Mngmnt - {"cuTexObjectCreate", {"hipTexObjectCreate", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexObjectDestroy", {"hipTexObjectDestroy", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexObjectGetResourceDesc", {"hipTexObjectGetResourceDesc", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexObjectGetResourceViewDesc", {"hipTexObjectGetResourceViewDesc", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuTexObjectGetTextureDesc", {"hipTexObjectGetTextureDesc", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.26. Peer Context Memory Access + // no analogue + // NOTE: Not equal to cudaDeviceEnablePeerAccess due to different signatures + {"cuCtxEnablePeerAccess", {"hipCtxEnablePeerAccess", CONV_PEER, API_DRIVER}}, + // no analogue + // NOTE: Not equal to cudaDeviceDisablePeerAccess due to different signatures + {"cuCtxDisablePeerAccess", {"hipCtxDisablePeerAccess", CONV_PEER, API_DRIVER}}, + // cudaDeviceCanAccessPeer + {"cuDeviceCanAccessPeer", {"hipDeviceCanAccessPeer", CONV_PEER, API_DRIVER}}, + // cudaDeviceGetP2PAttribute + {"cuDeviceGetP2PAttribute", {"hipDeviceGetP2PAttribute", CONV_PEER, API_DRIVER, HIP_UNSUPPORTED}}, - // Surface Object Mngmnt - {"cuSurfObjectCreate", {"hipSurfObjectCreate", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuSurfObjectDestroy", {"hipSurfObjectDestroy", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuSurfObjectGetResourceDesc", {"hipSurfObjectGetResourceDesc", CONV_TEXTURE, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.27. Graphics Interoperability + // cudaGraphicsMapResources + {"cuGraphicsMapResources", {"hipGraphicsMapResources", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsResourceGetMappedMipmappedArray + {"cuGraphicsResourceGetMappedMipmappedArray", {"hipGraphicsResourceGetMappedMipmappedArray", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsResourceGetMappedPointer + {"cuGraphicsResourceGetMappedPointer", {"hipGraphicsResourceGetMappedPointer", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsResourceGetMappedPointer + {"cuGraphicsResourceGetMappedPointer_v2", {"hipGraphicsResourceGetMappedPointer", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsResourceSetMapFlags + {"cuGraphicsResourceSetMapFlags", {"hipGraphicsResourceSetMapFlags", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsResourceSetMapFlags + {"cuGraphicsResourceSetMapFlags_v2", {"hipGraphicsResourceSetMapFlags", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsSubResourceGetMappedArray + {"cuGraphicsSubResourceGetMappedArray", {"hipGraphicsSubResourceGetMappedArray", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsUnmapResources + {"cuGraphicsUnmapResources", {"hipGraphicsUnmapResources", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsUnregisterResource + {"cuGraphicsUnregisterResource", {"hipGraphicsUnregisterResource", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, - // Graphics Interoperability - {"cuGraphicsMapResources", {"hipGraphicsMapResources", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsMapResources) - {"cuGraphicsResourceGetMappedMipmappedArray", {"hipGraphicsResourceGetMappedMipmappedArray", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsResourceGetMappedMipmappedArray) - {"cuGraphicsResourceGetMappedPointer", {"hipGraphicsResourceGetMappedPointer", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsResourceGetMappedPointer) - {"cuGraphicsResourceSetMapFlags", {"hipGraphicsResourceSetMapFlags", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsResourceSetMapFlags) - {"cuGraphicsSubResourceGetMappedArray", {"hipGraphicsSubResourceGetMappedArray", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsSubResourceGetMappedArray) - {"cuGraphicsUnmapResources", {"hipGraphicsUnmapResources", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsUnmapResources) - {"cuGraphicsUnregisterResource", {"hipGraphicsUnregisterResource", CONV_GRAPHICS, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsUnregisterResource) + // 5.28. Profiler Control + // cudaProfilerInitialize + {"cuProfilerInitialize", {"hipProfilerInitialize", CONV_PROFILER, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaProfilerStart + {"cuProfilerStart", {"hipProfilerStart", CONV_PROFILER, API_DRIVER}}, + // cudaProfilerStop + {"cuProfilerStop", {"hipProfilerStop", CONV_PROFILER, API_DRIVER}}, - // Profiler - {"cuProfilerInitialize", {"hipProfilerInitialize", CONV_PROFILER, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaProfilerInitialize) - {"cuProfilerStart", {"hipProfilerStart", CONV_PROFILER, API_DRIVER}}, // API_Runtime ANALOGUE (cudaProfilerStart) - {"cuProfilerStop", {"hipProfilerStop", CONV_PROFILER, API_DRIVER}}, // API_Runtime ANALOGUE (cudaProfilerStop) + // 5.29. OpenGL Interoperability + // cudaGLGetDevices + {"cuGLGetDevices", {"hipGLGetDevices", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsGLRegisterBuffer + {"cuGraphicsGLRegisterBuffer", {"hipGraphicsGLRegisterBuffer", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsGLRegisterImage + {"cuGraphicsGLRegisterImage", {"hipGraphicsGLRegisterImage", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaWGLGetDevice + {"cuWGLGetDevice", {"hipWGLGetDevice", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGLGetDevices", {"hipGLGetDevices", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGLGetDevices) - {"cuGraphicsGLRegisterBuffer", {"hipGraphicsGLRegisterBuffer", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsGLRegisterBuffer) - {"cuGraphicsGLRegisterImage", {"hipGraphicsGLRegisterImage", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsGLRegisterImage) - {"cuWGLGetDevice", {"hipWGLGetDevice", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaWGLGetDevice) + // 5.29. OpenGL Interoperability [DEPRECATED] + // no analogue + {"cuGLCtxCreate", {"hipGLCtxCreate", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuGLInit", {"hipGLInit", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // NOTE: Not equal to cudaGLMapBufferObject due to different signatures + {"cuGLMapBufferObject", {"hipGLMapBufferObject", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // NOTE: Not equal to cudaGLMapBufferObjectAsync due to different signatures + {"cuGLMapBufferObjectAsync", {"hipGLMapBufferObjectAsync", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGLRegisterBufferObject + {"cuGLRegisterBufferObject", {"hipGLRegisterBufferObject", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGLSetBufferObjectMapFlags + {"cuGLSetBufferObjectMapFlags", {"hipGLSetBufferObjectMapFlags", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGLUnmapBufferObject + {"cuGLUnmapBufferObject", {"hipGLUnmapBufferObject", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGLUnmapBufferObjectAsync + {"cuGLUnmapBufferObjectAsync", {"hipGLUnmapBufferObjectAsync", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGLUnregisterBufferObject + {"cuGLUnregisterBufferObject", {"hipGLUnregisterBufferObject", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuGLCtxCreate", {"hipGLCtxCreate", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuGLInit", {"hipGLInit", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuGLMapBufferObject", {"hipGLMapBufferObject", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaGLMapBufferObject due to different signatures - {"cuGLMapBufferObjectAsync", {"hipGLMapBufferObjectAsync", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // Not equal to cudaGLMapBufferObjectAsync due to different signatures - {"cuGLRegisterBufferObject", {"hipGLRegisterBufferObject", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGLRegisterBufferObject) - {"cuGLSetBufferObjectMapFlags", {"hipGLSetBufferObjectMapFlags", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGLSetBufferObjectMapFlags) - {"cuGLUnmapBufferObject", {"hipGLUnmapBufferObject", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGLUnmapBufferObject) - {"cuGLUnmapBufferObjectAsync", {"hipGLUnmapBufferObjectAsync", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGLUnmapBufferObjectAsync) - {"cuGLUnregisterBufferObject", {"hipGLUnregisterBufferObject", CONV_OPENGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGLUnregisterBufferObject) + // 5.30.Direct3D 9 Interoperability + // no analogue + {"cuD3D9CtxCreate", {"hipD3D9CtxCreate", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuD3D9CtxCreateOnDevice", {"hipD3D9CtxCreateOnDevice", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9GetDevice + {"cuD3D9GetDevice", {"hipD3D9GetDevice", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9GetDevices + {"cuD3D9GetDevices", {"hipD3D9GetDevices", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9GetDirect3DDevice + {"cuD3D9GetDirect3DDevice", {"hipD3D9GetDirect3DDevice", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsD3D9RegisterResource + {"cuGraphicsD3D9RegisterResource", {"hipGraphicsD3D9RegisterResource", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuD3D9CtxCreate", {"hipD3D9CtxCreate", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuD3D9CtxCreateOnDevice", {"hipD3D9CtxCreateOnDevice", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuD3D9GetDevice", {"hipD3D9GetDevice", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9GetDevice) - {"cuD3D9GetDevices", {"hipD3D9GetDevices", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9GetDevices) - {"cuD3D9GetDirect3DDevice", {"hipD3D9GetDirect3DDevice", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9GetDirect3DDevice) - {"cuGraphicsD3D9RegisterResource", {"hipGraphicsD3D9RegisterResource", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsD3D9RegisterResource) + // 5.30.Direct3D 9 Interoperability [DEPRECATED] + // cudaD3D9MapResources + {"cuD3D9MapResources", {"hipD3D9MapResources", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9RegisterResource + {"cuD3D9RegisterResource", {"hipD3D9RegisterResource", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9ResourceGetMappedArray + {"cuD3D9ResourceGetMappedArray", {"hipD3D9ResourceGetMappedArray", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9ResourceGetMappedPitch + {"cuD3D9ResourceGetMappedPitch", {"hipD3D9ResourceGetMappedPitch", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9ResourceGetMappedPointer + {"cuD3D9ResourceGetMappedPointer", {"hipD3D9ResourceGetMappedPointer", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9ResourceGetMappedSize + {"cuD3D9ResourceGetMappedSize", {"hipD3D9ResourceGetMappedSize", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9ResourceGetSurfaceDimensions + {"cuD3D9ResourceGetSurfaceDimensions", {"hipD3D9ResourceGetSurfaceDimensions", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9ResourceSetMapFlags + {"cuD3D9ResourceSetMapFlags", {"hipD3D9ResourceSetMapFlags", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9UnmapResources + {"cuD3D9UnmapResources", {"hipD3D9UnmapResources", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D9UnregisterResource + {"cuD3D9UnregisterResource", {"hipD3D9UnregisterResource", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, - {"cuD3D9MapResources", {"hipD3D9MapResources", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9MapResources) - {"cuD3D9RegisterResource", {"hipD3D9RegisterResource", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9RegisterResource) - {"cuD3D9ResourceGetMappedArray", {"hipD3D9ResourceGetMappedArray", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9ResourceGetMappedArray) - {"cuD3D9ResourceGetMappedPitch", {"hipD3D9ResourceGetMappedPitch", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9ResourceGetMappedPitch) - {"cuD3D9ResourceGetMappedPointer", {"hipD3D9ResourceGetMappedPointer", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9ResourceGetMappedPointer) - {"cuD3D9ResourceGetMappedSize", {"hipD3D9ResourceGetMappedSize", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9ResourceGetMappedSize) - {"cuD3D9ResourceGetSurfaceDimensions", {"hipD3D9ResourceGetSurfaceDimensions", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9ResourceGetSurfaceDimensions) - {"cuD3D9ResourceSetMapFlags", {"hipD3D9ResourceSetMapFlags", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9ResourceSetMapFlags) - {"cuD3D9UnmapResources", {"hipD3D9UnmapResources", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9UnmapResources) - {"cuD3D9UnregisterResource", {"hipD3D9UnregisterResource", CONV_D3D9, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D9UnregisterResource) + // 5.31. Direct3D 10 Interoperability + // cudaD3D10GetDevice + {"cuD3D10GetDevice", {"hipD3D10GetDevice", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10GetDevices + {"cuD3D10GetDevices", {"hipD3D10GetDevices", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsD3D10RegisterResource + {"cuGraphicsD3D10RegisterResource", {"hipGraphicsD3D10RegisterResource", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, - // Direct3D 10 Interoperability - {"cuD3D10GetDevice", {"hipD3D10GetDevice", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10GetDevice) - {"cuD3D10GetDevices", {"hipD3D10GetDevices", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10GetDevices) - {"cuGraphicsD3D10RegisterResource", {"hipGraphicsD3D10RegisterResource", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsD3D10RegisterResource) + // 5.31. Direct3D 10 Interoperability [DEPRECATED] + // no analogue + {"cuD3D10CtxCreate", {"hipD3D10CtxCreate", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuD3D10CtxCreateOnDevice", {"hipD3D10CtxCreateOnDevice", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10GetDirect3DDevice + {"cuD3D10GetDirect3DDevice", {"hipD3D10GetDirect3DDevice", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10MapResources + {"cuD3D10MapResources", {"hipD3D10MapResources", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10RegisterResource + {"cuD3D10RegisterResource", {"hipD3D10RegisterResource", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10ResourceGetMappedArray + {"cuD3D10ResourceGetMappedArray", {"hipD3D10ResourceGetMappedArray", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10ResourceGetMappedPitch + {"cuD3D10ResourceGetMappedPitch", {"hipD3D10ResourceGetMappedPitch", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10ResourceGetMappedPointer + {"cuD3D10ResourceGetMappedPointer", {"hipD3D10ResourceGetMappedPointer", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10ResourceGetMappedSize + {"cuD3D10ResourceGetMappedSize", {"hipD3D10ResourceGetMappedSize", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10ResourceGetSurfaceDimensions + {"cuD3D10ResourceGetSurfaceDimensions", {"hipD3D10ResourceGetSurfaceDimensions", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10ResourceSetMapFlags + {"cuD310ResourceSetMapFlags", {"hipD3D10ResourceSetMapFlags", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10UnmapResources + {"cuD3D10UnmapResources", {"hipD3D10UnmapResources", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D10UnregisterResource + {"cuD3D10UnregisterResource", {"hipD3D10UnregisterResource", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, - // Direct3D 10 Interoperability [DEPRECATED] - {"cuD3D10CtxCreate", {"hipD3D10CtxCreate", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuD3D10CtxCreateOnDevice", {"hipD3D10CtxCreateOnDevice", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuD3D10GetDirect3DDevice", {"hipD3D10GetDirect3DDevice", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10GetDirect3DDevice) - {"cuD3D10MapResources", {"hipD3D10MapResources", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10MapResources) - {"cuD3D10RegisterResource", {"hipD3D10RegisterResource", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10RegisterResource) - {"cuD3D10ResourceGetMappedArray", {"hipD3D10ResourceGetMappedArray", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10ResourceGetMappedArray) - {"cuD3D10ResourceGetMappedPitch", {"hipD3D10ResourceGetMappedPitch", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10ResourceGetMappedPitch) - {"cuD3D10ResourceGetMappedPointer", {"hipD3D10ResourceGetMappedPointer", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10ResourceGetMappedPointer) - {"cuD3D10ResourceGetMappedSize", {"hipD3D10ResourceGetMappedSize", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10ResourceGetMappedSize) - {"cuD3D10ResourceGetSurfaceDimensions", {"hipD3D10ResourceGetSurfaceDimensions", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10ResourceGetSurfaceDimensions) - {"cuD310ResourceSetMapFlags", {"hipD3D10ResourceSetMapFlags", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10ResourceSetMapFlags) - {"cuD3D10UnmapResources", {"hipD3D10UnmapResources", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10UnmapResources) - {"cuD3D10UnregisterResource", {"hipD3D10UnregisterResource", CONV_D3D10, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D10UnregisterResource) + // 5.32. Direct3D 11 Interoperability + // cudaD3D11GetDevice + {"cuD3D11GetDevice", {"hipD3D11GetDevice", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D11GetDevices + {"cuD3D11GetDevices", {"hipD3D11GetDevices", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsD3D11RegisterResource + {"cuGraphicsD3D11RegisterResource", {"hipGraphicsD3D11RegisterResource", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, - // Direct3D 11 Interoperability - {"cuD3D11GetDevice", {"hipD3D11GetDevice", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D11GetDevice) - {"cuD3D11GetDevices", {"hipD3D11GetDevices", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D11GetDevices) - {"cuGraphicsD3D11RegisterResource", {"hipGraphicsD3D11RegisterResource", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsD3D11RegisterResource) + // 5.32. Direct3D 11 Interoperability [DEPRECATED] + // no analogue + {"cuD3D11CtxCreate", {"hipD3D11CtxCreate", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuD3D11CtxCreateOnDevice", {"hipD3D11CtxCreateOnDevice", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaD3D11GetDirect3DDevice + {"cuD3D11GetDirect3DDevice", {"hipD3D11GetDirect3DDevice", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, - // Direct3D 11 Interoperability [DEPRECATED] - {"cuD3D11CtxCreate", {"hipD3D11CtxCreate", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuD3D11CtxCreateOnDevice", {"hipD3D11CtxCreateOnDevice", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuD3D11GetDirect3DDevice", {"hipD3D11GetDirect3DDevice", CONV_D3D11, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaD3D11GetDirect3DDevice) - - // VDPAU Interoperability - {"cuGraphicsVDPAURegisterOutputSurface", {"hipGraphicsVDPAURegisterOutputSurface", CONV_VDPAU, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsVDPAURegisterOutputSurface) - {"cuGraphicsVDPAURegisterVideoSurface", {"hipGraphicsVDPAURegisterVideoSurface", CONV_VDPAU, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsVDPAURegisterVideoSurface) - {"cuVDPAUGetDevice", {"hipVDPAUGetDevice", CONV_VDPAU, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaVDPAUGetDevice) - {"cuVDPAUCtxCreate", {"hipVDPAUCtxCreate", CONV_VDPAU, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - - // EGL Interoperability - {"cuEGLStreamConsumerAcquireFrame", {"hipEGLStreamConsumerAcquireFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaEGLStreamConsumerAcquireFrame) - {"cuEGLStreamConsumerConnect", {"hipEGLStreamConsumerConnect", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaEGLStreamConsumerConnect) - {"cuEGLStreamConsumerConnectWithFlags", {"hipEGLStreamConsumerConnectWithFlags", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaEGLStreamConsumerConnectWithFlags) - {"cuEGLStreamConsumerDisconnect", {"hipEGLStreamConsumerDisconnect", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // no API_Runtime ANALOGUE - {"cuEGLStreamConsumerReleaseFrame", {"hipEGLStreamConsumerReleaseFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaEGLStreamConsumerReleaseFrame) - {"cuEGLStreamProducerConnect", {"hipEGLStreamProducerConnect", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaEGLStreamProducerConnect) - {"cuEGLStreamProducerDisconnect", {"hipEGLStreamProducerDisconnect", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaEGLStreamProducerDisconnect) - {"cuEGLStreamProducerPresentFrame", {"hipEGLStreamProducerPresentFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaEGLStreamProducerPresentFrame) - {"cuEGLStreamProducerReturnFrame", {"hipEGLStreamProducerReturnFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaEGLStreamProducerReturnFrame) - {"cuGraphicsEGLRegisterImage", {"hipGraphicsEGLRegisterImage", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsEGLRegisterImage) - {"cuGraphicsResourceGetMappedEglFrame", {"hipGraphicsResourceGetMappedEglFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // API_Runtime ANALOGUE (cudaGraphicsResourceGetMappedEglFrame) + // 5.33. VDPAU Interoperability + // cudaGraphicsVDPAURegisterOutputSurface + {"cuGraphicsVDPAURegisterOutputSurface", {"hipGraphicsVDPAURegisterOutputSurface", CONV_VDPAU, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsVDPAURegisterVideoSurface + {"cuGraphicsVDPAURegisterVideoSurface", {"hipGraphicsVDPAURegisterVideoSurface", CONV_VDPAU, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaVDPAUGetDevice + {"cuVDPAUGetDevice", {"hipVDPAUGetDevice", CONV_VDPAU, API_DRIVER, HIP_UNSUPPORTED}}, + // no analogue + {"cuVDPAUCtxCreate", {"hipVDPAUCtxCreate", CONV_VDPAU, API_DRIVER, HIP_UNSUPPORTED}}, + // 5.34. EGL Interoperability + // cudaEGLStreamConsumerAcquireFrame + {"cuEGLStreamConsumerAcquireFrame", {"hipEGLStreamConsumerAcquireFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaEGLStreamConsumerConnect + {"cuEGLStreamConsumerConnect", {"hipEGLStreamConsumerConnect", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaEGLStreamConsumerConnectWithFlags + {"cuEGLStreamConsumerConnectWithFlags", {"hipEGLStreamConsumerConnectWithFlags", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaEGLStreamConsumerDisconnect + {"cuEGLStreamConsumerDisconnect", {"hipEGLStreamConsumerDisconnect", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaEGLStreamConsumerReleaseFrame + {"cuEGLStreamConsumerReleaseFrame", {"hipEGLStreamConsumerReleaseFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaEGLStreamProducerConnect + {"cuEGLStreamProducerConnect", {"hipEGLStreamProducerConnect", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaEGLStreamProducerDisconnect + {"cuEGLStreamProducerDisconnect", {"hipEGLStreamProducerDisconnect", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaEGLStreamProducerPresentFrame + {"cuEGLStreamProducerPresentFrame", {"hipEGLStreamProducerPresentFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaEGLStreamProducerReturnFrame + {"cuEGLStreamProducerReturnFrame", {"hipEGLStreamProducerReturnFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsEGLRegisterImage + {"cuGraphicsEGLRegisterImage", {"hipGraphicsEGLRegisterImage", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaGraphicsResourceGetMappedEglFrame + {"cuGraphicsResourceGetMappedEglFrame", {"hipGraphicsResourceGetMappedEglFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, + // cudaEventCreateFromEGLSync + {"cuEventCreateFromEGLSync", {"hipEventCreateFromEGLSync", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, ////////////////////////////// cuComplex API ////////////////////////////// {"cuFloatComplex", {"hipFloatComplex", CONV_TYPE, API_COMPLEX}}, @@ -423,4 +777,4 @@ const std::map CUDA_DRIVER_FUNCTION_MAP{ {"cuComplexDoubleToFloat", {"hipComplexDoubleToFloat", CONV_COMPLEX, API_COMPLEX}}, {"cuCfmaf", {"hipCfmaf", CONV_COMPLEX, API_COMPLEX}}, {"cuCfma", {"hipCfma", CONV_COMPLEX, API_COMPLEX}}, -}; \ No newline at end of file +}; diff --git a/hipify-clang/src/CUDA2HIP_Driver_API_types.cpp b/hipify-clang/src/CUDA2HIP_Driver_API_types.cpp index 07b78ac738..5438aab3de 100644 --- a/hipify-clang/src/CUDA2HIP_Driver_API_types.cpp +++ b/hipify-clang/src/CUDA2HIP_Driver_API_types.cpp @@ -80,8 +80,10 @@ const std::map CUDA_DRIVER_TYPE_NAME_MAP{ {"CUDA_TEXTURE_DESC_st", {"HIP_TEXTURE_DESC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}}, {"CUDA_TEXTURE_DESC", {"HIP_TEXTURE_DESC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}}, - {"CUdevprop_st", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}}, - {"CUdevprop", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}}, + // no analogue + // NOTE: cudaDeviceProp differs + {"CUdevprop_st", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}}, + {"CUdevprop", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}}, // cudaIpcEventHandle_st {"CUipcEventHandle_st", {"ihipIpcEventHandle_t", CONV_TYPE, API_DRIVER}}, diff --git a/hipify-clang/src/CUDA2HIP_Runtime_API_functions.cpp b/hipify-clang/src/CUDA2HIP_Runtime_API_functions.cpp index 6c81de2817..1eaa0903e1 100644 --- a/hipify-clang/src/CUDA2HIP_Runtime_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_Runtime_API_functions.cpp @@ -1,6 +1,6 @@ #include "CUDA2HIP.h" -// Map of all functions +// Map of all CUDA Runtime API functions const std::map CUDA_RUNTIME_FUNCTION_MAP{ // Error API {"cudaGetLastError", {"hipGetLastError", CONV_ERROR, API_RUNTIME}}, @@ -9,29 +9,49 @@ const std::map CUDA_RUNTIME_FUNCTION_MAP{ {"cudaGetErrorString", {"hipGetErrorString", CONV_ERROR, API_RUNTIME}}, // memcpy functions + // no analogue + // NOTE: Not equal to cuMemcpy due to different signatures {"cudaMemcpy", {"hipMemcpy", CONV_MEMORY, API_RUNTIME}}, {"cudaMemcpyToArray", {"hipMemcpyToArray", CONV_MEMORY, API_RUNTIME}}, {"cudaMemcpyToSymbol", {"hipMemcpyToSymbol", CONV_MEMORY, API_RUNTIME}}, {"cudaMemcpyToSymbolAsync", {"hipMemcpyToSymbolAsync", CONV_MEMORY, API_RUNTIME}}, + {"cudaMemcpyAsync", {"hipMemcpyAsync", CONV_MEMORY, API_RUNTIME}}, + // no analogue + // NOTE: Not equal to cuMemcpy2D due to different signatures {"cudaMemcpy2D", {"hipMemcpy2D", CONV_MEMORY, API_RUNTIME}}, + // no analogue + // NOTE: Not equal to cuMemcpy2DAsync due to different signatures {"cudaMemcpy2DAsync", {"hipMemcpy2DAsync", CONV_MEMORY, API_RUNTIME}}, {"cudaMemcpy2DToArray", {"hipMemcpy2DToArray", CONV_MEMORY, API_RUNTIME}}, {"cudaMemcpy2DArrayToArray", {"hipMemcpy2DArrayToArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaMemcpy2DFromArray", {"hipMemcpy2DFromArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaMemcpy2DFromArrayAsync", {"hipMemcpy2DFromArrayAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaMemcpy2DToArrayAsync", {"hipMemcpy2DToArrayAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cuMemcpy3D due to different signatures {"cudaMemcpy3D", {"hipMemcpy3D", CONV_MEMORY, API_RUNTIME}}, + // no analogue + // NOTE: Not equal to cuMemcpy3DAsync due to different signatures {"cudaMemcpy3DAsync", {"hipMemcpy3DAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cuMemcpy3DPeer due to different signatures {"cudaMemcpy3DPeer", {"hipMemcpy3DPeer", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cuMemcpy3DPeerAsync due to different signatures {"cudaMemcpy3DPeerAsync", {"hipMemcpy3DPeerAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cuMemcpyAtoA due to different signatures {"cudaMemcpyArrayToArray", {"hipMemcpyArrayToArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaMemcpyFromArrayAsync", {"hipMemcpyFromArrayAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaMemcpyFromSymbol", {"hipMemcpyFromSymbol", CONV_MEMORY, API_RUNTIME}}, {"cudaMemcpyFromSymbolAsync", {"hipMemcpyFromSymbolAsync", CONV_MEMORY, API_RUNTIME}}, - {"cudaMemAdvise", {"hipMemAdvise", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, // - {"cudaMemRangeGetAttribute", {"hipMemRangeGetAttribute", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, // - {"cudaMemRangeGetAttributes", {"hipMemRangeGetAttributes", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, // + // cuMemAdvise + {"cudaMemAdvise", {"hipMemAdvise", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuMemRangeGetAttribute + {"cudaMemRangeGetAttribute", {"hipMemRangeGetAttribute", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuMemRangeGetAttributes + {"cudaMemRangeGetAttributes", {"hipMemRangeGetAttributes", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, // memset {"cudaMemset", {"hipMemset", CONV_MEMORY, API_RUNTIME}}, @@ -42,13 +62,17 @@ const std::map CUDA_RUNTIME_FUNCTION_MAP{ {"cudaMemset3DAsync", {"hipMemset3DAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, // Memory management + // cuMemGetInfo {"cudaMemGetInfo", {"hipMemGetInfo", CONV_MEMORY, API_RUNTIME}}, {"cudaArrayGetInfo", {"hipArrayGetInfo", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cuMipmappedArrayDestroy due to different signatures {"cudaFreeMipmappedArray", {"hipFreeMipmappedArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaGetMipmappedArrayLevel", {"hipGetMipmappedArrayLevel", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaGetSymbolAddress", {"hipGetSymbolAddress", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaGetSymbolSize", {"hipGetSymbolSize", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, - {"cudaMemPrefetchAsync", {"hipMemPrefetchAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, // // API_Driver ANALOGUE (cuMemPrefetchAsync) + // TODO: double check cuMemPrefetchAsync + {"cudaMemPrefetchAsync", {"hipMemPrefetchAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, // malloc {"cudaMalloc", {"hipMalloc", CONV_MEMORY, API_RUNTIME}}, @@ -57,15 +81,22 @@ const std::map CUDA_RUNTIME_FUNCTION_MAP{ {"cudaMalloc3D", {"hipMalloc3D", CONV_MEMORY, API_RUNTIME}}, {"cudaMalloc3DArray", {"hipMalloc3DArray", CONV_MEMORY, API_RUNTIME}}, {"cudaMallocManaged", {"hipMallocManaged", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, + // no analogue + // NOTE: Not equal to cuMipmappedArrayCreate due to different signatures {"cudaMallocMipmappedArray", {"hipMallocMipmappedArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, {"cudaMallocPitch", {"hipMallocPitch", CONV_MEMORY, API_RUNTIME}}, + // cuMemFree {"cudaFree", {"hipFree", CONV_MEMORY, API_RUNTIME}}, + // cuMemFreeHost {"cudaFreeHost", {"hipHostFree", CONV_MEMORY, API_RUNTIME}}, {"cudaFreeArray", {"hipFreeArray", CONV_MEMORY, API_RUNTIME}}, + // cuMemHostRegister {"cudaHostRegister", {"hipHostRegister", CONV_MEMORY, API_RUNTIME}}, + // cuMemHostUnregister {"cudaHostUnregister", {"hipHostUnregister", CONV_MEMORY, API_RUNTIME}}, - // hipHostAlloc deprecated - use hipHostMalloc instead + // cuMemHostAlloc + // NOTE: hipHostAlloc deprecated - use hipHostMalloc instead {"cudaHostAlloc", {"hipHostMalloc", CONV_MEMORY, API_RUNTIME}}, // make memory functions @@ -74,35 +105,81 @@ const std::map CUDA_RUNTIME_FUNCTION_MAP{ {"make_cudaPos", {"make_hipPos", CONV_MEMORY, API_RUNTIME}}, // Host Register Flags + // cuMemHostGetFlags {"cudaHostGetFlags", {"hipHostGetFlags", CONV_MEMORY, API_RUNTIME}}, // Events - {"cudaEventCreate", {"hipEventCreate", CONV_EVENT, API_RUNTIME}}, - {"cudaEventCreateWithFlags", {"hipEventCreateWithFlags", CONV_EVENT, API_RUNTIME}}, - {"cudaEventDestroy", {"hipEventDestroy", CONV_EVENT, API_RUNTIME}}, - {"cudaEventRecord", {"hipEventRecord", CONV_EVENT, API_RUNTIME}}, - {"cudaEventElapsedTime", {"hipEventElapsedTime", CONV_EVENT, API_RUNTIME}}, - {"cudaEventSynchronize", {"hipEventSynchronize", CONV_EVENT, API_RUNTIME}}, - {"cudaEventQuery", {"hipEventQuery", CONV_EVENT, API_RUNTIME}}, + // no analogue + // NOTE: Not equal to cuEventCreate due to different signatures + {"cudaEventCreate", {"hipEventCreate", CONV_EVENT, API_RUNTIME}}, + // cuEventCreate + {"cudaEventCreateWithFlags", {"hipEventCreateWithFlags", CONV_EVENT, API_RUNTIME}}, + // cuEventDestroy + {"cudaEventDestroy", {"hipEventDestroy", CONV_EVENT, API_RUNTIME}}, + // cuEventRecord + {"cudaEventRecord", {"hipEventRecord", CONV_EVENT, API_RUNTIME}}, + // cuEventElapsedTime + {"cudaEventElapsedTime", {"hipEventElapsedTime", CONV_EVENT, API_RUNTIME}}, + // cuEventSynchronize + {"cudaEventSynchronize", {"hipEventSynchronize", CONV_EVENT, API_RUNTIME}}, + // cuEventQuery + {"cudaEventQuery", {"hipEventQuery", CONV_EVENT, API_RUNTIME}}, + + // 5.6. External Resource Interoperability + // cuDestroyExternalMemory + {"cudaDestroyExternalMemory", {"hipDestroyExternalMemory", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuDestroyExternalSemaphore + {"cudaDestroyExternalSemaphore", {"hipDestroyExternalSemaphore", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuExternalMemoryGetMappedBuffer + {"cudaExternalMemoryGetMappedBuffer", {"hipExternalMemoryGetMappedBuffer", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuExternalMemoryGetMappedMipmappedArray + {"cudaExternalMemoryGetMappedMipmappedArray", {"hipExternalMemoryGetMappedMipmappedArray", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuImportExternalMemory + {"cudaImportExternalMemory", {"hipImportExternalMemory", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuImportExternalSemaphore + {"cudaImportExternalSemaphore", {"hipImportExternalSemaphore", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuSignalExternalSemaphoresAsync + {"cudaSignalExternalSemaphoresAsync", {"hipSignalExternalSemaphoresAsync", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuWaitExternalSemaphoresAsync + {"cudaWaitExternalSemaphoresAsync", {"hipWaitExternalSemaphoresAsync", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}}, // Streams + // no analogue + // NOTE: Not equal to cuStreamCreate due to different signatures {"cudaStreamCreate", {"hipStreamCreate", CONV_STREAM, API_RUNTIME}}, + // cuStreamCreate {"cudaStreamCreateWithFlags", {"hipStreamCreateWithFlags", CONV_STREAM, API_RUNTIME}}, - {"cudaStreamCreateWithPriority", {"hipStreamCreateWithPriority", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuStreamCreateWithPriority + {"cudaStreamCreateWithPriority", {"hipStreamCreateWithPriority", CONV_STREAM, API_RUNTIME}}, + // cuStreamDestroy {"cudaStreamDestroy", {"hipStreamDestroy", CONV_STREAM, API_RUNTIME}}, + // cuStreamWaitEvent {"cudaStreamWaitEvent", {"hipStreamWaitEvent", CONV_STREAM, API_RUNTIME}}, + // cuStreamSynchronize {"cudaStreamSynchronize", {"hipStreamSynchronize", CONV_STREAM, API_RUNTIME}}, + // cuStreamGetFlags {"cudaStreamGetFlags", {"hipStreamGetFlags", CONV_STREAM, API_RUNTIME}}, + // cuStreamQuery {"cudaStreamQuery", {"hipStreamQuery", CONV_STREAM, API_RUNTIME}}, + // cuStreamAddCallback {"cudaStreamAddCallback", {"hipStreamAddCallback", CONV_STREAM, API_RUNTIME}}, + // cuStreamAttachMemAsync {"cudaStreamAttachMemAsync", {"hipStreamAttachMemAsync", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}}, - {"cudaStreamGetPriority", {"hipStreamGetPriority", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuStreamBeginCapture + {"cudaStreamBeginCapture", {"hipStreamBeginCapture", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuStreamEndCapture + {"cudaStreamEndCapture", {"hipStreamEndCapture", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuStreamIsCapturing + {"cudaStreamIsCapturing", {"hipStreamIsCapturing", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuStreamGetPriority + {"cudaStreamGetPriority", {"hipStreamGetPriority", CONV_STREAM, API_RUNTIME}}, // Other synchronization {"cudaDeviceSynchronize", {"hipDeviceSynchronize", CONV_DEVICE, API_RUNTIME}}, {"cudaDeviceReset", {"hipDeviceReset", CONV_DEVICE, API_RUNTIME}}, {"cudaSetDevice", {"hipSetDevice", CONV_DEVICE, API_RUNTIME}}, {"cudaGetDevice", {"hipGetDevice", CONV_DEVICE, API_RUNTIME}}, + // cuDeviceGetCount {"cudaGetDeviceCount", {"hipGetDeviceCount", CONV_DEVICE, API_RUNTIME}}, {"cudaChooseDevice", {"hipChooseDevice", CONV_DEVICE, API_RUNTIME}}, @@ -118,20 +195,25 @@ const std::map CUDA_RUNTIME_FUNCTION_MAP{ {"cudaDeviceGetAttribute", {"hipDeviceGetAttribute", CONV_DEVICE, API_RUNTIME}}, // Pointer Attributes - // struct cudaPointerAttributes - {"cudaPointerGetAttributes", {"hipPointerGetAttributes", CONV_MEMORY, API_RUNTIME}}, - + // no analogue + // NOTE: Not equal to cuPointerGetAttributes due to different signatures + {"cudaPointerGetAttributes", {"hipPointerGetAttributes", CONV_ADDRESSING, API_RUNTIME}}, + // cuMemHostGetDevicePointer {"cudaHostGetDevicePointer", {"hipHostGetDevicePointer", CONV_MEMORY, API_RUNTIME}}, // Device {"cudaGetDeviceProperties", {"hipGetDeviceProperties", CONV_DEVICE, API_RUNTIME}}, + // cuDeviceGetPCIBusId {"cudaDeviceGetPCIBusId", {"hipDeviceGetPCIBusId", CONV_DEVICE, API_RUNTIME}}, + // cuDeviceGetByPCIBusId {"cudaDeviceGetByPCIBusId", {"hipDeviceGetByPCIBusId", CONV_DEVICE, API_RUNTIME}}, - {"cudaDeviceGetStreamPriorityRange", {"hipDeviceGetStreamPriorityRange", CONV_DEVICE, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuCtxGetStreamPriorityRange + {"cudaDeviceGetStreamPriorityRange", {"hipDeviceGetStreamPriorityRange", CONV_DEVICE, API_RUNTIME}}, {"cudaSetValidDevices", {"hipSetValidDevices", CONV_DEVICE, API_RUNTIME, HIP_UNSUPPORTED}}, // Device Flags - {"cudaGetDeviceFlags", {"hipGetDeviceFlags", CONV_DEVICE, API_RUNTIME, HIP_UNSUPPORTED}}, + // cuCtxGetFlags + {"cudaGetDeviceFlags", {"hipCtxGetFlags", CONV_DEVICE, API_RUNTIME}}, {"cudaSetDeviceFlags", {"hipSetDeviceFlags", CONV_DEVICE, API_RUNTIME}}, // Cache config @@ -179,7 +261,7 @@ const std::map CUDA_RUNTIME_FUNCTION_MAP{ // {"cudaThreadGetSharedMemConfig", {"hipDeviceGetSharedMemConfig", CONV_DEVICE, API_RUNTIME}}, // {"cudaThreadSetSharedMemConfig", {"hipDeviceSetSharedMemConfig", CONV_DEVICE, API_RUNTIME}}, - + // cuCtxGetLimit {"cudaDeviceGetLimit", {"hipDeviceGetLimit", CONV_DEVICE, API_RUNTIME}}, // Profiler From 8aefe12b8e8458f22e3f6c41775643df102b37af Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 19 Nov 2018 21:04:47 +0300 Subject: [PATCH 31/55] [HIPIFY] Move Complex API types and functions to separate files --- hipify-clang/src/CUDA2HIP.cpp | 2 ++ hipify-clang/src/CUDA2HIP.h | 4 +++ .../src/CUDA2HIP_Complex_API_functions.cpp | 28 ++++++++++++++++++ .../src/CUDA2HIP_Complex_API_types.cpp | 8 +++++ .../src/CUDA2HIP_Driver_API_functions.cpp | 29 ------------------- 5 files changed, 42 insertions(+), 29 deletions(-) create mode 100644 hipify-clang/src/CUDA2HIP_Complex_API_functions.cpp create mode 100644 hipify-clang/src/CUDA2HIP_Complex_API_types.cpp diff --git a/hipify-clang/src/CUDA2HIP.cpp b/hipify-clang/src/CUDA2HIP.cpp index 02f3ae0f12..c0879c1f98 100644 --- a/hipify-clang/src/CUDA2HIP.cpp +++ b/hipify-clang/src/CUDA2HIP.cpp @@ -51,6 +51,8 @@ const std::map& CUDA_RENAMES_MAP() { ret.insert(CUDA_DRIVER_FUNCTION_MAP.begin(), CUDA_DRIVER_FUNCTION_MAP.end()); ret.insert(CUDA_RUNTIME_TYPE_NAME_MAP.begin(), CUDA_RUNTIME_TYPE_NAME_MAP.end()); ret.insert(CUDA_RUNTIME_FUNCTION_MAP.begin(), CUDA_RUNTIME_FUNCTION_MAP.end()); + ret.insert(CUDA_COMPLEX_TYPE_NAME_MAP.begin(), CUDA_COMPLEX_TYPE_NAME_MAP.end()); + ret.insert(CUDA_COMPLEX_FUNCTION_MAP.begin(), CUDA_COMPLEX_FUNCTION_MAP.end()); ret.insert(CUDA_BLAS_TYPE_NAME_MAP.begin(), CUDA_BLAS_TYPE_NAME_MAP.end()); ret.insert(CUDA_BLAS_FUNCTION_MAP.begin(), CUDA_BLAS_FUNCTION_MAP.end()); ret.insert(CUDA_RAND_TYPE_NAME_MAP.begin(), CUDA_RAND_TYPE_NAME_MAP.end()); diff --git a/hipify-clang/src/CUDA2HIP.h b/hipify-clang/src/CUDA2HIP.h index 9593c216a4..5c3a6fa246 100644 --- a/hipify-clang/src/CUDA2HIP.h +++ b/hipify-clang/src/CUDA2HIP.h @@ -15,6 +15,10 @@ extern const std::map CUDA_DRIVER_TYPE_NAME_MAP; extern const std::map CUDA_DRIVER_FUNCTION_MAP; // Maps the names of CUDA RUNTIME API types to the corresponding HIP types extern const std::map CUDA_RUNTIME_TYPE_NAME_MAP; +// Maps the names of CUDA Complex API types to the corresponding HIP types +extern const std::map CUDA_COMPLEX_TYPE_NAME_MAP; +// Maps the names of CUDA Complex API functions to the corresponding HIP functions +extern const std::map CUDA_COMPLEX_FUNCTION_MAP; // Maps the names of CUDA RUNTIME API functions to the corresponding HIP functions extern const std::map CUDA_RUNTIME_FUNCTION_MAP; // Maps the names of CUDA BLAS API types to the corresponding HIP types diff --git a/hipify-clang/src/CUDA2HIP_Complex_API_functions.cpp b/hipify-clang/src/CUDA2HIP_Complex_API_functions.cpp new file mode 100644 index 0000000000..3bc7c4f0a0 --- /dev/null +++ b/hipify-clang/src/CUDA2HIP_Complex_API_functions.cpp @@ -0,0 +1,28 @@ +#include "CUDA2HIP.h" + +// Maps the names of CUDA DRIVER 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}}, + {"make_cuFloatComplex", {"make_hipFloatComplex", CONV_COMPLEX, API_COMPLEX}}, + {"cuConjf", {"hipConjf", CONV_COMPLEX, API_COMPLEX}}, + {"cuCaddf", {"hipCaddf", CONV_COMPLEX, API_COMPLEX}}, + {"cuCsubf", {"hipCsubf", CONV_COMPLEX, API_COMPLEX}}, + {"cuCmulf", {"hipCmulf", CONV_COMPLEX, API_COMPLEX}}, + {"cuCdivf", {"hipCdivf", CONV_COMPLEX, API_COMPLEX}}, + {"cuCabsf", {"hipCabsf", CONV_COMPLEX, API_COMPLEX}}, + {"cuCreal", {"hipCreal", CONV_COMPLEX, API_COMPLEX}}, + {"cuCimag", {"hipCimag", CONV_COMPLEX, API_COMPLEX}}, + {"make_cuDoubleComplex", {"make_hipDoubleComplex", CONV_COMPLEX, API_COMPLEX}}, + {"cuConj", {"hipConj", CONV_COMPLEX, API_COMPLEX}}, + {"cuCadd", {"hipCadd", CONV_COMPLEX, API_COMPLEX}}, + {"cuCsub", {"hipCsub", CONV_COMPLEX, API_COMPLEX}}, + {"cuCmul", {"hipCmul", CONV_COMPLEX, API_COMPLEX}}, + {"cuCdiv", {"hipCdiv", CONV_COMPLEX, API_COMPLEX}}, + {"cuCabs", {"hipCabs", CONV_COMPLEX, API_COMPLEX}}, + {"make_cuComplex", {"make_hipComplex", CONV_COMPLEX, API_COMPLEX}}, + {"cuComplexFloatToDouble", {"hipComplexFloatToDouble", CONV_COMPLEX, API_COMPLEX}}, + {"cuComplexDoubleToFloat", {"hipComplexDoubleToFloat", CONV_COMPLEX, API_COMPLEX}}, + {"cuCfmaf", {"hipCfmaf", CONV_COMPLEX, API_COMPLEX}}, + {"cuCfma", {"hipCfma", CONV_COMPLEX, API_COMPLEX}}, +}; diff --git a/hipify-clang/src/CUDA2HIP_Complex_API_types.cpp b/hipify-clang/src/CUDA2HIP_Complex_API_types.cpp new file mode 100644 index 0000000000..f371cf3b9a --- /dev/null +++ b/hipify-clang/src/CUDA2HIP_Complex_API_types.cpp @@ -0,0 +1,8 @@ +#include "CUDA2HIP.h" + +// Maps the names of CUDA DRIVER 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}}, + {"cuComplex", {"hipComplex", CONV_TYPE, API_COMPLEX}}, +}; diff --git a/hipify-clang/src/CUDA2HIP_Driver_API_functions.cpp b/hipify-clang/src/CUDA2HIP_Driver_API_functions.cpp index 77dd67fd03..6871be877b 100644 --- a/hipify-clang/src/CUDA2HIP_Driver_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_Driver_API_functions.cpp @@ -748,33 +748,4 @@ const std::map CUDA_DRIVER_FUNCTION_MAP{ {"cuGraphicsResourceGetMappedEglFrame", {"hipGraphicsResourceGetMappedEglFrame", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, // cudaEventCreateFromEGLSync {"cuEventCreateFromEGLSync", {"hipEventCreateFromEGLSync", CONV_EGL, API_DRIVER, HIP_UNSUPPORTED}}, - -////////////////////////////// cuComplex API ////////////////////////////// - {"cuFloatComplex", {"hipFloatComplex", CONV_TYPE, API_COMPLEX}}, - {"cuDoubleComplex", {"hipDoubleComplex", CONV_TYPE, API_COMPLEX}}, - {"cuComplex", {"hipComplex", CONV_TYPE, API_COMPLEX}}, - - {"cuCrealf", {"hipCrealf", CONV_COMPLEX, API_COMPLEX}}, - {"cuCimagf", {"hipCimagf", CONV_COMPLEX, API_COMPLEX}}, - {"make_cuFloatComplex", {"make_hipFloatComplex", CONV_COMPLEX, API_COMPLEX}}, - {"cuConjf", {"hipConjf", CONV_COMPLEX, API_COMPLEX}}, - {"cuCaddf", {"hipCaddf", CONV_COMPLEX, API_COMPLEX}}, - {"cuCsubf", {"hipCsubf", CONV_COMPLEX, API_COMPLEX}}, - {"cuCmulf", {"hipCmulf", CONV_COMPLEX, API_COMPLEX}}, - {"cuCdivf", {"hipCdivf", CONV_COMPLEX, API_COMPLEX}}, - {"cuCabsf", {"hipCabsf", CONV_COMPLEX, API_COMPLEX}}, - {"cuCreal", {"hipCreal", CONV_COMPLEX, API_COMPLEX}}, - {"cuCimag", {"hipCimag", CONV_COMPLEX, API_COMPLEX}}, - {"make_cuDoubleComplex", {"make_hipDoubleComplex", CONV_COMPLEX, API_COMPLEX}}, - {"cuConj", {"hipConj", CONV_COMPLEX, API_COMPLEX}}, - {"cuCadd", {"hipCadd", CONV_COMPLEX, API_COMPLEX}}, - {"cuCsub", {"hipCsub", CONV_COMPLEX, API_COMPLEX}}, - {"cuCmul", {"hipCmul", CONV_COMPLEX, API_COMPLEX}}, - {"cuCdiv", {"hipCdiv", CONV_COMPLEX, API_COMPLEX}}, - {"cuCabs", {"hipCabs", CONV_COMPLEX, API_COMPLEX}}, - {"make_cuComplex", {"make_hipComplex", CONV_COMPLEX, API_COMPLEX}}, - {"cuComplexFloatToDouble", {"hipComplexFloatToDouble", CONV_COMPLEX, API_COMPLEX}}, - {"cuComplexDoubleToFloat", {"hipComplexDoubleToFloat", CONV_COMPLEX, API_COMPLEX}}, - {"cuCfmaf", {"hipCfmaf", CONV_COMPLEX, API_COMPLEX}}, - {"cuCfma", {"hipCfma", CONV_COMPLEX, API_COMPLEX}}, }; From 30c387a8119baea0b3e637ee79c5521caac4d2da Mon Sep 17 00:00:00 2001 From: emankov Date: Tue, 20 Nov 2018 17:58:05 +0300 Subject: [PATCH 32/55] [HIPIFY][SPARSE] Initial support --- hipify-clang/src/CUDA2HIP.cpp | 9 +++++++-- hipify-clang/src/CUDA2HIP.h | 4 ++++ hipify-clang/src/CUDA2HIP_Complex_API_functions.cpp | 2 +- hipify-clang/src/CUDA2HIP_Complex_API_types.cpp | 2 +- hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp | 5 +++++ hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp | 5 +++++ hipify-clang/src/HipifyAction.cpp | 4 ++++ hipify-clang/src/HipifyAction.h | 1 + hipify-clang/src/Statistics.cpp | 9 ++++++++- hipify-clang/src/Statistics.h | 3 ++- tests/hipify-clang/headers_test_09.cu | 3 +++ 11 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp create mode 100644 hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp 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" From 47aeaecec825620bac0dbdade0aee2f9e956027f Mon Sep 17 00:00:00 2001 From: emankov Date: Wed, 21 Nov 2018 01:31:02 +0300 Subject: [PATCH 33/55] [HIPIFY][SPARSE] Data types support + Add all cuSPARSE types + Update CUSPARSE_API_supported_by_HIP.md + Update README.md --- .../markdown/CUSPARSE_API_supported_by_HIP.md | 89 +++++++++++++++ hipify-clang/README.md | 3 +- .../src/CUDA2HIP_SPARSE_API_types.cpp | 106 ++++++++++++++++++ 3 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 docs/markdown/CUSPARSE_API_supported_by_HIP.md diff --git a/docs/markdown/CUSPARSE_API_supported_by_HIP.md b/docs/markdown/CUSPARSE_API_supported_by_HIP.md new file mode 100644 index 0000000000..cbc4074daf --- /dev/null +++ b/docs/markdown/CUSPARSE_API_supported_by_HIP.md @@ -0,0 +1,89 @@ +# CUSPARSE API supported by HIP + +## **1. CUSPARSE Data types** + +| **type** | **CUDA** | **HIP** | +|-------------:|---------------------------------------------------------------|------------------------------------------------------------| +| enum |***`cusparseAction_t`*** |***`hipsparseAction_t`*** | +| 0 |*`CUSPARSE_ACTION_SYMBOLIC`* |*`HIPSPARSE_ACTION_SYMBOLIC`* | +| 1 |*`CUSPARSE_ACTION_NUMERIC`* |*`HIPSPARSE_ACTION_NUMERIC`* | +| enum |***`cusparseDirection_t`*** | | +| 0 |*`CUSPARSE_DIRECTION_ROW`* | | +| 1 |*`CUSPARSE_DIRECTION_COLUMN`* | | +| enum |***`cusparseHybPartition_t`*** |***`hipsparseHybPartition_t`*** | +| 0 |*`CUSPARSE_HYB_PARTITION_AUTO`* |*`HIPSPARSE_HYB_PARTITION_AUTO`* | +| 1 |*`CUSPARSE_HYB_PARTITION_USER`* |*`HIPSPARSE_HYB_PARTITION_USER`* | +| 2 |*`CUSPARSE_HYB_PARTITION_MAX`* |*`HIPSPARSE_HYB_PARTITION_MAX`* | +| enum |***`cusparseDiagType_t`*** |***`hipsparseDiagType_t`*** | +| 0 |*`CUSPARSE_DIAG_TYPE_NON_UNIT`* |*`HIPSPARSE_DIAG_TYPE_NON_UNIT`* | +| 1 |*`CUSPARSE_DIAG_TYPE_UNIT`* |*`HIPSPARSE_DIAG_TYPE_UNIT`* | +| enum |***`cusparseFillMode_t`*** |***`hipsparseFillMode_t`*** | +| 0 |*`CUSPARSE_FILL_MODE_LOWER`* |*`HIPSPARSE_FILL_MODE_LOWER`* | +| 1 |*`CUSPARSE_FILL_MODE_UPPER`* |*`HIPSPARSE_FILL_MODE_UPPER`* | +| enum |***`cusparseIndexBase_t`*** |***`hipsparseIndexBase_t`*** | +| 0 |*`CUSPARSE_INDEX_BASE_ZERO`* |*`HIPSPARSE_INDEX_BASE_ZERO`* | +| 1 |*`CUSPARSE_INDEX_BASE_ONE`* |*`HIPSPARSE_INDEX_BASE_ONE`* | +| enum |***`cusparseMatrixType_t`*** |***`hipsparseMatrixType_t`*** | +| 0 |*`CUSPARSE_MATRIX_TYPE_GENERAL`* |*`HIPSPARSE_MATRIX_TYPE_GENERAL`* | +| 1 |*`CUSPARSE_MATRIX_TYPE_SYMMETRIC`* |*`HIPSPARSE_MATRIX_TYPE_SYMMETRIC`* | +| 2 |*`CUSPARSE_MATRIX_TYPE_HERMITIAN`* |*`HIPSPARSE_MATRIX_TYPE_HERMITIAN`* | +| 3 |*`CUSPARSE_MATRIX_TYPE_TRIANGULAR`* |*`HIPSPARSE_MATRIX_TYPE_TRIANGULAR`* | +| enum |***`cusparseOperation_t`*** |***`hipsparseOperation_t`*** | +| 0 |*`CUSPARSE_OPERATION_NON_TRANSPOSE`* |*`HIPSPARSE_OPERATION_NON_TRANSPOSE`* | +| 1 |*`CUSPARSE_OPERATION_TRANSPOSE`* |*`HIPSPARSE_OPERATION_TRANSPOSE`* | +| 2 |*`CUSPARSE_OPERATION_CONJUGATE_TRANSPOSE`* |*`HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE`* | +| enum |***`cusparsePointerMode_t`*** |***`hipsparsePointerMode_t`*** | +| 0 |*`CUSPARSE_POINTER_MODE_HOST`* |*`HIPSPARSE_POINTER_MODE_HOST`* | +| 1 |*`CUSPARSE_POINTER_MODE_DEVICE`* |*`HIPSPARSE_POINTER_MODE_DEVICE`* | +| enum |***`cusparseAlgMode_t`*** | | +| 0 |*`CUSPARSE_ALG0`* | | +| 1 |*`CUSPARSE_ALG1`* | | +| 0 |*`CUSPARSE_ALG_NAIVE`* | | +| 1 |*`CUSPARSE_ALG_MERGE_PATH`* | | +| enum |***`cusparseSolvePolicy_t`*** |***`hipsparseSolvePolicy_t`*** | +| 0 |*`CUSPARSE_SOLVE_POLICY_NO_LEVEL`* |*`HIPSPARSE_SOLVE_POLICY_NO_LEVEL`* | +| 1 |*`CUSPARSE_SOLVE_POLICY_USE_LEVEL`* |*`HIPSPARSE_SOLVE_POLICY_USE_LEVEL`* | +| enum |***`cusparseStatus_t`*** |***`hipsparseMatrixType_t`*** | +| 0 |*`CUSPARSE_STATUS_SUCCESS`* |*`HIPSPARSE_STATUS_SUCCESS`* | +| 1 |*`CUSPARSE_STATUS_NOT_INITIALIZED`* |*`HIPSPARSE_STATUS_NOT_INITIALIZED`* | +| 2 |*`CUSPARSE_STATUS_ALLOC_FAILED`* |*`HIPSPARSE_STATUS_ALLOC_FAILED`* | +| 3 |*`CUSPARSE_STATUS_INVALID_VALUE`* |*`HIPSPARSE_STATUS_INVALID_VALUE`* | +| 4 |*`CUSPARSE_STATUS_ARCH_MISMATCH`* |*`HIPSPARSE_STATUS_ARCH_MISMATCH`* | +| 5 |*`CUSPARSE_STATUS_MAPPING_ERROR`* |*`HIPSPARSE_STATUS_MAPPING_ERROR`* | +| 6 |*`CUSPARSE_STATUS_EXECUTION_FAILED`* |*`HIPSPARSE_STATUS_EXECUTION_FAILED`* | +| 7 |*`CUSPARSE_STATUS_INTERNAL_ERROR`* |*`HIPSPARSE_STATUS_INTERNAL_ERROR`* | +| 8 |*`CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED`* |*`HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED`* | +| 9 |*`CUSPARSE_STATUS_ZERO_PIVOT`* |*`HIPSPARSE_STATUS_ZERO_PIVOT`* | +| struct |`cusparseContext` | | +| typedef |`cusparseHandle_t` |`hipsparseHandle_t` | +| struct |`cusparseHybMat` | | +| typedef |`cusparseHybMat_t` |`hipsparseHybMat_t` | +| struct |`cusparseMatDescr` | | +| typedef |`cusparseMatDescr_t` |`hipsparseMatDescr_t` | +| struct |`cusparseSolveAnalysisInfo` | | +| typedef |`cusparseSolveAnalysisInfo_t` | | +| struct |`csrsv2Info` | | +| typedef |`csrsv2Info_t` |`csrsv2Info_t` | +| struct |`csrsm2Info` | | +| typedef |`csrsm2Info_t` | | +| struct |`bsrsv2Info` | | +| typedef |`bsrsv2Info_t` | | +| struct |`bsrsm2Info` | | +| typedef |`bsrsm2Info_t` | | +| struct |`bsric02Info` | | +| typedef |`bsric02Info_t` | | +| struct |`csrilu02Info` | | +| typedef |`csrilu02Info_t` |`csrilu02Info_t` | +| struct |`bsrilu02Info` | | +| typedef |`bsrilu02Info_t` | | +| struct |`csru2csrInfo` | | +| typedef |`csru2csrInfo_t` | | +| struct |`cusparseColorInfo` | | +| typedef |`cusparseColorInfo_t` | | +| struct |`pruneInfo` | | +| typedef |`pruneInfo_t` | | + +## **2. CUSPARSE API functions** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| diff --git a/hipify-clang/README.md b/hipify-clang/README.md index 431c0a844a..2df3a73bff 100644 --- a/hipify-clang/README.md +++ b/hipify-clang/README.md @@ -27,13 +27,14 @@ - [cuRAND](../docs/markdown/CURAND_API_supported_by_HIP.md) - [cuDNN](../docs/markdown/CUDNN_API_supported_by_HIP.md) - [cuFFT](../docs/markdown/CUFFT_API_supported_by_HIP.md) +- [cuSPARSE](../docs/markdown/CUSPARSE_API_supported_by_HIP.md) ## Dependencies `hipify-clang` requires: 1. LLVM+CLANG of at least version 3.8.0, latest stable and recommended release: 6.0.1 (linux and windows). -2. CUDA at least version 7.5, latest supported release is 9.2. +2. CUDA at least version 7.5, latest supported release is 9.0. | **LLVM release version** | **CUDA latest supported version** | **Comments** | |:------------------------:|:---------------------------------:|:------------:| diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp index 7cb252a8e2..ad7ce43be5 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp @@ -2,4 +2,110 @@ // Maps the names of CUDA SPARSE API types to the corresponding HIP types const std::map CUDA_SPARSE_TYPE_NAME_MAP{ + + // 1. Structs + {"cusparseContext", {"hipsparseContext", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseHandle_t", {"hipsparseHandle_t", CONV_TYPE, API_SPARSE}}, + + {"cusparseHybMat", {"hipsparseHybMat", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseHybMat_t", {"hipsparseHybMat_t", CONV_TYPE, API_SPARSE}}, + + {"cusparseMatDescr", {"hipsparseMatDescr", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseMatDescr_t", {"hipsparseMatDescr_t", CONV_TYPE, API_SPARSE}}, + + {"cusparseSolveAnalysisInfo", {"hipsparseSolveAnalysisInfo", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSolveAnalysisInfo_t", {"hipsparseSolveAnalysisInfo_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + + {"csrsv2Info", {"csrsv2Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"csrsv2Info_t", {"csrsv2Info_t", CONV_TYPE, API_SPARSE}}, + + {"csrsm2Info", {"csrsm2Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"csrsm2Info_t", {"csrsm2Info_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + + {"bsrsv2Info", {"bsrsv2Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"bsrsv2Info_t", {"bsrsv2Info_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + + {"bsrsm2Info", {"bsrsm2Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"bsrsm2Info_t", {"bsrsm2Info_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + + {"bsric02Info", {"bsric02Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"bsric02Info_t", {"bsric02Info_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + + {"csrilu02Info", {"csrilu02Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"csrilu02Info_t", {"csrilu02Info_t", CONV_TYPE, API_SPARSE}}, + + {"bsrilu02Info", {"bsrilu02Info", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"bsrilu02Info_t", {"bsrilu02Info_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + + {"csru2csrInfo", {"csru2csrInfo", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"csru2csrInfo_t", {"csru2csrInfo_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseColorInfo", {"hipsparseColorInfo", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseColorInfo_t", {"hipsparseColorInfo_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + + {"pruneInfo", {"pruneInfo", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"pruneInfo_t", {"pruneInfo_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + + // 2. Enums + {"cusparseAction_t", {"hipsparseAction_t", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_ACTION_SYMBOLIC", {"HIPSPARSE_ACTION_SYMBOLIC", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_ACTION_NUMERIC", {"HIPSPARSE_ACTION_NUMERIC", CONV_NUMERIC_LITERAL, API_SPARSE}}, + + {"cusparseDirection_t", {"hipsparseDirection_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"CUSPARSE_DIRECTION_ROW", {"HIPSPARSE_DIRECTION_ROW", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}}, + {"CUSPARSE_DIRECTION_COLUMN", {"HIPSPARSE_DIRECTION_COLUMN", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseHybPartition_t", {"hipsparseHybPartition_t", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_HYB_PARTITION_AUTO", {"HIPSPARSE_HYB_PARTITION_AUTO", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_HYB_PARTITION_USER", {"HIPSPARSE_HYB_PARTITION_USER", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_HYB_PARTITION_MAX", {"HIPSPARSE_HYB_PARTITION_MAX", CONV_NUMERIC_LITERAL, API_SPARSE}}, + + {"cusparseDiagType_t", {"hipsparseDiagType_t", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_DIAG_TYPE_NON_UNIT", {"HIPSPARSE_DIAG_TYPE_NON_UNIT", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_DIAG_TYPE_UNIT", {"HIPSPARSE_DIAG_TYPE_UNIT", CONV_NUMERIC_LITERAL, API_SPARSE}}, + + {"cusparseFillMode_t", {"hipsparseFillMode_t", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_FILL_MODE_LOWER", {"HIPSPARSE_FILL_MODE_LOWER", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_FILL_MODE_UPPER", {"HIPSPARSE_FILL_MODE_UPPER", CONV_NUMERIC_LITERAL, API_SPARSE}}, + + {"cusparseIndexBase_t", {"hipsparseIndexBase_t", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_INDEX_BASE_ZERO", {"HIPSPARSE_INDEX_BASE_ZERO", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_INDEX_BASE_ONE", {"HIPSPARSE_INDEX_BASE_ONE", CONV_NUMERIC_LITERAL, API_SPARSE}}, + + {"cusparseMatrixType_t", {"hipsparseMatrixType_t", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_MATRIX_TYPE_GENERAL", {"HIPSPARSE_MATRIX_TYPE_GENERAL", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_MATRIX_TYPE_SYMMETRIC", {"HIPSPARSE_MATRIX_TYPE_SYMMETRIC", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_MATRIX_TYPE_HERMITIAN", {"HIPSPARSE_MATRIX_TYPE_HERMITIAN", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_MATRIX_TYPE_TRIANGULAR", {"HIPSPARSE_MATRIX_TYPE_TRIANGULAR", CONV_NUMERIC_LITERAL, API_SPARSE}}, + + {"cusparseOperation_t", {"hipsparseOperation_t", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_OPERATION_NON_TRANSPOSE", {"HIPSPARSE_OPERATION_NON_TRANSPOSE", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_OPERATION_TRANSPOSE", {"HIPSPARSE_OPERATION_TRANSPOSE", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_OPERATION_CONJUGATE_TRANSPOSE", {"HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE", CONV_NUMERIC_LITERAL, API_SPARSE}}, + + {"cusparsePointerMode_t", {"hipsparsePointerMode_t", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_POINTER_MODE_HOST", {"HIPSPARSE_POINTER_MODE_HOST", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_POINTER_MODE_DEVICE", {"HIPSPARSE_POINTER_MODE_DEVICE", CONV_NUMERIC_LITERAL, API_SPARSE}}, + + {"cusparseAlgMode_t", {"hipsparseAlgMode_t", CONV_TYPE, API_SPARSE, HIP_UNSUPPORTED}}, + {"CUSPARSE_ALG0", {"CUSPARSE_ALG0", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}}, + {"CUSPARSE_ALG1", {"CUSPARSE_ALG1", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}}, + {"CUSPARSE_ALG_NAIVE", {"CUSPARSE_ALG_NAIVE", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}}, + {"CUSPARSE_ALG_MERGE_PATH", {"CUSPARSE_ALG_MERGE_PATH", CONV_NUMERIC_LITERAL, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSolvePolicy_t", {"hipsparseSolvePolicy_t", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_SOLVE_POLICY_NO_LEVEL", {"HIPSPARSE_SOLVE_POLICY_NO_LEVEL", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_SOLVE_POLICY_USE_LEVEL", {"HIPSPARSE_SOLVE_POLICY_USE_LEVEL", CONV_NUMERIC_LITERAL, API_SPARSE}}, + + {"cusparseStatus_t", {"hipsparseMatrixType_t", CONV_TYPE, API_SPARSE}}, + {"CUSPARSE_STATUS_SUCCESS", {"HIPSPARSE_STATUS_SUCCESS", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_STATUS_NOT_INITIALIZED", {"HIPSPARSE_STATUS_NOT_INITIALIZED", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_STATUS_ALLOC_FAILED", {"HIPSPARSE_STATUS_ALLOC_FAILED", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_STATUS_INVALID_VALUE", {"HIPSPARSE_STATUS_INVALID_VALUE", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_STATUS_ARCH_MISMATCH", {"HIPSPARSE_STATUS_ARCH_MISMATCH", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_STATUS_MAPPING_ERROR", {"HIPSPARSE_STATUS_MAPPING_ERROR", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_STATUS_EXECUTION_FAILED", {"HIPSPARSE_STATUS_EXECUTION_FAILED", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_STATUS_INTERNAL_ERROR", {"HIPSPARSE_STATUS_INTERNAL_ERROR", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED", {"HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED", CONV_NUMERIC_LITERAL, API_SPARSE}}, + {"CUSPARSE_STATUS_ZERO_PIVOT", {"HIPSPARSE_STATUS_ZERO_PIVOT", CONV_NUMERIC_LITERAL, API_SPARSE}}, }; From 19acf86ceff876ac03f2ace039b55c414c37fe17 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Wed, 21 Nov 2018 12:07:28 -0500 Subject: [PATCH 34/55] Fix issue in kernarg metadata parsing due to early finalization The logic to parse the kernel metadata is unaware that enabling of early finalization could result in multiple code blobs in a single .kernel section. This teaches the HIP runtime to handle that. Change-Id: I1581b42f0da8b30233d7898014f7468728c1d489 --- src/program_state.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/program_state.cpp b/src/program_state.cpp index 7e42a44245..2fda546b54 100644 --- a/src/program_state.cpp +++ b/src/program_state.cpp @@ -590,14 +590,16 @@ unordered_map>>& kernargs() { static once_flag f; call_once(f, []() { - for (auto&& blob : code_object_blobs()) { - stringstream tmp{std::string{ - blob.second.front().cbegin(), blob.second.front().cend()}}; + for (auto&& blobs_for_one_arch : code_object_blobs()) { + for (auto && blob : blobs_for_one_arch.second) { + stringstream tmp{std::string{ + blob.cbegin(), blob.cend()}}; - elfio reader; - if (!reader.load(tmp)) continue; + elfio reader; + if (!reader.load(tmp)) continue; - read_kernarg_metadata(reader, r); + read_kernarg_metadata(reader, r); + } } }); From 81cf7cabfa9e4efcc965e7b58c33ffe2bf61a3f2 Mon Sep 17 00:00:00 2001 From: Qianfeng Zhang Date: Thu, 22 Nov 2018 18:58:06 +0800 Subject: [PATCH 35/55] Add support of printing process ID for HIP Tracing --- src/hip_hcc.cpp | 5 +++-- src/hip_hcc_internal.h | 50 ++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/hip_hcc.cpp b/src/hip_hcc.cpp index e152e7ba69..9b2d18f22e 100644 --- a/src/hip_hcc.cpp +++ b/src/hip_hcc.cpp @@ -179,7 +179,7 @@ uint64_t recordApiTrace(std::string* fullStr, const std::string& apiStr) { if (COMPILE_HIP_DB && HIP_TRACE_API) { - fprintf(stderr, "%s<c_str(), apiStartTick, + fprintf(stderr, "%s<c_str(), apiStartTick, API_COLOR_END); } @@ -237,6 +237,7 @@ hipError_t ihipSynchronize(void) { //================================================================================================= TidInfo::TidInfo() : _apiSeqNum(0) { _shortTid = g_lastShortTid.fetch_add(1); + _pid = getpid(); if (COMPILE_HIP_DB && HIP_TRACE_API) { std::stringstream tid_ss; @@ -1535,7 +1536,7 @@ void ihipPrintKernelLaunch(const char* kernelName, const grid_launch_parm* lp, if ((HIP_TRACE_API & (1 << TRACE_KCMD)) || HIP_PROFILE_API || (COMPILE_HIP_DB & HIP_TRACE_API)) { std::stringstream os; - os << tls_tidInfo.tid() << "." << tls_tidInfo.apiSeqNum() << " hipLaunchKernel '" + os << tls_tidInfo.pid() << " " << tls_tidInfo.tid() << "." << tls_tidInfo.apiSeqNum() << " hipLaunchKernel '" << kernelName << "'" << " gridDim:" << lp->grid_dim << " groupDim:" << lp->group_dim << " sharedMem:+" << lp->dynamic_group_mem_bytes << " " << *stream; diff --git a/src/hip_hcc_internal.h b/src/hip_hcc_internal.h index 8102f066de..3a183340c2 100644 --- a/src/hip_hcc_internal.h +++ b/src/hip_hcc_internal.h @@ -94,11 +94,13 @@ class TidInfo { TidInfo(); int tid() const { return _shortTid; }; + pid_t pid() const { return _pid; }; uint64_t incApiSeqNum() { return ++_apiSeqNum; }; uint64_t apiSeqNum() const { return _apiSeqNum; }; private: int _shortTid; + pid_t _pid; // monotonically increasing API sequence number for this threa. uint64_t _apiSeqNum; @@ -243,14 +245,14 @@ static const DbName dbName[] = { #if COMPILE_HIP_DB -#define tprintf(trace_level, ...) \ - { \ - if (HIP_DB & (1 << (trace_level))) { \ - char msgStr[1000]; \ - snprintf(msgStr, sizeof(msgStr), __VA_ARGS__); \ - fprintf(stderr, " %ship-%s tid:%d:%s%s", dbName[trace_level]._color, \ - dbName[trace_level]._shortName, tls_tidInfo.tid(), msgStr, KNRM); \ - } \ +#define tprintf(trace_level, ...) \ + { \ + if (HIP_DB & (1 << (trace_level))) { \ + char msgStr[1000]; \ + snprintf(msgStr, sizeof(msgStr), __VA_ARGS__); \ + fprintf(stderr, " %ship-%s pid:%d tid:%d:%s%s", dbName[trace_level]._color, \ + dbName[trace_level]._shortName, tls_tidInfo.pid(), tls_tidInfo.tid(), msgStr, KNRM); \ + } \ } #else /* Compile to empty code */ @@ -313,22 +315,22 @@ extern uint64_t recordApiTrace(std::string* fullStr, const std::string& apiStr); // This macro should be called at the end of every HIP API, and only at the end of top-level hip // APIS (not internal hip) It has dual function: logs the last error returned for use by // hipGetLastError, and also prints the closing message when the debug trace is enabled. -#define ihipLogStatus(hipStatus) \ - ({ \ - hipError_t localHipStatus = hipStatus; /*local copy so hipStatus only evaluated once*/ \ - tls_lastHipError = localHipStatus; \ - \ - if ((COMPILE_HIP_TRACE_API & 0x2) && HIP_TRACE_API & (1 << TRACE_ALL)) { \ - auto ticks = getTicks() - hipApiStartTick; \ - fprintf(stderr, " %ship-api tid:%d.%lu %-30s ret=%2d (%s)>> +%lu ns%s\n", \ - (localHipStatus == 0) ? API_COLOR : KRED, tls_tidInfo.tid(), \ - tls_tidInfo.apiSeqNum(), __func__, localHipStatus, \ - ihipErrorString(localHipStatus), ticks, API_COLOR_END); \ - } \ - if (HIP_PROFILE_API) { \ - MARKER_END(); \ - } \ - localHipStatus; \ +#define ihipLogStatus(hipStatus) \ + ({ \ + hipError_t localHipStatus = hipStatus; /*local copy so hipStatus only evaluated once*/ \ + tls_lastHipError = localHipStatus; \ + \ + if ((COMPILE_HIP_TRACE_API & 0x2) && HIP_TRACE_API & (1 << TRACE_ALL)) { \ + auto ticks = getTicks() - hipApiStartTick; \ + fprintf(stderr, " %ship-api pid:%d tid:%d.%lu %-30s ret=%2d (%s)>> +%lu ns%s\n", \ + (localHipStatus == 0) ? API_COLOR : KRED, tls_tidInfo.pid(), tls_tidInfo.tid(), \ + tls_tidInfo.apiSeqNum(), __func__, localHipStatus, \ + ihipErrorString(localHipStatus), ticks, API_COLOR_END); \ + } \ + if (HIP_PROFILE_API) { \ + MARKER_END(); \ + } \ + localHipStatus; \ }) From 3bcf2fcd18f02f1d4199a326a2cdf792930edb4a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 22 Nov 2018 21:12:08 -0600 Subject: [PATCH 36/55] fixing the adding of USE_PROF_API define only if the tracer header was found --- CMakeLists.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 154971f480..1608bbdb2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,16 +153,20 @@ add_to_config(_buildInfo COMPILE_HIP_ATP_MARKER) ################ # Detect profiling API ################ -if (USE_PROF_API EQUAL 1) -add_definitions(-DUSE_PROF_API=1) -find_path(PROF_API_HEADER_DIR NAMES prof_protocol.h PATHS ${PROF_API_HEADER_PATH} /opt/rocm/roctracer/include/roctracer NO_DEFAULT_PATH) -if (NOT PROF_API_HEADER_DIR) +if(USE_PROF_API EQUAL 1) +if(NOT DEFINED PROF_API_HEADER_PATH) + set(PROF_API_HEADER_PATH /opt/rocm/roctracer/include/ext) +endif () +find_path(PROF_API_HEADER_DIR NAMES prof_protocol.h PATHS ${PROF_API_HEADER_PATH} NO_DEFAULT_PATH) +if(NOT PROF_API_HEADER_DIR) + MESSAGE("PROF_API_HEADER_PATH = ${PROF_API_HEADER_PATH}") MESSAGE("Profiling API header not found, use -DPROF_API_HEADER_PATH=") -else () +else() + add_definitions(-DUSE_PROF_API=1) include_directories ( ${PROF_API_HEADER_DIR} ) -endif () -MESSAGE("PROF_API_HEADER_DIR = ${PROF_API_HEADER_DIR}") -endif () + MESSAGE("PROF_API_HEADER_DIR = ${PROF_API_HEADER_DIR}") +endif() +endif() ############################# # Build steps From 8a4354bdc0289c0462874abd01203d76b41be01a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 22 Nov 2018 21:51:20 -0600 Subject: [PATCH 37/55] FATAL_ERRROR if Profiling API header not found --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1608bbdb2b..45d7640643 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,11 +160,11 @@ endif () find_path(PROF_API_HEADER_DIR NAMES prof_protocol.h PATHS ${PROF_API_HEADER_PATH} NO_DEFAULT_PATH) if(NOT PROF_API_HEADER_DIR) MESSAGE("PROF_API_HEADER_PATH = ${PROF_API_HEADER_PATH}") - MESSAGE("Profiling API header not found, use -DPROF_API_HEADER_PATH=") + MESSAGE(FATAL_ERROR "Profiling API header not found, use -DPROF_API_HEADER_PATH=") else() add_definitions(-DUSE_PROF_API=1) include_directories ( ${PROF_API_HEADER_DIR} ) - MESSAGE("PROF_API_HEADER_DIR = ${PROF_API_HEADER_DIR}") + MESSAGE(STATUS "Profiling API: ${PROF_API_HEADER_DIR}") endif() endif() From c7f62668245e51b058eaf66c1ac76256e36719ba Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 26 Nov 2018 15:11:52 +0300 Subject: [PATCH 38/55] [HIPIFY][SPARSE] Helper and Level 1,2 functions + 2 cuSPARSE tests + update CUSPARSE_API_supported_by_HIP.md --- .../markdown/CUSPARSE_API_supported_by_HIP.md | 151 ++++++- .../src/CUDA2HIP_SPARSE_API_functions.cpp | 172 ++++++++ .../src/CUDA2HIP_SPARSE_API_types.cpp | 2 +- tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu | 367 ++++++++++++++++++ tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu | 284 ++++++++++++++ 5 files changed, 974 insertions(+), 2 deletions(-) create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu diff --git a/docs/markdown/CUSPARSE_API_supported_by_HIP.md b/docs/markdown/CUSPARSE_API_supported_by_HIP.md index cbc4074daf..d3707573a5 100644 --- a/docs/markdown/CUSPARSE_API_supported_by_HIP.md +++ b/docs/markdown/CUSPARSE_API_supported_by_HIP.md @@ -83,7 +83,156 @@ | struct |`pruneInfo` | | | typedef |`pruneInfo_t` | | -## **2. CUSPARSE API functions** +## **2.cuSPARSE Helper Function Reference** | **CUDA** | **HIP** | |-----------------------------------------------------------|-------------------------------------------------| +|`cusparseCreate` |`hipsparseCreate` | +|`cusparseCreateSolveAnalysisInfo` | | +|`cusparseCreateHybMat` |`hipsparseCreateHybMat` | +|`cusparseCreateMatDescr` |`hipsparseCreateMatDescr` | +|`cusparseDestroy` |`hipsparseDestroy` | +|`cusparseDestroySolveAnalysisInfo` | | +|`cusparseDestroyHybMat` |`hipsparseDestroyHybMat` | +|`cusparseDestroyMatDescr` |`hipsparseDestroyMatDescr` | +|`cusparseGetLevelInfo` | | +|`cusparseGetMatDiagType` |`hipsparseGetMatDiagType` | +|`cusparseGetMatFillMode` |`hipsparseGetMatFillMode` | +|`cusparseGetMatIndexBase` |`hipsparseGetMatIndexBase` | +|`cusparseGetMatType` |`hipsparseGetMatType` | +|`cusparseGetPointerMode` |`hipsparseGetPointerMode` | +|`cusparseGetVersion` |`hipsparseGetVersion` | +|`cusparseSetMatDiagType` |`hipsparseSetMatDiagType` | +|`cusparseSetMatFillMode` |`hipsparseSetMatFillMode` | +|`cusparseSetMatType` |`hipsparseSetMatType` | +|`cusparseSetPointerMode` |`hipsparseSetPointerMode` | +|`cusparseSetStream` |`hipsparseSetStream` | +|`cusparseGetStream` |`hipsparseGetStream` | +|`cusparseCreateCsrsv2Info` |`hipsparseCreateCsrsv2Info` | +|`cusparseDestroyCsrsv2Info` |`hipsparseDestroyCsrsv2Info` | +|`cusparseCreateCsrsm2Info` | | +|`cusparseDestroyCsrsm2Info` | | +|`cusparseCreateCsric02Info` | | +|`cusparseDestroyCsric02Info` | | +|`cusparseCreateCsrilu02Info` |`hipsparseCreateCsrilu02Info` | +|`cusparseDestroyCsrilu02Info` |`hipsparseDestroyCsrilu02Info` | +|`cusparseCreateBsrsv2Info` | | +|`cusparseDestroyBsrsv2Info` | | +|`cusparseCreateBsrsm2Info` | | +|`cusparseDestroyBsrsm2Info` | | +|`cusparseCreateBsric02Info` | | +|`cusparseDestroyBsric02Info` | | +|`cusparseCreateBsrilu02Info` | | +|`cusparseDestroyBsrilu02Info` | | +|`cusparseCreateCsrgemm2Info` | | +|`cusparseDestroyCsrgemm2Info` | | +|`cusparseCreatePruneInfo` | | +|`cusparseDestroyPruneInfo` | | + +## **3.cuSPARSE Level 1 Function Reference** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseSaxpyi` |`hipsparseSaxpyi` | +|`cusparseDaxpyi` |`hipsparseDaxpyi` | +|`cusparseCaxpyi` | | +|`cusparseZaxpyi` | | +|`cusparseSdoti` |`hipsparseSdoti` | +|`cusparseDdoti` |`hipsparseDdoti` | +|`cusparseCdoti` | | +|`cusparseZdoti` | | +|`cusparseCdotci` | | +|`cusparseZdotci` | | +|`cusparseSgthr` |`hipsparseSgthr` | +|`cusparseDgthr` |`hipsparseDgthr` | +|`cusparseCgthr` | | +|`cusparseZgthr` | | +|`cusparseSgthrz` |`hipsparseSgthrz` | +|`cusparseDgthrz` |`hipsparseDgthrz` | +|`cusparseCgthrz` | | +|`cusparseZgthrz` | | +|`cusparseSroti` |`hipsparseSroti` | +|`cusparseDroti` |`hipsparseDroti` | +|`cusparseSsctr` |`hipsparseSsctr` | +|`cusparseDsctr` |`hipsparseDsctr` | +|`cusparseCsctr` | | +|`cusparseZsctr` | | + +## **4.cuSPARSE Level 2 Function Reference** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseSbsrmv` | | +|`cusparseDbsrmv` | | +|`cusparseCbsrmv` | | +|`cusparseZbsrmv` | | +|`cusparseSbsrxmv` | | +|`cusparseDbsrxmv` | | +|`cusparseCbsrxmv` | | +|`cusparseZbsrxmv` | | +|`cusparseScsrmv` |`hipsparseScsrmv` | +|`cusparseDcsrmv` |`hipsparseDcsrmv` | +|`cusparseCcsrmv` | | +|`cusparseZcsrmv` | | +|`cusparseCsrmvEx` | | +|`cusparseCsrmvEx_bufferSize` | | +|`cusparseScsrmv_mp` | | +|`cusparseDcsrmv_mp` | | +|`cusparseCcsrmv_mp` | | +|`cusparseZcsrmv_mp` | | +|`cusparseSgemvi` | | +|`cusparseDgemvi` | | +|`cusparseCgemvi` | | +|`cusparseZgemvi` | | +|`cusparseSgemvi_bufferSize` | | +|`cusparseDgemvi_bufferSize` | | +|`cusparseCgemvi_bufferSize` | | +|`cusparseZgemvi_bufferSize` | | +|`cusparseSbsrsv2_bufferSize` | | +|`cusparseDbsrsv2_bufferSize` | | +|`cusparseCbsrsv2_bufferSize` | | +|`cusparseZbsrsv2_bufferSize` | | +|`cusparseSbsrsv2_analysis` | | +|`cusparseDbsrsv2_analysis` | | +|`cusparseCbsrsv2_analysis` | | +|`cusparseZbsrsv2_analysis` | | +|`cusparseScsrsv_solve` | | +|`cusparseDcsrsv_solve` | | +|`cusparseCcsrsv_solve` | | +|`cusparseZcsrsv_solve` | | +|`cusparseXbsrsv2_zeroPivot` | | +|`cusparseScsrsv_analysis` | | +|`cusparseDcsrsv_analysis` | | +|`cusparseCcsrsv_analysis` | | +|`cusparseZcsrsv_analysis` | | +|`cusparseCsrsv_analysisEx` | | +|`cusparseScsrsv_solve` | | +|`cusparseDcsrsv_solve` | | +|`cusparseCcsrsv_solve` | | +|`cusparseZcsrsv_solve` | | +|`cusparseCsrsv_solveEx` | | +|`cusparseScsrsv2_bufferSize` |`hipsparseScsrsv2_bufferSize` | +|`cusparseDcsrsv2_bufferSize` |`hipsparseDcsrsv2_bufferSize` | +|`cusparseCcsrsv2_bufferSize` | | +|`cusparseZcsrsv2_bufferSize` | | +|`cusparseScsrsv2_analysis` |`hipsparseScsrsv2_analysis` | +|`cusparseDcsrsv2_analysis` |`hipsparseDcsrsv2_analysis` | +|`cusparseCcsrsv2_analysis` | | +|`cusparseZcsrsv2_analysis` | | +|`cusparseScsrsv2_solve` |`hipsparseScsrsv2_solve` | +|`cusparseDcsrsv2_solve` |`hipsparseDcsrsv2_solve` | +|`cusparseCcsrsv2_solve` | | +|`cusparseZcsrsv2_solve` | | +|`cusparseXcsrsv2_zeroPivot` |`hipsparseXcsrsv2_zeroPivot` | +|`cusparseShybmv` |`hipsparseShybmv` | +|`cusparseDhybmv` |`hipsparseDhybmv` | +|`cusparseChybmv` | | +|`cusparseZhybmv` | | +|`cusparseShybsv_analysis` | | +|`cusparseDhybsv_analysis` | | +|`cusparseChybsv_analysis` | | +|`cusparseZhybsv_analysis` | | +|`cusparseShybsv_solve` | | +|`cusparseDhybsv_solve` | | +|`cusparseChybsv_solve` | | +|`cusparseZhybsv_solve` | | diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp index 9331e297d7..429c8d0ea2 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -2,4 +2,176 @@ // Maps the names of CUDA SPARSE API types to the corresponding HIP types const std::map CUDA_SPARSE_FUNCTION_MAP{ + // 5. cuSPARSE Helper Function Reference + {"cusparseCreate", {"hipsparseCreate", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCreateSolveAnalysisInfo", {"hipsparseCreateSolveAnalysisInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateHybMat", {"hipsparseCreateHybMat", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCreateMatDescr", {"hipsparseCreateMatDescr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDestroy", {"hipsparseDestroy", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDestroySolveAnalysisInfo", {"hipsparseDestroySolveAnalysisInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyHybMat", {"hipsparseDestroyHybMat", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDestroyMatDescr", {"hipsparseDestroyMatDescr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetLevelInfo", {"hipsparseGetLevelInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseGetMatDiagType", {"hipsparseGetMatDiagType", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetMatFillMode", {"hipsparseGetMatFillMode", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetMatIndexBase", {"hipsparseGetMatIndexBase", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetMatType", {"hipsparseGetMatType", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetPointerMode", {"hipsparseGetPointerMode", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetVersion", {"hipsparseGetVersion", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetMatDiagType", {"hipsparseSetMatDiagType", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetMatFillMode", {"hipsparseSetMatFillMode", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetMatIndexBase", {"hipsparseSetMatIndexBase", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetMatType", {"hipsparseSetMatType", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetPointerMode", {"hipsparseSetPointerMode", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetStream", {"hipsparseSetStream", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetStream", {"hipsparseGetStream", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCreateCsrsv2Info", {"hipsparseCreateCsrsv2Info", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDestroyCsrsv2Info", {"hipsparseDestroyCsrsv2Info", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCreateCsrsm2Info", {"hipsparseCreateCsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyCsrsm2Info", {"hipsparseDestroyCsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateCsric02Info", {"hipsparseCreateCsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyCsric02Info", {"hipsparseDestroyCsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateCsrilu02Info", {"hipsparseCreateCsrilu02Info", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDestroyCsrilu02Info", {"hipsparseDestroyCsrilu02Info", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCreateBsrsv2Info", {"hipsparseCreateBsrsv2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyBsrsv2Info", {"hipsparseDestroyBsrsv2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateBsrsm2Info", {"hipsparseCreateBsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyBsrsm2Info", {"hipsparseDestroyBsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateBsric02Inf", {"hipsparseCreateBsric02Inf", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyBsric02Info", {"hipsparseDestroyBsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateBsrilu02Info", {"hipsparseCreateBsrilu02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyBsrilu02Info", {"hipsparseDestroyBsrilu02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateCsrgemm2Info", {"hipsparseCreateCsrgemm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyCsrgemm2Info", {"hipsparseDestroyCsrgemm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreatePruneInfo", {"hipsparseCreatePruneInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyPruneInfo", {"hipsparseDestroyPruneInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + // 6. cuSPARSE Level 1 Function Reference + {"cusparseSaxpyi", {"hipsparseSaxpyi", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDaxpyi", {"hipsparseDaxpyi", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCaxpyi", {"hipsparseCaxpyi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZaxpyi", {"hipsparseZaxpyi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSdoti", {"hipsparseSdoti", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDdoti", {"hipsparseDdoti", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCdoti", {"hipsparseCdoti", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZdoti", {"hipsparseZdoti", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseCdotci", {"hipsparseCdotci", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZdotci", {"hipsparseZdotci", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgthr", {"hipsparseSgthr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDgthr", {"hipsparseDgthr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCgthr", {"hipsparseCgthr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgthr", {"hipsparseZgthr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgthrz", {"hipsparseSgthrz", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDgthrz", {"hipsparseDgthrz", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCgthrz", {"hipsparseCgthrz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgthrz", {"hipsparseZgthrz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSroti", {"hipsparseSroti", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDroti", {"hipsparseDroti", CONV_LIB_FUNC, API_SPARSE}}, + + {"cusparseSsctr", {"hipsparseSsctr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDsctr", {"hipsparseDsctr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCsctr", {"hipsparseCsctr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZsctr", {"hipsparseZsctr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + // 7. cuSPARSE Level 2 Function Reference + {"cusparseSbsrmv", {"hipsparseSbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrmv", {"hipsparseDbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrmv", {"hipsparseCbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrmv", {"hipsparseZbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsrxmv", {"hipsparseSbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrxmv", {"hipsparseDbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrxmv", {"hipsparseCbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrxmv", {"hipsparseZbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrmv", {"hipsparseScsrmv", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrmv", {"hipsparseDcsrmv", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrmv", {"hipsparseCcsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrmv", {"hipsparseZcsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseCsrmvEx", {"hipsparseCsrmvEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCsrmvEx_bufferSize", {"hipsparseCsrmvEx_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrmv_mp", {"hipsparseScsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrmv_mp", {"hipsparseDcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrmv_mp", {"hipsparseCcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrmv_mp", {"hipsparseZcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgemvi", {"hipsparseSgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgemvi", {"hipsparseDgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgemvi", {"hipsparseCgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgemvi", {"hipsparseZgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgemvi_bufferSize", {"hipsparseSgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgemvi_bufferSize", {"hipsparseDgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgemvi_bufferSize", {"hipsparseCgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgemvi_bufferSize", {"hipsparseZgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsrsv2_bufferSize", {"hipsparseSbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrsv2_bufferSize", {"hipsparseDbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrsv2_bufferSize", {"hipsparseCbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrsv2_bufferSize", {"hipsparseZbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsrsv2_analysis", {"hipsparseSbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrsv2_analysis", {"hipsparseDbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrsv2_analysis", {"hipsparseCbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrsv2_analysis", {"hipsparseZbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsv_solve", {"hipsparseScsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsv_solve", {"hipsparseDcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsv_solve", {"hipsparseCcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv_solve", {"hipsparseZcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXbsrsv2_zeroPivot", {"hipsparseXbsrsv2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsv_analysis", {"hipsparseScsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsv_analysis", {"hipsparseDcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsv_analysis", {"hipsparseCcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv_analysis", {"hipsparseZcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseCsrsv_analysisEx", {"hipsparseCsrsv_analysisEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsv_solve", {"hipsparseScsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsv_solve", {"hipsparseDcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsv_solve", {"hipsparseCcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv_solve", {"hipsparseZcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseCsrsv_solveEx", {"hipsparseCsrsv_solveEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsv2_bufferSize", {"hipsparseScsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrsv2_bufferSize", {"hipsparseDcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrsv2_bufferSize", {"hipsparseCcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv2_bufferSize", {"hipsparseZcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsv2_analysis", {"hipsparseScsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrsv2_analysis", {"hipsparseDcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrsv2_analysis", {"hipsparseCcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv2_analysis", {"hipsparseZcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsv2_solve", {"hipsparseScsrsv2_solve", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrsv2_solve", {"hipsparseDcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrsv2_solve", {"hipsparseCcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv2_solve", {"hipsparseZcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXcsrsv2_zeroPivot", {"hipsparseXcsrsv2_zeroPivot", CONV_LIB_FUNC, API_SPARSE}}, + + {"cusparseShybmv", {"hipsparseShybmv", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDhybmv", {"hipsparseDhybmv", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseChybmv", {"hipsparseChybmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZhybmv", {"hipsparseZhybmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseShybsv_analysis", {"hipsparseShybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDhybsv_analysis", {"hipsparseDhybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseChybsv_analysis", {"hipsparseChybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZhybsv_analysis", {"hipsparseZhybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseShybsv_solve", {"hipsparseShybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDhybsv_solve", {"hipsparseDhybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseChybsv_solve", {"hipsparseChybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZhybsv_solve", {"hipsparseZhybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, }; diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp index ad7ce43be5..298e00a7bd 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_types.cpp @@ -97,7 +97,7 @@ const std::map CUDA_SPARSE_TYPE_NAME_MAP{ {"CUSPARSE_SOLVE_POLICY_NO_LEVEL", {"HIPSPARSE_SOLVE_POLICY_NO_LEVEL", CONV_NUMERIC_LITERAL, API_SPARSE}}, {"CUSPARSE_SOLVE_POLICY_USE_LEVEL", {"HIPSPARSE_SOLVE_POLICY_USE_LEVEL", CONV_NUMERIC_LITERAL, API_SPARSE}}, - {"cusparseStatus_t", {"hipsparseMatrixType_t", CONV_TYPE, API_SPARSE}}, + {"cusparseStatus_t", {"hipsparseStatus_t", CONV_TYPE, API_SPARSE}}, {"CUSPARSE_STATUS_SUCCESS", {"HIPSPARSE_STATUS_SUCCESS", CONV_NUMERIC_LITERAL, API_SPARSE}}, {"CUSPARSE_STATUS_NOT_INITIALIZED", {"HIPSPARSE_STATUS_NOT_INITIALIZED", CONV_NUMERIC_LITERAL, API_SPARSE}}, {"CUSPARSE_STATUS_ALLOC_FAILED", {"HIPSPARSE_STATUS_ALLOC_FAILED", CONV_NUMERIC_LITERAL, API_SPARSE}}, diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu new file mode 100644 index 0000000000..5ef7c188ee --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu @@ -0,0 +1,367 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +// CHECK: #include +#include +// CHECK: #include "hipsparse.h" +#include "cusparse.h" + +// CHECK: if (y) hipFree(y); +// CHECK: if (z) hipFree(z); +// CHECK: if (xInd) hipFree(xInd); +// CHECK: if (xVal) hipFree(xVal); +// CHECK: if (csrRowPtr) hipFree(csrRowPtr); +// CHECK: if (cooRowIndex) hipFree(cooRowIndex); +// CHECK: if (cooColIndex) hipFree(cooColIndex); +// CHECK: if (cooVal) hipFree(cooVal); +// CHECK: if (descr) hipsparseDestroyMatDescr(descr); +// CHECK: if (handle) hipsparseDestroy(handle); +// CHECK: hipDeviceReset(); +#define CLEANUP(s) \ +do { \ + printf ("%s\n", s); \ + if (yHostPtr) free(yHostPtr); \ + if (zHostPtr) free(zHostPtr); \ + if (xIndHostPtr) free(xIndHostPtr); \ + if (xValHostPtr) free(xValHostPtr); \ + if (cooRowIndexHostPtr) free(cooRowIndexHostPtr);\ + if (cooColIndexHostPtr) free(cooColIndexHostPtr);\ + if (cooValHostPtr) free(cooValHostPtr); \ + if (y) cudaFree(y); \ + if (z) cudaFree(z); \ + if (xInd) cudaFree(xInd); \ + if (xVal) cudaFree(xVal); \ + if (csrRowPtr) cudaFree(csrRowPtr); \ + if (cooRowIndex) cudaFree(cooRowIndex); \ + if (cooColIndex) cudaFree(cooColIndex); \ + if (cooVal) cudaFree(cooVal); \ + if (descr) cusparseDestroyMatDescr(descr);\ + if (handle) cusparseDestroy(handle); \ + cudaDeviceReset(); \ + fflush (stdout); \ +} while (0) + +int main(){ + // CHECK: hipError_t cudaStat1,cudaStat2,cudaStat3,cudaStat4,cudaStat5,cudaStat6; + cudaError_t cudaStat1,cudaStat2,cudaStat3,cudaStat4,cudaStat5,cudaStat6; + // CHECK: hipsparseStatus_t status; + cusparseStatus_t status; + // CHECK: hipsparseHandle_t handle=0; + cusparseHandle_t handle=0; + // CHECK: hipsparseMatDescr_t descr=0; + cusparseMatDescr_t descr=0; + int * cooRowIndexHostPtr=0; + int * cooColIndexHostPtr=0; + double * cooValHostPtr=0; + int * cooRowIndex=0; + int * cooColIndex=0; + double * cooVal=0; + int * xIndHostPtr=0; + double * xValHostPtr=0; + double * yHostPtr=0; + int * xInd=0; + double * xVal=0; + double * y=0; + int * csrRowPtr=0; + double * zHostPtr=0; + double * z=0; + int n, nnz, nnz_vector; + double dzero =0.0; + double dtwo =2.0; + double dthree=3.0; + double dfive =5.0; + printf("testing example\n"); + /* create the following sparse test matrix in COO format */ + /* |1.0 2.0 3.0| + | 4.0 | + |5.0 6.0 7.0| + | 8.0 9.0| */ + n=4; nnz=9; + cooRowIndexHostPtr = (int *) malloc(nnz*sizeof(cooRowIndexHostPtr[0])); + cooColIndexHostPtr = (int *) malloc(nnz*sizeof(cooColIndexHostPtr[0])); + cooValHostPtr = (double *)malloc(nnz*sizeof(cooValHostPtr[0])); + if ((!cooRowIndexHostPtr) || (!cooColIndexHostPtr) || (!cooValHostPtr)){ + CLEANUP("Host malloc failed (matrix)"); + return 1; + } + cooRowIndexHostPtr[0]=0; cooColIndexHostPtr[0]=0; cooValHostPtr[0]=1.0; + cooRowIndexHostPtr[1]=0; cooColIndexHostPtr[1]=2; cooValHostPtr[1]=2.0; + cooRowIndexHostPtr[2]=0; cooColIndexHostPtr[2]=3; cooValHostPtr[2]=3.0; + cooRowIndexHostPtr[3]=1; cooColIndexHostPtr[3]=1; cooValHostPtr[3]=4.0; + cooRowIndexHostPtr[4]=2; cooColIndexHostPtr[4]=0; cooValHostPtr[4]=5.0; + cooRowIndexHostPtr[5]=2; cooColIndexHostPtr[5]=2; cooValHostPtr[5]=6.0; + cooRowIndexHostPtr[6]=2; cooColIndexHostPtr[6]=3; cooValHostPtr[6]=7.0; + cooRowIndexHostPtr[7]=3; cooColIndexHostPtr[7]=1; cooValHostPtr[7]=8.0; + cooRowIndexHostPtr[8]=3; cooColIndexHostPtr[8]=3; cooValHostPtr[8]=9.0; + nnz_vector = 3; + xIndHostPtr = (int *) malloc(nnz_vector*sizeof(xIndHostPtr[0])); + xValHostPtr = (double *)malloc(nnz_vector*sizeof(xValHostPtr[0])); + yHostPtr = (double *)malloc(2*n *sizeof(yHostPtr[0])); + zHostPtr = (double *)malloc(2*(n+1) *sizeof(zHostPtr[0])); + if((!xIndHostPtr) || (!xValHostPtr) || (!yHostPtr) || (!zHostPtr)) { + CLEANUP("Host malloc failed (vectors)"); + return 1; + } + yHostPtr[0] = 10.0; + xIndHostPtr[0]=0; + xValHostPtr[0]=100.0; + yHostPtr[1] = 20.0; + xIndHostPtr[1]=1; + xValHostPtr[1]=200.0; + yHostPtr[2] = 30.0; + yHostPtr[3] = 40.0; + xIndHostPtr[2]=3; + xValHostPtr[2]=400.0; + yHostPtr[4] = 50.0; + yHostPtr[5] = 60.0; + yHostPtr[6] = 70.0; + yHostPtr[7] = 80.0; + /* allocate GPU memory and copy the matrix and vectors into it */ + // CHECK: cudaStat1 = hipMalloc((void**)&cooRowIndex,nnz*sizeof(cooRowIndex[0])); + cudaStat1 = cudaMalloc((void**)&cooRowIndex,nnz*sizeof(cooRowIndex[0])); + // CHECK: cudaStat2 = hipMalloc((void**)&cooColIndex,nnz*sizeof(cooColIndex[0])); + cudaStat2 = cudaMalloc((void**)&cooColIndex,nnz*sizeof(cooColIndex[0])); + // CHECK: cudaStat3 = hipMalloc((void**)&cooVal, nnz*sizeof(cooVal[0])); + cudaStat3 = cudaMalloc((void**)&cooVal, nnz*sizeof(cooVal[0])); + // CHECK: cudaStat4 = hipMalloc((void**)&y, 2*n*sizeof(y[0])); + cudaStat4 = cudaMalloc((void**)&y, 2*n*sizeof(y[0])); + // CHECK: cudaStat5 = hipMalloc((void**)&xInd,nnz_vector*sizeof(xInd[0])); + cudaStat5 = cudaMalloc((void**)&xInd,nnz_vector*sizeof(xInd[0])); + // CHECK: cudaStat6 = hipMalloc((void**)&xVal,nnz_vector*sizeof(xVal[0])); + cudaStat6 = cudaMalloc((void**)&xVal,nnz_vector*sizeof(xVal[0])); + // CHECK: if ((cudaStat1 != hipSuccess) || + // CHECK: (cudaStat2 != hipSuccess) || + // CHECK: (cudaStat3 != hipSuccess) || + // CHECK: (cudaStat4 != hipSuccess) || + // CHECK: (cudaStat5 != hipSuccess) || + // CHECK: (cudaStat6 != hipSuccess)) { + if ((cudaStat1 != cudaSuccess) || + (cudaStat2 != cudaSuccess) || + (cudaStat3 != cudaSuccess) || + (cudaStat4 != cudaSuccess) || + (cudaStat5 != cudaSuccess) || + (cudaStat6 != cudaSuccess)) { + CLEANUP("Device malloc failed"); + return 1; + } + // CHECK: cudaStat1 = hipMemcpy(cooRowIndex, cooRowIndexHostPtr, + // CHECK: hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(cooRowIndex, cooRowIndexHostPtr, + (size_t)(nnz*sizeof(cooRowIndex[0])), + cudaMemcpyHostToDevice); + // CHECK: cudaStat2 = hipMemcpy(cooColIndex, cooColIndexHostPtr, + // CHECK: hipMemcpyHostToDevice); + cudaStat2 = cudaMemcpy(cooColIndex, cooColIndexHostPtr, + (size_t)(nnz*sizeof(cooColIndex[0])), + cudaMemcpyHostToDevice); + // CHECK: cudaStat3 = hipMemcpy(cooVal, cooValHostPtr, + // CHECK: hipMemcpyHostToDevice); + cudaStat3 = cudaMemcpy(cooVal, cooValHostPtr, + (size_t)(nnz*sizeof(cooVal[0])), + cudaMemcpyHostToDevice); + // CHECK: cudaStat4 = hipMemcpy(y, yHostPtr, + // CHECK: hipMemcpyHostToDevice); + cudaStat4 = cudaMemcpy(y, yHostPtr, + (size_t)(2*n*sizeof(y[0])), + cudaMemcpyHostToDevice); + // CHECK: cudaStat5 = hipMemcpy(xInd, xIndHostPtr, + // CHECK: hipMemcpyHostToDevice); + cudaStat5 = cudaMemcpy(xInd, xIndHostPtr, + (size_t)(nnz_vector*sizeof(xInd[0])), + cudaMemcpyHostToDevice); + // CHECK: cudaStat6 = hipMemcpy(xVal, xValHostPtr, + // CHECK: hipMemcpyHostToDevice); + cudaStat6 = cudaMemcpy(xVal, xValHostPtr, + (size_t)(nnz_vector*sizeof(xVal[0])), + cudaMemcpyHostToDevice); + // CHECK: if ((cudaStat1 != hipSuccess) || + // CHECK: (cudaStat2 != hipSuccess) || + // CHECK: (cudaStat3 != hipSuccess) || + // CHECK: (cudaStat4 != hipSuccess) || + // CHECK: (cudaStat5 != hipSuccess) || + // CHECK: (cudaStat6 != hipSuccess)) { + if ((cudaStat1 != cudaSuccess) || + (cudaStat2 != cudaSuccess) || + (cudaStat3 != cudaSuccess) || + (cudaStat4 != cudaSuccess) || + (cudaStat5 != cudaSuccess) || + (cudaStat6 != cudaSuccess)) { + CLEANUP("Memcpy from Host to Device failed"); + return 1; + } + /* initialize cusparse library */ + // CHECK: status= hipsparseCreate(&handle); + status= cusparseCreate(&handle); + // CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) { + if (status != CUSPARSE_STATUS_SUCCESS) { + CLEANUP("CUSPARSE Library initialization failed"); + return 1; + } + /* create and setup matrix descriptor */ + // CHECK: status= hipsparseCreateMatDescr(&descr); + status= cusparseCreateMatDescr(&descr); + // CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) { + if (status != CUSPARSE_STATUS_SUCCESS) { + CLEANUP("Matrix descriptor initialization failed"); + return 1; + } + // CHECK: hipsparseSetMatType(descr,HIPSPARSE_MATRIX_TYPE_GENERAL); + cusparseSetMatType(descr,CUSPARSE_MATRIX_TYPE_GENERAL); + // CHECK: hipsparseSetMatIndexBase(descr,HIPSPARSE_INDEX_BASE_ZERO); + cusparseSetMatIndexBase(descr,CUSPARSE_INDEX_BASE_ZERO); + /* exercise conversion routines (convert matrix from COO 2 CSR format) */ + // CHECK: cudaStat1 = hipMalloc((void**)&csrRowPtr,(n+1)*sizeof(csrRowPtr[0])); + cudaStat1 = cudaMalloc((void**)&csrRowPtr,(n+1)*sizeof(csrRowPtr[0])); + // CHECK: if (cudaStat1 != hipSuccess) { + if (cudaStat1 != cudaSuccess) { + CLEANUP("Device malloc failed (csrRowPtr)"); + return 1; + } + status= cusparseXcoo2csr(handle,cooRowIndex,nnz,n, + // CHECK: csrRowPtr,HIPSPARSE_INDEX_BASE_ZERO); + csrRowPtr,CUSPARSE_INDEX_BASE_ZERO); + // CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) { + if (status != CUSPARSE_STATUS_SUCCESS) { + CLEANUP("Conversion from COO to CSR format failed"); + return 1; + } + //csrRowPtr = [0 3 4 7 9] + // The following test only works for compute capability 1.3 and above + // because it needs double precision. + int devId; + // CHECK: hipDeviceProp_t prop; + cudaDeviceProp prop; + // CHECK: hipError_t cudaStat; + cudaError_t cudaStat; + // CHECK: cudaStat = hipGetDevice(&devId); + cudaStat = cudaGetDevice(&devId); + // CHECK: if (hipSuccess != cudaStat){ + if (cudaSuccess != cudaStat){ + // CLEANUP("hipGetDevice failed"); + CLEANUP("cudaGetDevice failed"); + // printf("Error: cudaStat %d, %s\n", cudaStat, hipGetErrorString(cudaStat)); + printf("Error: cudaStat %d, %s\n", cudaStat, cudaGetErrorString(cudaStat)); + return 1; + } + // CHECK: cudaStat = hipGetDeviceProperties( &prop, devId); + cudaStat = cudaGetDeviceProperties( &prop, devId); + // CHECK: if (hipSuccess != cudaStat) { + if (cudaSuccess != cudaStat) { + // CHECK: CLEANUP("hipGetDeviceProperties failed"); + CLEANUP("cudaGetDeviceProperties failed"); + // CHECK: printf("Error: cudaStat %d, %s\n", cudaStat, hipGetErrorString(cudaStat)); + printf("Error: cudaStat %d, %s\n", cudaStat, cudaGetErrorString(cudaStat)); + return 1; + } + int cc = 100*prop.major + 10*prop.minor; + if (cc < 130){ + CLEANUP("waive the test because only sm13 and above are supported\n"); + printf("the device has compute capability %d\n", cc); + printf("example test WAIVED"); + return 2; + } + /* exercise Level 1 routines (scatter vector elements) */ + // TODO: status= hipsparseDsctr(handle, nnz_vector, xVal, xInd, + // CHECK: &y[n], HIPSPARSE_INDEX_BASE_ZERO); + status= cusparseDsctr(handle, nnz_vector, xVal, xInd, + &y[n], CUSPARSE_INDEX_BASE_ZERO); + // CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) { + if (status != CUSPARSE_STATUS_SUCCESS) { + CLEANUP("Scatter from sparse to dense vector failed"); + return 1; + } + //y = [10 20 30 40 | 100 200 70 400] + /* exercise Level 2 routines (csrmv) */ + // CHECK: status= hipsparseDcsrmv(handle,HIPSPARSE_OPERATION_NON_TRANSPOSE, n, n, nnz, + status= cusparseDcsrmv(handle,CUSPARSE_OPERATION_NON_TRANSPOSE, n, n, nnz, + &dtwo, descr, cooVal, csrRowPtr, cooColIndex, + &y[0], &dthree, &y[n]); + // CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) { + if (status != CUSPARSE_STATUS_SUCCESS) { + CLEANUP("Matrix-vector multiplication failed"); + return 1; + } + //y = [10 20 30 40 | 680 760 1230 2240] + // CHECK: hipMemcpy(yHostPtr, y, (size_t)(2*n*sizeof(y[0])), hipMemcpyDeviceToHost); + cudaMemcpy(yHostPtr, y, (size_t)(2*n*sizeof(y[0])), cudaMemcpyDeviceToHost); + /* exercise Level 3 routines (csrmm) */ + // cudaStat1 = hipMalloc((void**)&z, 2*(n+1)*sizeof(z[0])); + cudaStat1 = cudaMalloc((void**)&z, 2*(n+1)*sizeof(z[0])); + // CHECK: if (cudaStat1 != hipSuccess) { + if (cudaStat1 != cudaSuccess) { + CLEANUP("Device malloc failed (z)"); + return 1; + } + // CHECK: cudaStat1 = hipMemset((void *)z,0, 2*(n+1)*sizeof(z[0])); + cudaStat1 = cudaMemset((void *)z,0, 2*(n+1)*sizeof(z[0])); + // CHECK: if (cudaStat1 != hipSuccess) { + if (cudaStat1 != cudaSuccess) { + CLEANUP("Memset on Device failed"); + return 1; + } + // TODO: status= hipsparseDcsrmm(handle, HIPSPARSE_OPERATION_NON_TRANSPOSE, n, 2, n, + status= cusparseDcsrmm(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, n, 2, n, + nnz, &dfive, descr, cooVal, csrRowPtr, cooColIndex, + y, n, &dzero, z, n+1); + // CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) { + if (status != CUSPARSE_STATUS_SUCCESS) { + CLEANUP("Matrix-matrix multiplication failed"); + return 1; + } + /* print final results (z) */ + // CHECK: cudaStat1 = hipMemcpy(zHostPtr, z, + // CHECK: hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(zHostPtr, z, + (size_t)(2*(n+1)*sizeof(z[0])), + cudaMemcpyDeviceToHost); + // CHECK: if (cudaStat1 != hipSuccess) { + if (cudaStat1 != cudaSuccess) { + CLEANUP("Memcpy from Device to Host failed"); + return 1; + } + //z = [950 400 2550 2600 0 | 49300 15200 132300 131200 0] + /* destroy matrix descriptor */ + // status = hipsparseDestroyMatDescr(descr); + status = cusparseDestroyMatDescr(descr); + descr = 0; + // CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) { + if (status != CUSPARSE_STATUS_SUCCESS) { + CLEANUP("Matrix descriptor destruction failed"); + return 1; + } + /* destroy handle */ + // CHECK: status = hipsparseDestroy(handle); + status = cusparseDestroy(handle); + handle = 0; + // CHECK: if (status != HIPSPARSE_STATUS_SUCCESS) { + if (status != CUSPARSE_STATUS_SUCCESS) { + CLEANUP("CUSPARSE Library release of resources failed"); + return 1; + } + /* check the results */ + // Notice that CLEANUP() contains a call to cusparseDestroy(handle) + if ((zHostPtr[0] != 950.0) || + (zHostPtr[1] != 400.0) || + (zHostPtr[2] != 2550.0) || + (zHostPtr[3] != 2600.0) || + (zHostPtr[4] != 0.0) || + (zHostPtr[5] != 49300.0) || + (zHostPtr[6] != 15200.0) || + (zHostPtr[7] != 132300.0) || + (zHostPtr[8] != 131200.0) || + (zHostPtr[9] != 0.0) || + (yHostPtr[0] != 10.0) || + (yHostPtr[1] != 20.0) || + (yHostPtr[2] != 30.0) || + (yHostPtr[3] != 40.0) || + (yHostPtr[4] != 680.0) || + (yHostPtr[5] != 760.0) || + (yHostPtr[6] != 1230.0) || + (yHostPtr[7] != 2240.0)) { + CLEANUP("example test FAILED"); + return 1; + } else { + CLEANUP("example test PASSED"); + return 0; + } +} \ No newline at end of file diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu new file mode 100644 index 0000000000..ab2defefe7 --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu @@ -0,0 +1,284 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +#include +// CHECK: #include +#include +// CHECK: #include +#include +// CHECK: #include "hipsparse.h" +#include "cusparse.h" + +void printMatrix(int m, int n, const double*A, int lda, const char* name) +{ + for(int row = 0 ; row < m ; row++){ + for(int col = 0 ; col < n ; col++){ + double Areg = A[row + col*lda]; + printf("%s(%d,%d) = %f\n", name, row+1, col+1, Areg); + } + } +} + +int main(int argc, char*argv[]) +{ + // CHECK: hipblasHandle_t cublasH = NULL; + cublasHandle_t cublasH = NULL; + // CHECK: hipsparseHandle_t cusparseH = NULL; + cusparseHandle_t cusparseH = NULL; + // CHECK: hipStream_t stream = NULL; + cudaStream_t stream = NULL; + // CHECK: hipsparseMatDescr_t descrA = NULL; + cusparseMatDescr_t descrA = NULL; + // CHECK: hipblasStatus_t cublasStat = HIPBLAS_STATUS_SUCCESS; + cublasStatus_t cublasStat = CUBLAS_STATUS_SUCCESS; + // CHECK: hipsparseStatus_t cusparseStat = HIPSPARSE_STATUS_SUCCESS; + cusparseStatus_t cusparseStat = CUSPARSE_STATUS_SUCCESS; + // CHECK: hipError_t cudaStat1 = hipSuccess; + // CHECK: hipError_t cudaStat2 = hipSuccess; + // CHECK: hipError_t cudaStat3 = hipSuccess; + // CHECK: hipError_t cudaStat4 = hipSuccess; + // CHECK: hipError_t cudaStat5 = hipSuccess; + cudaError_t cudaStat1 = cudaSuccess; + cudaError_t cudaStat2 = cudaSuccess; + cudaError_t cudaStat3 = cudaSuccess; + cudaError_t cudaStat4 = cudaSuccess; + cudaError_t cudaStat5 = cudaSuccess; + const int n = 4; + const int nnzA = 9; +/* + * | 1 0 2 3 | + * | 0 4 0 0 | + * A = | 5 0 6 7 | + * | 0 8 0 9 | + * + * eigevales are { -0.5311, 7.5311, 9.0000, 4.0000 } + * + * The largest eigenvaluse is 9 and corresponding eigenvector is + * + * | 0.3029 | + * v = | 0 | + * | 0.9350 | + * | 0.1844 | + */ + const int csrRowPtrA[n+1] = { 0, 3, 4, 7, 9 }; + const int csrColIndA[nnzA] = {0, 2, 3, 1, 0, 2, 3, 1, 3 }; + const double csrValA[nnzA] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 }; + const double lambda_exact[n] = { 9.0000, 7.5311, 4.0000, -0.5311 }; + const double x0[n] = {1.0, 2.0, 3.0, 4.0 }; /* initial guess */ + double x[n]; /* numerical eigenvector */ + + int *d_csrRowPtrA = NULL; + int *d_csrColIndA = NULL; + double *d_csrValA = NULL; + + double *d_x = NULL; /* eigenvector */ + double *d_y = NULL; /* workspace */ + + const double tol = 1.e-6; + const int max_ites = 30; + + const double h_one = 1.0; + const double h_zero = 0.0; + + printf("example of csrmv_mp \n"); + printf("tol = %E \n", tol); + printf("max. iterations = %d \n", max_ites); + + printf("1st eigenvaluse is %f\n", lambda_exact[0] ); + printf("2nd eigenvaluse is %f\n", lambda_exact[1] ); + + double alpha = lambda_exact[1]/lambda_exact[0] ; + printf("convergence rate is %f\n", alpha ); + + double est_iterations = log(tol)/log(alpha); + printf("# of iterations required is %d\n", (int)ceil(est_iterations)); + + // step 1: create cublas/cusparse handle, bind a stream + // CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); + cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cublasStat = hipblasCreate(&cublasH); + cublasStat = cublasCreate(&cublasH); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + // CHECK: cublasStat = hipblasSetStream(cublasH, stream); + cublasStat = cublasSetStream(cublasH, stream); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + // CHECK: cusparseStat = hipsparseCreate(&cusparseH); + cusparseStat = cusparseCreate(&cusparseH); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == cusparseStat); + assert(CUSPARSE_STATUS_SUCCESS == cusparseStat); + // CHECK: cusparseStat = hipsparseSetStream(cusparseH, stream); + cusparseStat = cusparseSetStream(cusparseH, stream); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == cusparseStat); + assert(CUSPARSE_STATUS_SUCCESS == cusparseStat); + + // step 2: configuration of matrix A + // cusparseStat = hipsparseCreateMatDescr(&descrA); + cusparseStat = cusparseCreateMatDescr(&descrA); + // assert(HIPSPARSE_STATUS_SUCCESS == cusparseStat); + assert(CUSPARSE_STATUS_SUCCESS == cusparseStat); + // CHECK: hipsparseSetMatIndexBase(descrA,HIPSPARSE_INDEX_BASE_ZERO); + cusparseSetMatIndexBase(descrA,CUSPARSE_INDEX_BASE_ZERO); + // CHECK: hipsparseSetMatType(descrA, HIPSPARSE_MATRIX_TYPE_GENERAL ); + cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL ); + + // step 3: copy A and x0 to device + // CHECK: cudaStat1 = hipMalloc ((void**)&d_csrRowPtrA, sizeof(int) * (n+1) ); + cudaStat1 = cudaMalloc ((void**)&d_csrRowPtrA, sizeof(int) * (n+1) ); + // CHECK: cudaStat2 = hipMalloc ((void**)&d_csrColIndA, sizeof(int) * nnzA ); + cudaStat2 = cudaMalloc ((void**)&d_csrColIndA, sizeof(int) * nnzA ); + // CHECK: cudaStat3 = hipMalloc ((void**)&d_csrValA , sizeof(double) * nnzA ); + cudaStat3 = cudaMalloc ((void**)&d_csrValA , sizeof(double) * nnzA ); + // CHECK: cudaStat4 = hipMalloc ((void**)&d_x , sizeof(double) * n ); + cudaStat4 = cudaMalloc ((void**)&d_x , sizeof(double) * n ); + // CHECK: cudaStat5 = hipMalloc ((void**)&d_y , sizeof(double) * n ); + cudaStat5 = cudaMalloc ((void**)&d_y , sizeof(double) * n ); + // CHECK: assert(hipSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + // CHECK: assert(hipSuccess == cudaStat3); + // CHECK: assert(hipSuccess == cudaStat4); + // CHECK: assert(hipSuccess == cudaStat5); + assert(cudaSuccess == cudaStat1); + assert(cudaSuccess == cudaStat2); + assert(cudaSuccess == cudaStat3); + assert(cudaSuccess == cudaStat4); + assert(cudaSuccess == cudaStat5); + + // CHECK: cudaStat1 = hipMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int) * (n+1) , hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int) * (n+1) , cudaMemcpyHostToDevice); + // CHECK: cudaStat2 = hipMemcpy(d_csrColIndA, csrColIndA, sizeof(int) * nnzA , hipMemcpyHostToDevice); + cudaStat2 = cudaMemcpy(d_csrColIndA, csrColIndA, sizeof(int) * nnzA , cudaMemcpyHostToDevice); + // CHECK: cudaStat3 = hipMemcpy(d_csrValA , csrValA , sizeof(double) * nnzA , hipMemcpyHostToDevice); + cudaStat3 = cudaMemcpy(d_csrValA , csrValA , sizeof(double) * nnzA , cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + assert(cudaSuccess == cudaStat2); + // CHECK: assert(hipSuccess == cudaStat3); + assert(cudaSuccess == cudaStat3); + + // step 4: power method + double lambda = 0.0; + double lambda_next = 0.0; + + // 4.1: initial guess x0 + cudaStat1 = cudaMemcpy(d_x, x0, sizeof(double) * n, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + for(int ite = 0 ; ite < max_ites ; ite++ ){ + // 4.2: normalize vector x + // x = x / |x| + double nrm2_x; + // TODO: cublasStat = hipblasDnrm2_v2(cublasH, + cublasStat = cublasDnrm2_v2(cublasH, + n, + d_x, + 1, // incx, + &nrm2_x /* host pointer */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + double one_over_nrm2_x = 1.0 / nrm2_x; + // TODO: cublasStat = hipblasDscal_v2( cublasH, + cublasStat = cublasDscal_v2( cublasH, + n, + &one_over_nrm2_x, /* host pointer */ + d_x, + 1 // incx + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + // 4.3: y = A*x + // TODO: hipsparseStat = cusparseDcsrmv_mp(cusparseH, + // CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE + cusparseStat = cusparseDcsrmv_mp(cusparseH, + CUSPARSE_OPERATION_NON_TRANSPOSE, + n, + n, + nnzA, + &h_one, + descrA, + d_csrValA, + d_csrRowPtrA, + d_csrColIndA, + d_x, + &h_zero, + d_y); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == cusparseStat); + assert(CUSPARSE_STATUS_SUCCESS == cusparseStat); + + // 4.4: lambda = y**T*x + // TODO: cublasStat = hipblasDdot_v2 ( cublasH, + cublasStat = cublasDdot_v2 ( cublasH, + n, + d_x, + 1, // incx, + d_y, + 1, // incy, + &lambda_next /* host pointer */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + double lambda_err = fabs( lambda_next - lambda_exact[0] ); + printf("ite %d: lambda = %f, error = %E\n", ite, lambda_next, lambda_err ); + + // 4.5: check if converges + if ( (ite > 0) && + fabs( lambda - lambda_next ) < tol + ){ + break; // converges + } + + /* + * 4.6: x := y + * lambda = lambda_next + * + * so new approximation is (lambda, x), x is not normalized. + */ + // CHECK: cudaStat1 = hipMemcpy(d_x, d_y, sizeof(double) * n , hipMemcpyDeviceToDevice); + cudaStat1 = cudaMemcpy(d_x, d_y, sizeof(double) * n , cudaMemcpyDeviceToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + lambda = lambda_next; + } + // step 5: report eigen-pair + // CHECK: cudaStat1 = hipMemcpy(x, d_x, sizeof(double) * n, hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(x, d_x, sizeof(double) * n, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + printf("largest eigenvalue is %E\n", lambda ); + printf("eigenvector = (matlab base-1)\n"); + printMatrix(n, 1, x, n, "V0"); + printf("=====\n"); + + // free resources + // CHECK: if (d_csrRowPtrA ) hipFree(d_csrRowPtrA); + if (d_csrRowPtrA ) cudaFree(d_csrRowPtrA); + // CHECK: if (d_csrColIndA ) hipFree(d_csrColIndA); + if (d_csrColIndA ) cudaFree(d_csrColIndA); + // CHECK: if (d_csrValA ) hipFree(d_csrValA); + if (d_csrValA ) cudaFree(d_csrValA); + // CHECK: if (d_x ) hipFree(d_x); + if (d_x ) cudaFree(d_x); + // CHeCK: if (d_y ) hipFree(d_y); + if (d_y ) cudaFree(d_y); + // CHECK: if (cublasH ) hipblasDestroy(cublasH); + if (cublasH ) cublasDestroy(cublasH); + // CHECK: if (cusparseH ) hipsparseDestroy(cusparseH); + if (cusparseH ) cusparseDestroy(cusparseH); + // CHECK: if (stream ) hipStreamDestroy(stream); + if (stream ) cudaStreamDestroy(stream); + // CHECK: if (descrA ) hipsparseDestroyMatDescr(descrA); + if (descrA ) cusparseDestroyMatDescr(descrA); + // CHECK: hipDeviceReset(); + cudaDeviceReset(); + return 0; +} From 9d46966a59fb3efac38349700a7df651f65591dc Mon Sep 17 00:00:00 2001 From: Yaxun Sam Liu Date: Mon, 26 Nov 2018 16:59:40 -0500 Subject: [PATCH 39/55] Let hipcc handle HIP_VDI_HOME without x86_64 --- bin/hipcc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/hipcc b/bin/hipcc index 68e4a96721..0ef3de2969 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -95,15 +95,19 @@ $HIP_VERSION= `$HIP_PATH/bin/hipconfig --version`; ($HIP_VERSION_MAJOR, $HIP_VERSION_MINOR, $HIP_VERSION_PATCH) = split(/\./, $HIP_VERSION); if (defined $HIP_VDI_HOME) { + my $bits = ""; + if (-d "$HIP_VDI_HOME/bin/x86_64") { + $bits = "/x86_64"; + } if (!defined $HIP_CLANG_PATH) { - $HIP_CLANG_PATH = "$HIP_VDI_HOME/bin/x86_64"; + $HIP_CLANG_PATH = "$HIP_VDI_HOME/bin" . $bits; } if (!defined $DEVICE_LIB_PATH) { - $DEVICE_LIB_PATH = "$HIP_VDI_HOME/lib/x86_64/bitcode"; + $DEVICE_LIB_PATH = "$HIP_VDI_HOME/lib" . $bits . "/bitcode"; } $HIP_CLANG_INCLUDE_PATH = "$HIP_VDI_HOME/include/clang"; $HIP_INCLUDE_PATH = "$HIP_VDI_HOME/include"; - $HIP_LIB_PATH = "$HIP_VDI_HOME/lib/x86_64"; + $HIP_LIB_PATH = "$HIP_VDI_HOME/lib" . $bits; } if (defined $HIP_CLANG_PATH) { From 82bbaf0b70730bed25e598807413b04acafbdd04 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 27 Nov 2018 11:57:25 +0300 Subject: [PATCH 40/55] [HIPIFY][SPARSE] Level 3 functions + cuSPARSE_03 test + update CUSPARSE_API_supported_by_HIP.md --- .../markdown/CUSPARSE_API_supported_by_HIP.md | 56 +++++ .../src/CUDA2HIP_SPARSE_API_functions.cpp | 65 +++++ tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu | 4 +- tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu | 2 +- tests/hipify-clang/cuSPARSE/cuSPARSE_03.cu | 229 ++++++++++++++++++ 5 files changed, 353 insertions(+), 3 deletions(-) create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_03.cu diff --git a/docs/markdown/CUSPARSE_API_supported_by_HIP.md b/docs/markdown/CUSPARSE_API_supported_by_HIP.md index d3707573a5..e871de927f 100644 --- a/docs/markdown/CUSPARSE_API_supported_by_HIP.md +++ b/docs/markdown/CUSPARSE_API_supported_by_HIP.md @@ -236,3 +236,59 @@ |`cusparseDhybsv_solve` | | |`cusparseChybsv_solve` | | |`cusparseZhybsv_solve` | | + +## **5.cuSPARSE Level 3 Function Reference** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseScsrmm` |`hipsparseScsrmm` | +|`cusparseDcsrmm` |`hipsparseDcsrmm` | +|`cusparseCcsrmm` | | +|`cusparseZcsrmm` | | +|`cusparseScsrmm2` |`hipsparseScsrmm2` | +|`cusparseDcsrmm2` |`hipsparseDcsrmm2` | +|`cusparseCcsrmm2` | | +|`cusparseZcsrmm2` | | +|`cusparseScsrsm_analysis` | | +|`cusparseDcsrsm_analysis` | | +|`cusparseCcsrsm_analysis` | | +|`cusparseZcsrsm_analysis` | | +|`cusparseScsrsm_solve` | | +|`cusparseDcsrsm_solve` | | +|`cusparseCcsrsm_solve` | | +|`cusparseZcsrsm_solve` | | +|`cusparseScsrsm2_bufferSizeExt` | | +|`cusparseDcsrsm2_bufferSizeExt` | | +|`cusparseCcsrsm2_bufferSizeExt` | | +|`cusparseZcsrsm2_bufferSizeExt` | | +|`cusparseScsrsm2_analysis` | | +|`cusparseDcsrsm2_analysis` | | +|`cusparseCcsrsm2_analysis` | | +|`cusparseZcsrsm2_analysis` | | +|`cusparseScsrsm2_solve` | | +|`cusparseDcsrsm2_solve` | | +|`cusparseCcsrsm2_solve` | | +|`cusparseZcsrsm2_solve` | | +|`cusparseXcsrsm2_zeroPivot` | | +|`cusparseSbsrmm` | | +|`cusparseDbsrmm` | | +|`cusparseCbsrmm` | | +|`cusparseZbsrmm` | | +|`cusparseSbsrsm2_bufferSize` | | +|`cusparseDbsrsm2_bufferSize` | | +|`cusparseCbsrsm2_bufferSize` | | +|`cusparseZbsrsm2_bufferSize` | | +|`cusparseSbsrsm2_analysis` | | +|`cusparseDbsrsm2_analysis` | | +|`cusparseCbsrsm2_analysis` | | +|`cusparseZbsrsm2_analysis` | | +|`cusparseSbsrsm2_solve` | | +|`cusparseDbsrsm2_solve` | | +|`cusparseCbsrsm2_solve` | | +|`cusparseZbsrsm2_solve` | | +|`cusparseXbsrsm2_zeroPivot` | | +|`cusparseSgemmi` | | +|`cusparseDgemmi` | | +|`cusparseCgemmi` | | +|`cusparseZgemmi` | | + diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp index 429c8d0ea2..1ea1365c19 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -174,4 +174,69 @@ const std::map CUDA_SPARSE_FUNCTION_MAP{ {"cusparseDhybsv_solve", {"hipsparseDhybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseChybsv_solve", {"hipsparseChybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseZhybsv_solve", {"hipsparseZhybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + // 8. cuSPARSE Level 3 Function Reference + {"cusparseScsrmm", {"hipsparseScsrmm", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrmm", {"hipsparseDcsrmm", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrmm", {"hipsparseCcsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrmm", {"hipsparseZcsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrmm2", {"hipsparseScsrmm2", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrmm2", {"hipsparseDcsrmm2", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrmm2", {"hipsparseCcsrmm2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrmm2", {"hipsparseZcsrmm2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsm_analysis", {"hipsparseScsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsm_analysis", {"hipsparseDcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsm_analysis", {"hipsparseCcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsm_analysis", {"hipsparseZcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsm_solve", {"hipsparseScsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsm_solve", {"hipsparseDcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsm_solve", {"hipsparseCcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsm_solve", {"hipsparseZcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsm2_bufferSizeExt", {"hipsparseScsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsm2_bufferSizeExt", {"hipsparseDcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsm2_bufferSizeExt", {"hipsparseCcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsm2_bufferSizeExt", {"hipsparseZcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsm2_analysis", {"hipsparseScsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsm2_analysis", {"hipsparseDcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsm2_analysis", {"hipsparseCcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsm2_analysis", {"hipsparseZcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrsm2_solve", {"hipsparseScsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsm2_solve", {"hipsparseDcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsm2_solve", {"hipsparseCcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsm2_solve", {"hipsparseZcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXcsrsm2_zeroPivot", {"hipsparseXcsrsm2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsrmm", {"hipsparseSbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrmm", {"hipsparseDbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrmm", {"hipsparseCbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrmm", {"hipsparseZbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsrsm2_bufferSize", {"hipsparseCbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrsm2_bufferSize", {"hipsparseDbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrsm2_bufferSize", {"hipsparseCbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrsm2_bufferSize", {"hipsparseZbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsrsm2_analysis", {"hipsparseSbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrsm2_analysis", {"hipsparseDbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrsm2_analysis", {"hipsparseCbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrsm2_analysis", {"hipsparseZbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsrsm2_solve", {"hipsparseSbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrsm2_solve", {"hipsparseDbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrsm2_solve", {"hipsparseCbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrsm2_solve", {"hipsparseZbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXbsrsm2_zeroPivot", {"hipsparseXbsrsm2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgemmi", {"hipsparseSgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgemmi", {"hipsparseDgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgemmi", {"hipsparseCgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgemmi", {"hipsparseZgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, }; diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu index 5ef7c188ee..df2499c041 100644 --- a/tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu @@ -261,7 +261,7 @@ int main(){ return 2; } /* exercise Level 1 routines (scatter vector elements) */ - // TODO: status= hipsparseDsctr(handle, nnz_vector, xVal, xInd, + // CHECK: status= hipsparseDsctr(handle, nnz_vector, xVal, xInd, // CHECK: &y[n], HIPSPARSE_INDEX_BASE_ZERO); status= cusparseDsctr(handle, nnz_vector, xVal, xInd, &y[n], CUSPARSE_INDEX_BASE_ZERO); @@ -299,7 +299,7 @@ int main(){ CLEANUP("Memset on Device failed"); return 1; } - // TODO: status= hipsparseDcsrmm(handle, HIPSPARSE_OPERATION_NON_TRANSPOSE, n, 2, n, + // CHECK: status= hipsparseDcsrmm(handle, HIPSPARSE_OPERATION_NON_TRANSPOSE, n, 2, n, status= cusparseDcsrmm(handle, CUSPARSE_OPERATION_NON_TRANSPOSE, n, 2, n, nnz, &dfive, descr, cooVal, csrRowPtr, cooColIndex, y, n, &dzero, z, n+1); diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu index ab2defefe7..de7629367f 100644 --- a/tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu @@ -116,7 +116,7 @@ int main(int argc, char*argv[]) assert(CUSPARSE_STATUS_SUCCESS == cusparseStat); // step 2: configuration of matrix A - // cusparseStat = hipsparseCreateMatDescr(&descrA); + // CHECK: cusparseStat = hipsparseCreateMatDescr(&descrA); cusparseStat = cusparseCreateMatDescr(&descrA); // assert(HIPSPARSE_STATUS_SUCCESS == cusparseStat); assert(CUSPARSE_STATUS_SUCCESS == cusparseStat); diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_03.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_03.cu new file mode 100644 index 0000000000..ef52072576 --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_03.cu @@ -0,0 +1,229 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +#include +// CHECK: #include +#include +// CHECK: #include "hipsparse.h" +#include "cusparse.h" + +int main(int argc, char*argv[]) +{ + // CHECK: hipsparseHandle_t handle = NULL; + cusparseHandle_t handle = NULL; + // CHECK: hipStream_t stream = NULL; + cudaStream_t stream = NULL; + // CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS; + cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS; + // CHECK: hipError_t cudaStat1 = hipSuccess; + // CHECK: hipError_t cudaStat2 = hipSuccess; + // CHECK: hipError_t cudaStat3 = hipSuccess; + // CHECK: hipError_t cudaStat4 = hipSuccess; + // CHECK: hipError_t cudaStat5 = hipSuccess; + // CHECK: hipError_t cudaStat6 = hipSuccess; + cudaError_t cudaStat1 = cudaSuccess; + cudaError_t cudaStat2 = cudaSuccess; + cudaError_t cudaStat3 = cudaSuccess; + cudaError_t cudaStat4 = cudaSuccess; + cudaError_t cudaStat5 = cudaSuccess; + cudaError_t cudaStat6 = cudaSuccess; + + /* + * A is a 3x3 sparse matrix + * | 1 2 0 | + * A = | 0 5 0 | + * | 0 8 0 | + */ + const int m = 3; + const int n = 3; + const int nnz = 4; + +#if 0 + /* index starts at 0 */ + int h_cooRows[nnz] = { 2, 1, 0, 0 }; + int h_cooCols[nnz] = { 1, 1, 0, 1 }; +#else + /* index starts at -2 */ + int h_cooRows[nnz] = { 0, -1, -2, -2 }; + int h_cooCols[nnz] = { -1, -1, -2, -1 }; +#endif + double h_cooVals[nnz] = { 8.0, 5.0, 1.0, 2.0 }; + int h_P[nnz]; + + int *d_cooRows = NULL; + int *d_cooCols = NULL; + int *d_P = NULL; + double *d_cooVals = NULL; + double *d_cooVals_sorted = NULL; + size_t pBufferSizeInBytes = 0; + void *pBuffer = NULL; + + printf("m = %d, n = %d, nnz=%d \n", m, n, nnz); + + /* step 1: create cusparse handle, bind a stream */ + // CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); + cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: status = hipsparseCreate(&handle); + status = cusparseCreate(&handle); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: status = hipsparseSetStream(handle, stream); + status = cusparseSetStream(handle, stream); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + /* step 2: allocate buffer */ + // TODO: status = hipsparseXcoosort_bufferSizeExt( + status = cusparseXcoosort_bufferSizeExt( + handle, + m, + n, + nnz, + d_cooRows, + d_cooCols, + &pBufferSizeInBytes + ); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + printf("pBufferSizeInBytes = %lld bytes \n", (long long)pBufferSizeInBytes); + + // CHECK: cudaStat1 = hipMalloc(&d_cooRows, sizeof(int)*nnz); + cudaStat1 = cudaMalloc(&d_cooRows, sizeof(int)*nnz); + // CHECK: cudaStat2 = hipMalloc(&d_cooCols, sizeof(int)*nnz); + cudaStat2 = cudaMalloc(&d_cooCols, sizeof(int)*nnz); + // CHECK: cudaStat3 = hipMalloc(&d_P, sizeof(int)*nnz); + cudaStat3 = cudaMalloc(&d_P, sizeof(int)*nnz); + // CHECK: cudaStat4 = hipMalloc(&d_cooVals, sizeof(double)*nnz); + cudaStat4 = cudaMalloc(&d_cooVals, sizeof(double)*nnz); + // CHECK: cudaStat5 = hipMalloc(&d_cooVals_sorted, sizeof(double)*nnz); + cudaStat5 = cudaMalloc(&d_cooVals_sorted, sizeof(double)*nnz); + // CHECK: cudaStat6 = hipMalloc(&pBuffer, sizeof(char)* pBufferSizeInBytes); + cudaStat6 = cudaMalloc(&pBuffer, sizeof(char)* pBufferSizeInBytes); + + // CHECK: assert(hipSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + // CHECK: assert(hipSuccess == cudaStat3); + // CHECK: assert(hipSuccess == cudaStat4); + // CHECK: assert(hipSuccess == cudaStat5); + // CHECK: assert(hipSuccess == cudaStat6); + assert(cudaSuccess == cudaStat1); + assert(cudaSuccess == cudaStat2); + assert(cudaSuccess == cudaStat3); + assert(cudaSuccess == cudaStat4); + assert(cudaSuccess == cudaStat5); + assert(cudaSuccess == cudaStat6); + + // CHECK: cudaStat1 = hipMemcpy(d_cooRows, h_cooRows, sizeof(int)*nnz, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_cooRows, h_cooRows, sizeof(int)*nnz, cudaMemcpyHostToDevice); + // CHECK: cudaStat2 = hipMemcpy(d_cooCols, h_cooCols, sizeof(int)*nnz, hipMemcpyHostToDevice); + cudaStat2 = cudaMemcpy(d_cooCols, h_cooCols, sizeof(int)*nnz, cudaMemcpyHostToDevice); + // CHECK: cudaStat3 = hipMemcpy(d_cooVals, h_cooVals, sizeof(double)*nnz, hipMemcpyHostToDevice); + cudaStat3 = cudaMemcpy(d_cooVals, h_cooVals, sizeof(double)*nnz, cudaMemcpyHostToDevice); + // CHECK: cudaStat4 = hipDeviceSynchronize(); + cudaStat4 = cudaDeviceSynchronize(); + + // CHECK: assert(hipSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + // CHECK: assert(hipSuccess == cudaStat3); + // CHECK: assert(hipSuccess == cudaStat4); + assert(cudaSuccess == cudaStat1); + assert(cudaSuccess == cudaStat2); + assert(cudaSuccess == cudaStat3); + assert(cudaSuccess == cudaStat4); + + /* step 3: setup permutation vector P to identity */ + // TODO: status = hipsparseCreateIdentityPermutation( + status = cusparseCreateIdentityPermutation( + handle, + nnz, + d_P); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + /* step 4: sort COO format by Row */ + // TODO: status = hipsparseXcoosortByRow( + status = cusparseXcoosortByRow( + handle, + m, + n, + nnz, + d_cooRows, + d_cooCols, + d_P, + pBuffer + ); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + /* step 5: gather sorted cooVals */ + // CHECK: status = hipsparseDgthr( + // CHECK: HIPSPARSE_INDEX_BASE_ZERO + status = cusparseDgthr( + handle, + nnz, + d_cooVals, + d_cooVals_sorted, + d_P, + CUSPARSE_INDEX_BASE_ZERO + ); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + /* wait until the computation is done */ + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: cudaStat2 = hipMemcpy(h_cooRows, d_cooRows, sizeof(int)*nnz, hipMemcpyDeviceToHost); + cudaStat2 = cudaMemcpy(h_cooRows, d_cooRows, sizeof(int)*nnz, cudaMemcpyDeviceToHost); + // CHECK: cudaStat3 = hipMemcpy(h_cooCols, d_cooCols, sizeof(int)*nnz, hipMemcpyDeviceToHost); + cudaStat3 = cudaMemcpy(h_cooCols, d_cooCols, sizeof(int)*nnz, cudaMemcpyDeviceToHost); + // CHECK: cudaStat4 = hipMemcpy(h_P, d_P, sizeof(int)*nnz, hipMemcpyDeviceToHost); + cudaStat4 = cudaMemcpy(h_P, d_P, sizeof(int)*nnz, cudaMemcpyDeviceToHost); + // CHECK: cudaStat5 = hipMemcpy(h_cooVals, d_cooVals_sorted, sizeof(double)*nnz, hipMemcpyDeviceToHost); + cudaStat5 = cudaMemcpy(h_cooVals, d_cooVals_sorted, sizeof(double)*nnz, cudaMemcpyDeviceToHost); + // CHECK: cudaStat6 = hipDeviceSynchronize(); + cudaStat6 = cudaDeviceSynchronize(); + // CHECK: assert(hipSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + // CHECK: assert(hipSuccess == cudaStat3); + // CHECK: assert(hipSuccess == cudaStat4); + // CHECK: assert(hipSuccess == cudaStat5); + // CHECK: assert(hipSuccess == cudaStat6); + assert(cudaSuccess == cudaStat1); + assert(cudaSuccess == cudaStat2); + assert(cudaSuccess == cudaStat3); + assert(cudaSuccess == cudaStat4); + assert(cudaSuccess == cudaStat5); + assert(cudaSuccess == cudaStat6); + + printf("sorted coo: \n"); + for (int j = 0; j < nnz; j++) { + printf("(%d, %d, %f) \n", h_cooRows[j], h_cooCols[j], h_cooVals[j]); + } + + for (int j = 0; j < nnz; j++) { + printf("P[%d] = %d \n", j, h_P[j]); + } + + /* free resources */ + // CHECK: if (d_cooRows) hipFree(d_cooRows); + if (d_cooRows) cudaFree(d_cooRows); + // CHECK: if (d_cooCols) hipFree(d_cooCols); + if (d_cooCols) cudaFree(d_cooCols); + // CHECK: if (d_P) hipFree(d_P); + if (d_P) cudaFree(d_P); + // CHECK: if (d_cooVals) hipFree(d_cooVals); + if (d_cooVals) cudaFree(d_cooVals); + // CHECK: if (d_cooVals_sorted) hipFree(d_cooVals_sorted); + if (d_cooVals_sorted) cudaFree(d_cooVals_sorted); + // CHECK: if (pBuffer) hipFree(pBuffer); + if (pBuffer) cudaFree(pBuffer); + // if (handle) hipsparseDestroy(handle); + if (handle) cusparseDestroy(handle); + // CHECK: if (stream) hipStreamDestroy(stream); + if (stream) cudaStreamDestroy(stream); + // CHECK: hipDeviceReset(); + cudaDeviceReset(); + return 0; +} From 11fedfbff6d02b8260b9189216cbc0613355201a Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 27 Nov 2018 12:41:50 +0300 Subject: [PATCH 41/55] [HIPIFY][SPARSE] Extra functions + cuSPARSE_04 test + update CUSPARSE_API_supported_by_HIP.md --- .../markdown/CUSPARSE_API_supported_by_HIP.md | 30 +- .../src/CUDA2HIP_SPARSE_API_functions.cpp | 21 ++ tests/hipify-clang/cuSPARSE/cuSPARSE_04.cu | 261 ++++++++++++++++++ 3 files changed, 307 insertions(+), 5 deletions(-) create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_04.cu diff --git a/docs/markdown/CUSPARSE_API_supported_by_HIP.md b/docs/markdown/CUSPARSE_API_supported_by_HIP.md index e871de927f..be82f35310 100644 --- a/docs/markdown/CUSPARSE_API_supported_by_HIP.md +++ b/docs/markdown/CUSPARSE_API_supported_by_HIP.md @@ -1,6 +1,6 @@ # CUSPARSE API supported by HIP -## **1. CUSPARSE Data types** +## **1. cuSPARSE Data types** | **type** | **CUDA** | **HIP** | |-------------:|---------------------------------------------------------------|------------------------------------------------------------| @@ -83,7 +83,7 @@ | struct |`pruneInfo` | | | typedef |`pruneInfo_t` | | -## **2.cuSPARSE Helper Function Reference** +## **2. cuSPARSE Helper Function Reference** | **CUDA** | **HIP** | |-----------------------------------------------------------|-------------------------------------------------| @@ -129,7 +129,7 @@ |`cusparseCreatePruneInfo` | | |`cusparseDestroyPruneInfo` | | -## **3.cuSPARSE Level 1 Function Reference** +## **3. cuSPARSE Level 1 Function Reference** | **CUDA** | **HIP** | |-----------------------------------------------------------|-------------------------------------------------| @@ -158,7 +158,7 @@ |`cusparseCsctr` | | |`cusparseZsctr` | | -## **4.cuSPARSE Level 2 Function Reference** +## **4. cuSPARSE Level 2 Function Reference** | **CUDA** | **HIP** | |-----------------------------------------------------------|-------------------------------------------------| @@ -237,7 +237,7 @@ |`cusparseChybsv_solve` | | |`cusparseZhybsv_solve` | | -## **5.cuSPARSE Level 3 Function Reference** +## **5. cuSPARSE Level 3 Function Reference** | **CUDA** | **HIP** | |-----------------------------------------------------------|-------------------------------------------------| @@ -292,3 +292,23 @@ |`cusparseCgemmi` | | |`cusparseZgemmi` | | +## **6. cuSPARSE Extra Function Reference** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseXcsrgeamNnz` | | +|`cusparseScsrgeam` | | +|`cusparseDcsrgeam` | | +|`cusparseCcsrgeam` | | +|`cusparseScsrgeam2_bufferSizeExt` | | +|`cusparseDcsrgeam2_bufferSizeExt` | | +|`cusparseCcsrgeam2_bufferSizeExt` | | +|`cusparseZcsrgeam2_bufferSizeExt` | | +|`cusparseXcsrgemmNnz` | | +|`cusparseScsrgemm` | | +|`cusparseDcsrgemm` | | +|`cusparseCcsrgemm` | | +|`cusparseScsrgemm2_bufferSizeExt` | | +|`cusparseDcsrgemm2_bufferSizeExt` | | +|`cusparseCcsrgemm2_bufferSizeExt` | | +|`cusparseZcsrgemm2_bufferSizeExt` | | diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp index 1ea1365c19..ed46fc5a54 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -239,4 +239,25 @@ const std::map CUDA_SPARSE_FUNCTION_MAP{ {"cusparseDgemmi", {"hipsparseDgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseCgemmi", {"hipsparseCgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseZgemmi", {"hipsparseZgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + // 9. cuSPARSE Extra Function Reference + {"cusparseXcsrgeamNnz", {"hipsparseXcsrgeamNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrgeam", {"hipsparseScsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrgeam", {"hipsparseDcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrgeam", {"hipsparseCcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrgeam2_bufferSizeExt", {"hipsparseScsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrgeam2_bufferSizeExt", {"hipsparseDcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrgeam2_bufferSizeExt", {"hipsparseCcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrgeam2_bufferSizeExt", {"hipsparseZcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXcsrgemmNnz", {"hipsparseXcsrgemmNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrgemm", {"hipsparseScsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrgemm", {"hipsparseDcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrgemm", {"hipsparseCcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrgemm2_bufferSizeExt", {"hipsparseScsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrgemm2_bufferSizeExt", {"hipsparseDcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrgemm2_bufferSizeExt", {"hipsparseCcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrgemm2_bufferSizeExt", {"hipsparseZcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, }; diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_04.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_04.cu new file mode 100644 index 0000000000..32760f4fa7 --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_04.cu @@ -0,0 +1,261 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +#include +// CHECK: #include +#include +// CHECK: #include +#include + +void printMatrix(int m, int n, const float*A, int lda, const char* name) +{ + for (int row = 0; row < m; row++) { + for (int col = 0; col < n; col++) { + float Areg = A[row + col * lda]; + printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg); + } + } +} + +void printCsr( + int m, + int n, + int nnz, + // CHECK: const hipsparseMatDescr_t descrA, + const cusparseMatDescr_t descrA, + const float *csrValA, + const int *csrRowPtrA, + const int *csrColIndA, + const char* name) +{ + // CHECK: const int base = (hipsparseGetMatIndexBase(descrA) != HIPSPARSE_INDEX_BASE_ONE) ? 0 : 1; + const int base = (cusparseGetMatIndexBase(descrA) != CUSPARSE_INDEX_BASE_ONE) ? 0 : 1; + + printf("matrix %s is %d-by-%d, nnz=%d, base=%d\n", name, m, n, nnz, base); + for (int row = 0; row < m; row++) { + const int start = csrRowPtrA[row] - base; + const int end = csrRowPtrA[row + 1] - base; + for (int colidx = start; colidx < end; colidx++) { + const int col = csrColIndA[colidx] - base; + const float Areg = csrValA[colidx]; + printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg); + } + } +} + +int main(int argc, char*argv[]) +{ + // CHECK: hipsparseHandle_t handle = NULL; + cusparseHandle_t handle = NULL; + // CHECK: hipStream_t stream = NULL; + cudaStream_t stream = NULL; + // CHECK: hipsparseMatDescr_t descrC = NULL; + cusparseMatDescr_t descrC = NULL; + // CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS; + cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS; + // CHECK: hipError_t cudaStat1 = hipSuccess; + // CHECK: hipError_t cudaStat2 = hipSuccess; + // CHECK: hipError_t cudaStat3 = hipSuccess; + // CHECK: hipError_t cudaStat4 = hipSuccess; + // CHECK: hipError_t cudaStat5 = hipSuccess; + cudaError_t cudaStat1 = cudaSuccess; + cudaError_t cudaStat2 = cudaSuccess; + cudaError_t cudaStat3 = cudaSuccess; + cudaError_t cudaStat4 = cudaSuccess; + cudaError_t cudaStat5 = cudaSuccess; + const int m = 4; + const int n = 4; + const int lda = m; + /* + * | 1 0 2 -3 | + * | 0 4 0 0 | + * A = | 5 0 6 7 | + * | 0 8 0 9 | + * + */ + const float A[lda*n] = { 1, 0, 5, 0, 0, 4, 0, 8, 2, 0, 6, 0, -3, 0, 7, 9 }; + int* csrRowPtrC = NULL; + int* csrColIndC = NULL; + float* csrValC = NULL; + + float *d_A = NULL; + int *d_csrRowPtrC = NULL; + int *d_csrColIndC = NULL; + float *d_csrValC = NULL; + + size_t lworkInBytes = 0; + char *d_work = NULL; + + int nnzC = 0; + + float threshold = 4.1; /* remove Aij <= 4.1 */ +// float threshold = 0; /* remove zeros */ + + printf("example of pruneDense2csr \n"); + + printf("prune |A(i,j)| <= threshold \n"); + printf("threshold = %E \n", threshold); + + printMatrix(m, n, A, lda, "A"); + + /* step 1: create cusparse handle, bind a stream */ + // CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); + cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: status = hipsparseCreate(&handle); + status = cusparseCreate(&handle); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: status = hipsparseSetStream(handle, stream); + status = cusparseSetStream(handle, stream); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + /* step 2: configuration of matrix C */ + // CHECK: status = hipsparseCreateMatDescr(&descrC); + status = cusparseCreateMatDescr(&descrC); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: hipsparseSetMatIndexBase(descrC, HIPSPARSE_INDEX_BASE_ZERO); + cusparseSetMatIndexBase(descrC, CUSPARSE_INDEX_BASE_ZERO); + // CHECK: hipsparseSetMatType(descrC, HIPSPARSE_MATRIX_TYPE_GENERAL); + cusparseSetMatType(descrC, CUSPARSE_MATRIX_TYPE_GENERAL); + // CHECK: cudaStat1 = hipMalloc((void**)&d_A, sizeof(float)*lda*n); + cudaStat1 = cudaMalloc((void**)&d_A, sizeof(float)*lda*n); + // CHECK: cudaStat2 = hipMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1)); + cudaStat2 = cudaMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1)); + // CHECK: assert(hipSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + assert(cudaSuccess == cudaStat1); + assert(cudaSuccess == cudaStat2); + + /* step 3: query workspace */ + // CHECK: cudaStat1 = hipMemcpy(d_A, A, sizeof(float)*lda*n, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_A, A, sizeof(float)*lda*n, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // TODO: status = hipsparseSpruneDense2csr_bufferSizeExt( + status = cusparseSpruneDense2csr_bufferSizeExt( + handle, + m, + n, + d_A, + lda, + &threshold, + descrC, + d_csrValC, + d_csrRowPtrC, + d_csrColIndC, + &lworkInBytes); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + printf("lworkInBytes (prune) = %lld \n", (long long)lworkInBytes); + // CHECK: if (NULL != d_work) { hipFree(d_work); } + if (NULL != d_work) { cudaFree(d_work); } + // CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes); + cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 4: compute csrRowPtrC and nnzC */ + // TODO: status = hipsparseSpruneDense2csrNnz( + status = cusparseSpruneDense2csrNnz( + handle, + m, + n, + d_A, + lda, + &threshold, + descrC, + d_csrRowPtrC, + &nnzC, /* host */ + d_work); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + printf("nnzC = %d\n", nnzC); + if (0 == nnzC) { + printf("C is empty \n"); + return 0; + } + + /* step 5: compute csrColIndC and csrValC */ + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC); + cudaStat1 = cudaMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC); + // CHECK: cudaStat2 = hipMalloc((void**)&d_csrValC, sizeof(float) * nnzC); + cudaStat2 = cudaMalloc((void**)&d_csrValC, sizeof(float) * nnzC); + // CHECK: assert(hipSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + assert(cudaSuccess == cudaStat1); + assert(cudaSuccess == cudaStat2); + // TODO: status = hipsparseSpruneDense2csr( + status = cusparseSpruneDense2csr( + handle, + m, + n, + d_A, + lda, + &threshold, + descrC, + d_csrValC, + d_csrRowPtrC, + d_csrColIndC, + d_work); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 6: output C */ + csrRowPtrC = (int*)malloc(sizeof(int)*(m + 1)); + csrColIndC = (int*)malloc(sizeof(int)*nnzC); + csrValC = (float*)malloc(sizeof(float)*nnzC); + assert(NULL != csrRowPtrC); + assert(NULL != csrColIndC); + assert(NULL != csrValC); + // CHECK: cudaStat1 = hipMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), cudaMemcpyDeviceToHost); + // CHECK: cudaStat2 = hipMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, hipMemcpyDeviceToHost); + cudaStat2 = cudaMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, cudaMemcpyDeviceToHost); + // CHECK: cudaStat3 = hipMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, hipMemcpyDeviceToHost); + cudaStat3 = cudaMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + // CHECK: assert(hipSuccess == cudaStat3); + assert(cudaSuccess == cudaStat1); + assert(cudaSuccess == cudaStat2); + assert(cudaSuccess == cudaStat3); + + printCsr(m, n, nnzC, descrC, csrValC, csrRowPtrC, csrColIndC, "C"); + + /* free resources */ + // CHECK: if (d_A) hipFree(d_A); + if (d_A) cudaFree(d_A); + // CHECK: if (d_csrRowPtrC) hipFree(d_csrRowPtrC); + if (d_csrRowPtrC) cudaFree(d_csrRowPtrC); + // CHECK: if (d_csrColIndC) hipFree(d_csrColIndC); + if (d_csrColIndC) cudaFree(d_csrColIndC); + // CHECK: if (d_csrValC) hipFree(d_csrValC); + if (d_csrValC) cudaFree(d_csrValC); + + if (csrRowPtrC) free(csrRowPtrC); + if (csrColIndC) free(csrColIndC); + if (csrValC) free(csrValC); + // CHECK: if (handle) hipsparseDestroy(handle); + if (handle) cusparseDestroy(handle); + // CHECK: if (stream) hipStreamDestroy(stream); + if (stream) cudaStreamDestroy(stream); + // CHECK: if (descrC) hipsparseDestroyMatDescr(descrC); + if (descrC) cusparseDestroyMatDescr(descrC); + // CHECK: hipDeviceReset(); + cudaDeviceReset(); + return 0; +} From 450f093231efeaf712a48514aeb27cb500b163b9 Mon Sep 17 00:00:00 2001 From: Yaxun Sam Liu Date: Tue, 13 Nov 2018 22:28:00 -0500 Subject: [PATCH 42/55] Let hip-clang support --genco --- CMakeLists.txt | 1 + bin/hipcc | 6 ++- src/hip_clang.cpp | 39 ++------------------ src/hip_fatbin.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++ src/hip_fatbin.h | 58 +++++++++++++++++++++++++++++ src/hip_module.cpp | 7 ++++ 6 files changed, 165 insertions(+), 37 deletions(-) create mode 100644 src/hip_fatbin.cpp create mode 100644 src/hip_fatbin.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 45d7640643..7730950ad5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,6 +213,7 @@ if(HIP_PLATFORM STREQUAL "hcc") src/hip_device.cpp src/hip_error.cpp src/hip_event.cpp + src/hip_fatbin.cpp src/hip_memory.cpp src/hip_peer.cpp src/hip_stream.cpp diff --git a/bin/hipcc b/bin/hipcc index 68e4a96721..50e9004acf 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -334,7 +334,7 @@ foreach $arg (@ARGV) $trimarg = $arg; $trimarg =~ s/^\s+|\s+$//g; # Remive whitespace my $swallowArg = 0; - if ($arg eq '-c') { + if ($arg eq '-c' or $arg eq '--genco') { $compileOnly = 1; $needCXXFLAGS = 1; $needLDFLAGS = 0; @@ -386,6 +386,10 @@ foreach $arg (@ARGV) $swallowArg = 1; } + if (($arg =~ /--genco/) and $HIP_PLATFORM eq 'clang' ) { + $arg = "--cuda-device-only"; + } + if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) { $HIPCXXFLAGS .= $HCC_WA_FLAGS; diff --git a/src/hip_clang.cpp b/src/hip_clang.cpp index fe08bbe45c..ef8d456103 100644 --- a/src/hip_clang.cpp +++ b/src/hip_clang.cpp @@ -26,34 +26,9 @@ THE SOFTWARE. #include "hip/hip_runtime.h" #include "hip_hcc_internal.h" +#include "hip_fatbin.h" #include "trace_helper.h" -constexpr unsigned __hipFatMAGIC2 = 0x48495046; // "HIPF" - -#define CLANG_OFFLOAD_BUNDLER_MAGIC "__CLANG_OFFLOAD_BUNDLE__" -#define AMDGCN_AMDHSA_TRIPLE "hip-amdgcn-amd-amdhsa" - -struct __ClangOffloadBundleDesc { - uint64_t offset; - uint64_t size; - uint64_t tripleSize; - const char triple[1]; -}; - -struct __ClangOffloadBundleHeader { - const char magic[sizeof(CLANG_OFFLOAD_BUNDLER_MAGIC) - 1]; - uint64_t numBundles; - __ClangOffloadBundleDesc desc[1]; -}; - -struct __CudaFatBinaryWrapper { - unsigned int magic; - unsigned int version; - __ClangOffloadBundleHeader* binary; - void* unused; -}; - - extern "C" std::vector* __hipRegisterFatBinary(const void* data) { @@ -108,21 +83,13 @@ __hipRegisterFatBinary(const void* data) std::string image{reinterpret_cast( reinterpret_cast(header) + desc->offset), desc->size}; + if (HIP_DUMP_CODE_OBJECT) + __hipDumpCodeObject(image); module->executable = hip_impl::load_executable(image, module->executable, agent); if (module->executable.handle) { modules->at(deviceId) = module; tprintf(DB_FB, "Loaded code object for %s\n", name); - if (HIP_DUMP_CODE_OBJECT) { - char fname[30]; - static std::atomic index; - sprintf(fname, "__hip_dump_code_object%04d.o", index++); - tprintf(DB_FB, "Dump code object %s\n", fname); - std::ofstream ofs; - ofs.open(fname, std::ios::binary); - ofs << image; - ofs.close(); - } } else { fprintf(stderr, "Failed to load code object for %s\n", name); abort(); diff --git a/src/hip_fatbin.cpp b/src/hip_fatbin.cpp new file mode 100644 index 0000000000..8fe7740ed7 --- /dev/null +++ b/src/hip_fatbin.cpp @@ -0,0 +1,91 @@ +/* +Copyright (c) 2018 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +#include +#include + +#include "hip_fatbin.h" +#include "hip/hip_runtime.h" +#include "hip_hcc_internal.h" +#include "trace_helper.h" + +void __hipDumpCodeObject(const std::string& image) { + char fname[30]; + static std::atomic index; + sprintf(fname, "__hip_dump_code_object%04d.o", index++); + tprintf(DB_FB, "Dump code object %s\n", fname); + std::ofstream ofs; + ofs.open(fname, std::ios::binary); + ofs << image; + ofs.close(); +} + +// Returns a pointer to the code object in the fatbin. The pointer should not +// be freed. +const void* __hipExtractCodeObjectFromFatBinary(const void* data, + const char* agent_name) +{ + HIP_INIT(); + + tprintf(DB_FB, "Enter __hipExtractCodeObjectFromFatBinary(%p, \"%s\")\n", + data, agent_name); + + const __ClangOffloadBundleHeader* header + = reinterpret_cast(data); + std::string magic(reinterpret_cast(header), + sizeof(CLANG_OFFLOAD_BUNDLER_MAGIC) - 1); + if (magic.compare(CLANG_OFFLOAD_BUNDLER_MAGIC)) { + return nullptr; + } + + const __ClangOffloadBundleDesc* desc = &header->desc[0]; + for (uint64_t i = 0; i < header->numBundles; ++i, + desc = reinterpret_cast( + reinterpret_cast(&desc->triple[0]) + desc->tripleSize)) { + + std::string triple{&desc->triple[0], sizeof(AMDGCN_AMDHSA_TRIPLE) - 1}; + if (triple.compare(AMDGCN_AMDHSA_TRIPLE)) + continue; + + std::string target{&desc->triple[sizeof(AMDGCN_AMDHSA_TRIPLE)], + desc->tripleSize - sizeof(AMDGCN_AMDHSA_TRIPLE)}; + tprintf(DB_FB, "Found hip-clang bundle for %s\n", target.c_str()); + if (target.compare(agent_name)) { + continue; + } + + auto *codeobj = reinterpret_cast( + reinterpret_cast(header) + desc->offset); + if (HIP_DUMP_CODE_OBJECT) + __hipDumpCodeObject(std::string{codeobj, desc->size}); + + tprintf(DB_FB, "__hipExtractCodeObjectFromFatBinary succeeds and returns %p\n", + codeobj); + return codeobj; + } + + // hipcc --genco for HCC generates fat binaries with different triple strings. + // It will reach here and return a null pointer. The fat binary itself will + // be handled in a different place. + tprintf(DB_FB, "No hip-clang device code bundle for %s\n", agent_name); + return nullptr; +} + diff --git a/src/hip_fatbin.h b/src/hip_fatbin.h new file mode 100644 index 0000000000..7b4a063c68 --- /dev/null +++ b/src/hip_fatbin.h @@ -0,0 +1,58 @@ +/* +Copyright (c) 2018 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +#ifndef HIP_SRC_HIP_FATBIN_H +#define HIP_SRC_HIP_FATBIN_H + +#include "hip/hip_runtime.h" +#include "hip_hcc_internal.h" + +// hip-clang fatbin format +constexpr unsigned __hipFatMAGIC2 = 0x48495046; // "HIPF" + +#define CLANG_OFFLOAD_BUNDLER_MAGIC "__CLANG_OFFLOAD_BUNDLE__" +#define AMDGCN_AMDHSA_TRIPLE "hip-amdgcn-amd-amdhsa" + +struct __ClangOffloadBundleDesc { + uint64_t offset; + uint64_t size; + uint64_t tripleSize; + const char triple[1]; +}; + +struct __ClangOffloadBundleHeader { + const char magic[sizeof(CLANG_OFFLOAD_BUNDLER_MAGIC) - 1]; + uint64_t numBundles; + __ClangOffloadBundleDesc desc[1]; +}; + +struct __CudaFatBinaryWrapper { + unsigned int magic; + unsigned int version; + __ClangOffloadBundleHeader* binary; + void* unused; +}; + +const void* __hipExtractCodeObjectFromFatBinary(const void* data, + const char* agent_name); +void __hipDumpCodeObject(const std::string& image); + +#endif // HIP_SRC_HIP_FATBIN_H diff --git a/src/hip_module.cpp b/src/hip_module.cpp index 2f1e4ee322..657fb06b5e 100644 --- a/src/hip_module.cpp +++ b/src/hip_module.cpp @@ -48,6 +48,7 @@ THE SOFTWARE. #include #include #include "../include/hip/hcc_detail/code_object_bundle.hpp" +#include "hip_fatbin.h" // TODO Use Pool APIs from HCC to get memory regions. using namespace ELFIO; @@ -556,6 +557,12 @@ hipError_t ihipModuleLoadData(hipModule_t* module, const void* image) { auto ctx = ihipGetTlsDefaultCtx(); if (!ctx) return hipErrorInvalidContext; + // try extracting code object from image as fatbin. + char name[64] = {}; + hsa_agent_get_info(this_agent(), HSA_AGENT_INFO_NAME, name); + if (auto *code_obj = __hipExtractCodeObjectFromFatBinary(image, name)) + image = code_obj; + hsa_executable_create_alt(HSA_PROFILE_FULL, HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT, nullptr, &(*module)->executable); From b39bd8c9a9c17026720dbbc41b291d48e0b578ca Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 28 Nov 2018 20:10:30 +0300 Subject: [PATCH 43/55] [HIPIFY][SPARSE] Preconditioners Reference: Incomplete Cholesky Factorization: level 0 + cuSPARSE_05 test + update CUSPARSE_API_supported_by_HIP.md --- .../markdown/CUSPARSE_API_supported_by_HIP.md | 37 +++ .../src/CUDA2HIP_SPARSE_API_functions.cpp | 36 +++ tests/hipify-clang/cuSPARSE/cuSPARSE_05.cu | 288 ++++++++++++++++++ 3 files changed, 361 insertions(+) create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_05.cu diff --git a/docs/markdown/CUSPARSE_API_supported_by_HIP.md b/docs/markdown/CUSPARSE_API_supported_by_HIP.md index be82f35310..c0f62f9f9d 100644 --- a/docs/markdown/CUSPARSE_API_supported_by_HIP.md +++ b/docs/markdown/CUSPARSE_API_supported_by_HIP.md @@ -312,3 +312,40 @@ |`cusparseDcsrgemm2_bufferSizeExt` | | |`cusparseCcsrgemm2_bufferSizeExt` | | |`cusparseZcsrgemm2_bufferSizeExt` | | + +## **7. cuSPARSE Preconditioners Reference** + +## ***7.1. Incomplete Cholesky Factorization: level 0*** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseScsric0` | | +|`cusparseDcsric0` | | +|`cusparseCcsric0` | | +|`cusparseZcsric0` | | +|`cusparseScsric02_bufferSize` | | +|`cusparseDcsric02_bufferSize` | | +|`cusparseCcsric02_bufferSize` | | +|`cusparseZcsric02_bufferSize` | | +|`cusparseScsric02_analysis` | | +|`cusparseDcsric02_analysis` | | +|`cusparseCcsric02_analysis` | | +|`cusparseZcsric02_analysis` | | +|`cusparseScsric02` | | +|`cusparseDcsric02` | | +|`cusparseCcsric02` | | +|`cusparseZcsric02` | | +|`cusparseXcsric02_zeroPivot` | | +|`cusparseSbsric02_bufferSize` | | +|`cusparseDbsric02_bufferSize` | | +|`cusparseCbsric02_bufferSize` | | +|`cusparseZbsric02_bufferSize` | | +|`cusparseSbsric02_analysis` | | +|`cusparseDbsric02_analysis` | | +|`cusparseCbsric02_analysis` | | +|`cusparseZbsric02_analysis` | | +|`cusparseSbsric02` | | +|`cusparseDbsric02` | | +|`cusparseCbsric02` | | +|`cusparseZbsric02` | | +|`cusparseXbsric02_zeroPivot` | | diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp index ed46fc5a54..38bac33854 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -260,4 +260,40 @@ const std::map CUDA_SPARSE_FUNCTION_MAP{ {"cusparseDcsrgemm2_bufferSizeExt", {"hipsparseDcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseCcsrgemm2_bufferSizeExt", {"hipsparseCcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseZcsrgemm2_bufferSizeExt", {"hipsparseZcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + // 10. cuSPARSE Preconditioners Reference + // 10.1. Incomplete Cholesky Factorization : level 0 + {"cusparseScsric0", {"hipsparseScsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsric0", {"hipsparseDcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsric0", {"hipsparseCcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsric0", {"hipsparseZcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsric02_bufferSize", {"hipsparseScsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsric02_bufferSize", {"hipsparseDcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsric02_bufferSize", {"hipsparseCcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsric02_bufferSize", {"hipsparseZcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsric02_analysis", {"hipsparseScsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsric02_analysis", {"hipsparseDcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsric02_analysis", {"hipsparseCcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsric02_analysis", {"hipsparseZcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsric02", {"hipsparseScsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsric02", {"hipsparseDcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsric02", {"hipsparseCcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsric02", {"hipsparseZcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXcsric02_zeroPivot", {"hipsparseXcsric02_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsric02_analysis", {"hipsparseSbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsric02_analysis", {"hipsparseDbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsric02_analysis", {"hipsparseCbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsric02_analysis", {"hipsparseZbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsric02", {"hipsparseSbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsric02", {"hipsparseDbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsric02", {"hipsparseCbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsric02", {"hipsparseZbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXbsric02_zeroPivot", {"hipsparseXbsric02_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, }; diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_05.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_05.cu new file mode 100644 index 0000000000..c6e7374d0b --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_05.cu @@ -0,0 +1,288 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +#include +// CHECK: #include +#include +// CHECK: #include +#include + +void printCsr( + int m, + int n, + int nnz, + // CHECK: const hipsparseMatDescr_t descrA, + const cusparseMatDescr_t descrA, + const float *csrValA, + const int *csrRowPtrA, + const int *csrColIndA, + const char* name) +{ + // CHECK: const int base = (hipsparseGetMatIndexBase(descrA) != HIPSPARSE_INDEX_BASE_ONE) ? 0 : 1; + const int base = (cusparseGetMatIndexBase(descrA) != CUSPARSE_INDEX_BASE_ONE) ? 0 : 1; + + printf("matrix %s is %d-by-%d, nnz=%d, base=%d, output base-1\n", name, m, n, nnz, base); + for (int row = 0; row < m; row++) { + const int start = csrRowPtrA[row] - base; + const int end = csrRowPtrA[row + 1] - base; + for (int colidx = start; colidx < end; colidx++) { + const int col = csrColIndA[colidx] - base; + const float Areg = csrValA[colidx]; + printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg); + } + } +} + +int main(int argc, char*argv[]) +{ + // CHECK: hipsparseHandle_t handle = NULL; + cusparseHandle_t handle = NULL; + // CHECK: hipStream_t stream = NULL; + cudaStream_t stream = NULL; + // CHECK: hipsparseMatDescr_t descrA = NULL; + cusparseMatDescr_t descrA = NULL; + // CHECK: hipsparseMatDescr_t descrC = NULL; + cusparseMatDescr_t descrC = NULL; + // CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS; + cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS; + // CHECK: hipError_t cudaStat1 = hipSuccess; + cudaError_t cudaStat1 = cudaSuccess; + const int m = 4; + const int n = 4; + const int nnzA = 9; + /* + * | 1 0 2 -3 | + * | 0 4 0 0 | + * A = | 5 0 6 7 | + * | 0 8 0 9 | + * + */ + + const int csrRowPtrA[m + 1] = { 1, 4, 5, 8, 10 }; + const int csrColIndA[nnzA] = { 1, 3, 4, 2, 1, 3, 4, 2, 4 }; + const float csrValA[nnzA] = { 1, 2, -3, 4, 5, 6, 7, 8, 9 }; + + int* csrRowPtrC = NULL; + int* csrColIndC = NULL; + float* csrValC = NULL; + + int *d_csrRowPtrA = NULL; + int *d_csrColIndA = NULL; + float *d_csrValA = NULL; + + int *d_csrRowPtrC = NULL; + int *d_csrColIndC = NULL; + float *d_csrValC = NULL; + + size_t lworkInBytes = 0; + char *d_work = NULL; + + int nnzC = 0; + + float threshold = 4.1; /* remove Aij <= 4.1 */ +// float threshold = 0; /* remove zeros */ + + printf("example of pruneCsr2csr \n"); + + printf("prune |A(i,j)| <= threshold \n"); + printf("threshold = %E \n", threshold); + + /* step 1: create cusparse handle, bind a stream */ + // CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); + cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: status = hipsparseCreate(&handle); + status = cusparseCreate(&handle); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: status = hipsparseSetStream(handle, stream); + status = cusparseSetStream(handle, stream); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + /* step 2: configuration of matrix A and C */ + // CHECK: status = hipsparseCreateMatDescr(&descrA); + status = cusparseCreateMatDescr(&descrA); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + /* A is base-1*/ + // CHECK: hipsparseSetMatIndexBase(descrA, HIPSPARSE_INDEX_BASE_ONE); + cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ONE); + // CHECK: hipsparseSetMatType(descrA, HIPSPARSE_MATRIX_TYPE_GENERAL); + cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL); + // CHECK: status = hipsparseCreateMatDescr(&descrC); + status = cusparseCreateMatDescr(&descrC); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + /* C is base-0 */ + // CHECK: hipsparseSetMatIndexBase(descrC, HIPSPARSE_INDEX_BASE_ZERO); + cusparseSetMatIndexBase(descrC, CUSPARSE_INDEX_BASE_ZERO); + // CHECK: hipsparseSetMatType(descrC, HIPSPARSE_MATRIX_TYPE_GENERAL); + cusparseSetMatType(descrC, CUSPARSE_MATRIX_TYPE_GENERAL); + + printCsr(m, n, nnzA, descrA, csrValA, csrRowPtrA, csrColIndA, "A"); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrRowPtrA, sizeof(int)*(m + 1)); + cudaStat1 = cudaMalloc((void**)&d_csrRowPtrA, sizeof(int)*(m + 1)); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA); + cudaStat1 = cudaMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrValA, sizeof(float)*nnzA); + cudaStat1 = cudaMalloc((void**)&d_csrValA, sizeof(float)*nnzA); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1)); + cudaStat1 = cudaMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1)); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(m + 1), hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(m + 1), cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 3: query workspace */ + // TODO: status = hipsparseSpruneCsr2csr_bufferSizeExt( + status = cusparseSpruneCsr2csr_bufferSizeExt( + handle, + m, + n, + nnzA, + descrA, + d_csrValA, + d_csrRowPtrA, + d_csrColIndA, + &threshold, + descrC, + d_csrValC, + d_csrRowPtrC, + d_csrColIndC, + &lworkInBytes); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + printf("lworkInBytes (prune) = %lld \n", (long long)lworkInBytes); + // CHECK: if (NULL != d_work) { hipFree(d_work); } + if (NULL != d_work) { cudaFree(d_work); } + // cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes); + cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 4: compute csrRowPtrC and nnzC */ + // TODO: status = hipsparseSpruneCsr2csrNnz( + status = cusparseSpruneCsr2csrNnz( + handle, + m, + n, + nnzA, + descrA, + d_csrValA, + d_csrRowPtrA, + d_csrColIndA, + &threshold, + descrC, + d_csrRowPtrC, + &nnzC, /* host */ + d_work); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + printf("nnzC = %d\n", nnzC); + if (0 == nnzC) { + printf("C is empty \n"); + return 0; + } + /* step 5: compute csrColIndC and csrValC */ + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC); + cudaStat1 = cudaMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrValC, sizeof(float) * nnzC); + cudaStat1 = cudaMalloc((void**)&d_csrValC, sizeof(float) * nnzC); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // TODO: status = hipsparseSpruneCsr2csr( + status = cusparseSpruneCsr2csr( + handle, + m, + n, + nnzA, + descrA, + d_csrValA, + d_csrRowPtrA, + d_csrColIndA, + &threshold, + descrC, + d_csrValC, + d_csrRowPtrC, + d_csrColIndC, + d_work); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 6: output C */ + csrRowPtrC = (int*)malloc(sizeof(int)*(m + 1)); + csrColIndC = (int*)malloc(sizeof(int)*nnzC); + csrValC = (float*)malloc(sizeof(float)*nnzC); + assert(NULL != csrRowPtrC); + assert(NULL != csrColIndC); + assert(NULL != csrValC); + // CHECK: cudaStat1 = hipMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + printCsr(m, n, nnzC, descrC, csrValC, csrRowPtrC, csrColIndC, "C"); + /* free resources */ + // CHECK: if (d_csrRowPtrA) hipFree(d_csrRowPtrA); + if (d_csrRowPtrA) cudaFree(d_csrRowPtrA); + // CHECK: if (d_csrColIndA) hipFree(d_csrColIndA); + if (d_csrColIndA) cudaFree(d_csrColIndA); + // CHECK: if (d_csrValA) hipFree(d_csrValA); + if (d_csrValA) cudaFree(d_csrValA); + // CHECK: if (d_csrRowPtrC) hipFree(d_csrRowPtrC); + if (d_csrRowPtrC) cudaFree(d_csrRowPtrC); + // CHECK: if (d_csrColIndC) hipFree(d_csrColIndC); + if (d_csrColIndC) cudaFree(d_csrColIndC); + // CHECK: if (d_csrValC) hipFree(d_csrValC); + if (d_csrValC) cudaFree(d_csrValC); + if (csrRowPtrC) free(csrRowPtrC); + if (csrColIndC) free(csrColIndC); + if (csrValC) free(csrValC); + // CHECK: if (handle) hipsparseDestroy(handle); + if (handle) cusparseDestroy(handle); + // CHECK: if (stream) hipStreamDestroy(stream); + if (stream) cudaStreamDestroy(stream); + // CHECK: if (descrA) hipsparseDestroyMatDescr(descrA); + if (descrA) cusparseDestroyMatDescr(descrA); + // CHECK: if (descrC) hipsparseDestroyMatDescr(descrC); + if (descrC) cusparseDestroyMatDescr(descrC); + // CHECK: hipDeviceReset(); + cudaDeviceReset(); + return 0; +} From 6c085c83a2d6c6f8fa2c85531334fa608f5721c0 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 29 Nov 2018 15:59:58 +0300 Subject: [PATCH 44/55] [HIPIFY][SPARSE] Preconditioners Reference: Incomplete LU Factorization: level 0 + cuSPARSE_06 test + update CUSPARSE_API_supported_by_HIP.md --- .../markdown/CUSPARSE_API_supported_by_HIP.md | 44 +++ .../src/CUDA2HIP_SPARSE_API_functions.cpp | 52 ++++ tests/hipify-clang/cuSPARSE/cuSPARSE_06.cu | 269 ++++++++++++++++++ 3 files changed, 365 insertions(+) create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_06.cu diff --git a/docs/markdown/CUSPARSE_API_supported_by_HIP.md b/docs/markdown/CUSPARSE_API_supported_by_HIP.md index c0f62f9f9d..d15ab83596 100644 --- a/docs/markdown/CUSPARSE_API_supported_by_HIP.md +++ b/docs/markdown/CUSPARSE_API_supported_by_HIP.md @@ -349,3 +349,47 @@ |`cusparseCbsric02` | | |`cusparseZbsric02` | | |`cusparseXbsric02_zeroPivot` | | + +## ***7.2. Incomplete LU Factorization: level 0*** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseScsrilu0` | | +|`cusparseDcsrilu0` | | +|`cusparseCcsrilu0` | | +|`cusparseZcsrilu0` | | +|`cusparseCsrilu0Ex` | | +|`cusparseScsrilu02_numericBoost` | | +|`cusparseDcsrilu02_numericBoost` | | +|`cusparseCcsrilu02_numericBoost` | | +|`cusparseZcsrilu02_numericBoost` | | +|`cusparseScsrilu02_bufferSize` |`hipsparseScsrilu02_bufferSize` | +|`cusparseDcsrilu02_bufferSize` |`hipsparseDcsrilu02_bufferSize` | +|`cusparseCcsrilu02_bufferSize` | | +|`cusparseZcsrilu02_bufferSize` | | +|`cusparseScsrilu02_analysis` |`hipsparseScsrilu02_analysis` | +|`cusparseDcsrilu02_analysis` |`hipsparseDcsrilu02_analysis` | +|`cusparseCcsrilu02_analysis` | | +|`cusparseZcsrilu02_analysis` | | +|`cusparseScsrilu02` |`hipsparseScsrilu02` | +|`cusparseDcsrilu02` |`hipsparseDcsrilu02` | +|`cusparseCcsrilu02` | | +|`cusparseZcsrilu02` | | +|`cusparseXbsric02_zeroPivot` |`hipsparseXcsrilu02_zeroPivot` | +|`cusparseSbsrilu02_numericBoost` | | +|`cusparseDbsrilu02_numericBoost` | | +|`cusparseCbsrilu02_numericBoost` | | +|`cusparseZbsrilu02_numericBoost` | | +|`cusparseSbsrilu02_bufferSize` | | +|`cusparseDbsrilu02_bufferSize` | | +|`cusparseCbsrilu02_bufferSize` | | +|`cusparseZbsrilu02_bufferSize` | | +|`cusparseSbsrilu02_analysis` | | +|`cusparseDbsrilu02_analysis` | | +|`cusparseCbsrilu02_analysis` | | +|`cusparseZbsrilu02_analysis` | | +|`cusparseSbsrilu02` | | +|`cusparseDbsrilu02` | | +|`cusparseCbsrilu02` | | +|`cusparseZbsrilu02` | | +|`cusparseXbsrilu02_zeroPivot` | | diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp index 38bac33854..a0815608be 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -296,4 +296,56 @@ const std::map CUDA_SPARSE_FUNCTION_MAP{ {"cusparseZbsric02", {"hipsparseZbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseXbsric02_zeroPivot", {"hipsparseXbsric02_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + // 10.2. Incomplete LU Factorization: level 0 + {"cusparseScsrilu0", {"hipsparseScsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrilu0", {"hipsparseDcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrilu0", {"hipsparseCcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrilu0", {"hipsparseZcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseCsrilu0Ex", {"hipsparseCsrilu0Ex", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrilu02_numericBoost", {"hipsparseScsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrilu02_numericBoost", {"hipsparseDcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrilu02_numericBoost", {"hipsparseCcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrilu02_numericBoost", {"hipsparseZcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrilu02_bufferSize", {"hipsparseScsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrilu02_bufferSize", {"hipsparseDcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrilu02_bufferSize", {"hipsparseCcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrilu02_bufferSize", {"hipsparseZcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrilu02_analysis", {"hipsparseScsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrilu02_analysis", {"hipsparseDcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrilu02_analysis", {"hipsparseCcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrilu02_analysis", {"hipsparseZcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsrilu02", {"hipsparseScsrilu02", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrilu02", {"hipsparseDcsrilu02", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrilu02", {"hipsparseCcsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrilu02", {"hipsparseZcsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXbsric02_zeroPivot", {"hipsparseXcsrilu02_zeroPivot", CONV_LIB_FUNC, API_SPARSE}}, + + {"cusparseSbsrilu02_numericBoost", {"hipsparseSbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrilu02_numericBoost", {"hipsparseDbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrilu02_numericBoost", {"hipsparseCbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrilu02_numericBoost", {"hipsparseZbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsrilu02_bufferSize", {"hipsparseSbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrilu02_bufferSize", {"hipsparseDbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrilu02_bufferSize", {"hipsparseCbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrilu02_bufferSize", {"hipsparseZbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsrilu02_analysis", {"hipsparseSbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrilu02_analysis", {"hipsparseDbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrilu02_analysis", {"hipsparseCbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrilu02_analysis", {"hipsparseZbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSbsrilu02", {"hipsparseSbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrilu02", {"hipsparseDbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrilu02", {"hipsparseCbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrilu02", {"hipsparseZbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXbsrilu02_zeroPivot", {"hipsparseXbsrilu02_zeroPivot", CONV_LIB_FUNC, API_SPARSE}}, }; diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_06.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_06.cu new file mode 100644 index 0000000000..d38dcd98e4 --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_06.cu @@ -0,0 +1,269 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +#include +// CHECK: #include +#include +// CHECK: #include +#include + +void printMatrix(int m, int n, const float*A, int lda, const char* name) +{ + for (int row = 0; row < m; row++) { + for (int col = 0; col < n; col++) { + float Areg = A[row + col * lda]; + printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg); + } + } +} + +void printCsr( + int m, + int n, + int nnz, + // CHECK: const hipsparseMatDescr_t descrA, + const cusparseMatDescr_t descrA, + const float *csrValA, + const int *csrRowPtrA, + const int *csrColIndA, + const char* name) +{ + // CHECK: const int base = (hipsparseGetMatIndexBase(descrA) != HIPSPARSE_INDEX_BASE_ONE) ? 0 : 1; + const int base = (cusparseGetMatIndexBase(descrA) != CUSPARSE_INDEX_BASE_ONE) ? 0 : 1; + + printf("matrix %s is %d-by-%d, nnz=%d, base=%d, output base-1\n", name, m, n, nnz, base); + for (int row = 0; row < m; row++) { + const int start = csrRowPtrA[row] - base; + const int end = csrRowPtrA[row + 1] - base; + for (int colidx = start; colidx < end; colidx++) { + const int col = csrColIndA[colidx] - base; + const float Areg = csrValA[colidx]; + printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg); + } + } +} + +int main(int argc, char*argv[]) +{ + // CHECK: hipsparseHandle_t handle = NULL; + cusparseHandle_t handle = NULL; + // CHECK: hipStream_t stream = NULL; + cudaStream_t stream = NULL; + // CHECK: hipsparseMatDescr_t descrC = NULL; + cusparseMatDescr_t descrC = NULL; + pruneInfo_t info = NULL; + // CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS; + cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS; + // CHECK: hipError_t cudaStat1 = hipSuccess; + // CHECK: hipError_t cudaStat2 = hipSuccess; + // CHECK: hipError_t cudaStat3 = hipSuccess; + // CHECK: hipError_t cudaStat4 = hipSuccess; + // CHECK: hipError_t cudaStat5 = hipSuccess; + cudaError_t cudaStat1 = cudaSuccess; + cudaError_t cudaStat2 = cudaSuccess; + cudaError_t cudaStat3 = cudaSuccess; + cudaError_t cudaStat4 = cudaSuccess; + cudaError_t cudaStat5 = cudaSuccess; + const int m = 4; + const int n = 4; + const int lda = m; + /* + * | 1 0 2 -3 | + * | 0 4 0 0 | + * A = | 5 0 6 7 | + * | 0 8 0 9 | + * + */ + const float A[lda*n] = { 1, 0, 5, 0, 0, 4, 0, 8, 2, 0, 6, 0, -3, 0, 7, 9 }; + int* csrRowPtrC = NULL; + int* csrColIndC = NULL; + float* csrValC = NULL; + + float *d_A = NULL; + int *d_csrRowPtrC = NULL; + int *d_csrColIndC = NULL; + float *d_csrValC = NULL; + + size_t lworkInBytes = 0; + char *d_work = NULL; + + int nnzC = 0; + + float percentage = 50; /* 50% of nnz */ + + printf("example of pruneDense2csrByPercentage \n"); + + printf("prune out %.1f percentage of A \n", percentage); + + printMatrix(m, n, A, lda, "A"); + + /* step 1: create cusparse handle, bind a stream */ + // CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); + cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: status = hipsparseCreate(&handle); + status = cusparseCreate(&handle); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: status = hipsparseSetStream(handle, stream); + status = cusparseSetStream(handle, stream); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // TODO: status = hipsparseCreatePruneInfo(&info); + status = cusparseCreatePruneInfo(&info); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + /* step 2: configuration of matrix C */ + // CHECK: status = hipsparseCreateMatDescr(&descrC); + status = cusparseCreateMatDescr(&descrC); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: hipsparseSetMatIndexBase(descrC, HIPSPARSE_INDEX_BASE_ZERO); + cusparseSetMatIndexBase(descrC, CUSPARSE_INDEX_BASE_ZERO); + // CHECK: hipsparseSetMatType(descrC, HIPSPARSE_MATRIX_TYPE_GENERAL); + cusparseSetMatType(descrC, CUSPARSE_MATRIX_TYPE_GENERAL); + // CHECK: cudaStat1 = hipMalloc((void**)&d_A, sizeof(float)*lda*n); + cudaStat1 = cudaMalloc((void**)&d_A, sizeof(float)*lda*n); + // CHECK: cudaStat2 = hipMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1)); + cudaStat2 = cudaMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1)); + // CHECK: assert(hipSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + assert(cudaSuccess == cudaStat1); + assert(cudaSuccess == cudaStat2); + // CHECK: cudaStat1 = hipMemcpy(d_A, A, sizeof(float)*lda*n, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_A, A, sizeof(float)*lda*n, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + /* step 3: query workspace */ + // TODO: status = hipsparseSpruneDense2csrByPercentage_bufferSizeExt( + status = cusparseSpruneDense2csrByPercentage_bufferSizeExt( + handle, + m, + n, + d_A, + lda, + percentage, + descrC, + d_csrValC, + d_csrRowPtrC, + d_csrColIndC, + info, + &lworkInBytes); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + printf("lworkInBytes = %lld \n", (long long)lworkInBytes); + // CHECK: if (NULL != d_work) { hipFree(d_work); } + if (NULL != d_work) { cudaFree(d_work); } + // CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes); + cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 4: compute csrRowPtrC and nnzC */ + // TODO: status = hipsparseSpruneDense2csrNnzByPercentage( + status = cusparseSpruneDense2csrNnzByPercentage( + handle, + m, + n, + d_A, + lda, + percentage, + descrC, + d_csrRowPtrC, + &nnzC, /* host */ + info, + d_work); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + printf("nnzC = %d\n", nnzC); + if (0 == nnzC) { + printf("C is empty \n"); + return 0; + } + + /* step 5: compute csrColIndC and csrValC */ + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC); + cudaStat1 = cudaMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC); + // CHECK: cudaStat2 = hipMalloc((void**)&d_csrValC, sizeof(float) * nnzC); + cudaStat2 = cudaMalloc((void**)&d_csrValC, sizeof(float) * nnzC); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + assert(cudaSuccess == cudaStat2); + // TODO: status = hipsparseSpruneDense2csrByPercentage( + status = cusparseSpruneDense2csrByPercentage( + handle, + m, + n, + d_A, + lda, + percentage, + descrC, + d_csrValC, + d_csrRowPtrC, + d_csrColIndC, + info, + d_work); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 7: output C */ + csrRowPtrC = (int*)malloc(sizeof(int)*(m + 1)); + csrColIndC = (int*)malloc(sizeof(int)*nnzC); + csrValC = (float*)malloc(sizeof(float)*nnzC); + assert(NULL != csrRowPtrC); + assert(NULL != csrColIndC); + assert(NULL != csrValC); + // CHECK: cudaStat1 = hipMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), cudaMemcpyDeviceToHost); + // CHECK: cudaStat2 = hipMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, hipMemcpyDeviceToHost); + cudaStat2 = cudaMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, cudaMemcpyDeviceToHost); + // CHECK: cudaStat3 = hipMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, hipMemcpyDeviceToHost); + cudaStat3 = cudaMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + // CHECK: assert(hipSuccess == cudaStat2); + // CHECK: assert(hipSuccess == cudaStat3); + assert(cudaSuccess == cudaStat1); + assert(cudaSuccess == cudaStat2); + assert(cudaSuccess == cudaStat3); + + printCsr(m, n, nnzC, descrC, csrValC, csrRowPtrC, csrColIndC, "C"); + + /* free resources */ + // CHECK: if (d_A) hipFree(d_A); + if (d_A) cudaFree(d_A); + // CHECK: if (d_csrRowPtrC) hipFree(d_csrRowPtrC); + if (d_csrRowPtrC) cudaFree(d_csrRowPtrC); + // CHECK: if (d_csrColIndC) hipFree(d_csrColIndC); + if (d_csrColIndC) cudaFree(d_csrColIndC); + // CHECK: if (d_csrValC) hipFree(d_csrValC); + if (d_csrValC) cudaFree(d_csrValC); + + if (csrRowPtrC) free(csrRowPtrC); + if (csrColIndC) free(csrColIndC); + if (csrValC) free(csrValC); + // CHECK: if (handle) hipsparseDestroy(handle); + if (handle) cusparseDestroy(handle); + // CHECK: if (stream) hipStreamDestroy(stream); + if (stream) cudaStreamDestroy(stream); + // CHECK: if (descrC) hipsparseDestroyMatDescr(descrC); + if (descrC) cusparseDestroyMatDescr(descrC); + // TODO: if (info) hipsparseDestroyPruneInfo(info); + if (info) cusparseDestroyPruneInfo(info); + // CHECK: hipDeviceReset(); + cudaDeviceReset(); + return 0; +} + From 8a84c665e2595ce8c96d13bb08a96f955767a568 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 29 Nov 2018 18:46:51 +0300 Subject: [PATCH 45/55] [HIPIFY][SPARSE] Preconditioners Reference: Tridiagonal and Pentadiagonal solves + Tridiagonal Solve, Batched Tridiagonal and Pentadiagonal Solve + cuSPARSE_07 test + update CUSPARSE_API_supported_by_HIP.md --- .../markdown/CUSPARSE_API_supported_by_HIP.md | 67 ++ .../src/CUDA2HIP_SPARSE_API_functions.cpp | 610 ++++++++++-------- tests/hipify-clang/cuSPARSE/cuSPARSE_07.cu | 302 +++++++++ 3 files changed, 708 insertions(+), 271 deletions(-) create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_07.cu diff --git a/docs/markdown/CUSPARSE_API_supported_by_HIP.md b/docs/markdown/CUSPARSE_API_supported_by_HIP.md index d15ab83596..0d0ded1406 100644 --- a/docs/markdown/CUSPARSE_API_supported_by_HIP.md +++ b/docs/markdown/CUSPARSE_API_supported_by_HIP.md @@ -393,3 +393,70 @@ |`cusparseCbsrilu02` | | |`cusparseZbsrilu02` | | |`cusparseXbsrilu02_zeroPivot` | | + +## ***7.3. Tridiagonal Solve*** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseSgtsv` | | +|`cusparseDgtsv` | | +|`cusparseCgtsv` | | +|`cusparseZgtsv` | | +|`cusparseSgtsv_nopivot` | | +|`cusparseDgtsv_nopivot` | | +|`cusparseCgtsv_nopivot` | | +|`cusparseZgtsv_nopivot` | | +|`cusparseSgtsv2_bufferSizeExt` | | +|`cusparseDgtsv2_bufferSizeExt` | | +|`cusparseCgtsv2_bufferSizeExt` | | +|`cusparseZgtsv2_bufferSizeExt` | | +|`cusparseSgtsv2` | | +|`cusparseDgtsv2` | | +|`cusparseCgtsv2` | | +|`cusparseZgtsv2` | | +|`cusparseSgtsv2_nopivot_bufferSizeExt` | | +|`cusparseDgtsv2_nopivot_bufferSizeExt` | | +|`cusparseCgtsv2_nopivot_bufferSizeExt` | | +|`cusparseZgtsv2_nopivot_bufferSizeExt` | | +|`cusparseSgtsv2_nopivot` | | +|`cusparseDgtsv2_nopivot` | | +|`cusparseCgtsv2_nopivot` | | +|`cusparseZgtsv2_nopivot` | | + +## ***7.4. Batched Tridiagonal Solve*** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseSgtsvStridedBatch` | | +|`cusparseDgtsvStridedBatch` | | +|`cusparseCgtsvStridedBatch` | | +|`cusparseZgtsvStridedBatch` | | +|`cusparseSgtsv2StridedBatch_bufferSizeExt` | | +|`cusparseDgtsv2StridedBatch_bufferSizeExt` | | +|`cusparseCgtsv2StridedBatch_bufferSizeExt` | | +|`cusparseZgtsv2StridedBatch_bufferSizeExt` | | +|`cusparseSgtsv2StridedBatch` | | +|`cusparseDgtsv2StridedBatch` | | +|`cusparseCgtsv2StridedBatch` | | +|`cusparseZgtsv2StridedBatch` | | +|`cusparseSgtsvInterleavedBatch_bufferSizeExt` | | +|`cusparseDgtsvInterleavedBatch_bufferSizeExt` | | +|`cusparseCgtsvInterleavedBatch_bufferSizeExt` | | +|`cusparseZgtsvInterleavedBatch_bufferSizeExt` | | +|`cusparseSgtsvInterleavedBatch` | | +|`cusparseDgtsvInterleavedBatch` | | +|`cusparseCgtsvInterleavedBatch` | | +|`cusparseZgtsvInterleavedBatch` | | + +## ***7.5. Batched Pentadiagonal Solve*** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseSgpsvInterleavedBatch_bufferSizeExt` | | +|`cusparseDgpsvInterleavedBatch_bufferSizeExt` | | +|`cusparseCgpsvInterleavedBatch_bufferSizeExt` | | +|`cusparseZgpsvInterleavedBatch_bufferSizeExt` | | +|`cusparseSgpsvInterleavedBatch` | | +|`cusparseDgpsvInterleavedBatch` | | +|`cusparseCgpsvInterleavedBatch` | | +|`cusparseZgpsvInterleavedBatch` | | diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp index a0815608be..fdb1a8381c 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -3,349 +3,417 @@ // Maps the names of CUDA SPARSE API types to the corresponding HIP types const std::map CUDA_SPARSE_FUNCTION_MAP{ // 5. cuSPARSE Helper Function Reference - {"cusparseCreate", {"hipsparseCreate", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCreateSolveAnalysisInfo", {"hipsparseCreateSolveAnalysisInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCreateHybMat", {"hipsparseCreateHybMat", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCreateMatDescr", {"hipsparseCreateMatDescr", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDestroy", {"hipsparseDestroy", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDestroySolveAnalysisInfo", {"hipsparseDestroySolveAnalysisInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDestroyHybMat", {"hipsparseDestroyHybMat", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDestroyMatDescr", {"hipsparseDestroyMatDescr", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseGetLevelInfo", {"hipsparseGetLevelInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseGetMatDiagType", {"hipsparseGetMatDiagType", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseGetMatFillMode", {"hipsparseGetMatFillMode", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseGetMatIndexBase", {"hipsparseGetMatIndexBase", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseGetMatType", {"hipsparseGetMatType", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseGetPointerMode", {"hipsparseGetPointerMode", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseGetVersion", {"hipsparseGetVersion", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseSetMatDiagType", {"hipsparseSetMatDiagType", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseSetMatFillMode", {"hipsparseSetMatFillMode", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseSetMatIndexBase", {"hipsparseSetMatIndexBase", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseSetMatType", {"hipsparseSetMatType", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseSetPointerMode", {"hipsparseSetPointerMode", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseSetStream", {"hipsparseSetStream", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseGetStream", {"hipsparseGetStream", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCreateCsrsv2Info", {"hipsparseCreateCsrsv2Info", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDestroyCsrsv2Info", {"hipsparseDestroyCsrsv2Info", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCreateCsrsm2Info", {"hipsparseCreateCsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDestroyCsrsm2Info", {"hipsparseDestroyCsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCreateCsric02Info", {"hipsparseCreateCsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDestroyCsric02Info", {"hipsparseDestroyCsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCreateCsrilu02Info", {"hipsparseCreateCsrilu02Info", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDestroyCsrilu02Info", {"hipsparseDestroyCsrilu02Info", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCreateBsrsv2Info", {"hipsparseCreateBsrsv2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDestroyBsrsv2Info", {"hipsparseDestroyBsrsv2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCreateBsrsm2Info", {"hipsparseCreateBsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDestroyBsrsm2Info", {"hipsparseDestroyBsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCreateBsric02Inf", {"hipsparseCreateBsric02Inf", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDestroyBsric02Info", {"hipsparseDestroyBsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCreateBsrilu02Info", {"hipsparseCreateBsrilu02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDestroyBsrilu02Info", {"hipsparseDestroyBsrilu02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCreateCsrgemm2Info", {"hipsparseCreateCsrgemm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDestroyCsrgemm2Info", {"hipsparseDestroyCsrgemm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCreatePruneInfo", {"hipsparseCreatePruneInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDestroyPruneInfo", {"hipsparseDestroyPruneInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreate", {"hipsparseCreate", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCreateSolveAnalysisInfo", {"hipsparseCreateSolveAnalysisInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateHybMat", {"hipsparseCreateHybMat", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCreateMatDescr", {"hipsparseCreateMatDescr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDestroy", {"hipsparseDestroy", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDestroySolveAnalysisInfo", {"hipsparseDestroySolveAnalysisInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyHybMat", {"hipsparseDestroyHybMat", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDestroyMatDescr", {"hipsparseDestroyMatDescr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetLevelInfo", {"hipsparseGetLevelInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseGetMatDiagType", {"hipsparseGetMatDiagType", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetMatFillMode", {"hipsparseGetMatFillMode", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetMatIndexBase", {"hipsparseGetMatIndexBase", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetMatType", {"hipsparseGetMatType", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetPointerMode", {"hipsparseGetPointerMode", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetVersion", {"hipsparseGetVersion", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetMatDiagType", {"hipsparseSetMatDiagType", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetMatFillMode", {"hipsparseSetMatFillMode", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetMatIndexBase", {"hipsparseSetMatIndexBase", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetMatType", {"hipsparseSetMatType", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetPointerMode", {"hipsparseSetPointerMode", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSetStream", {"hipsparseSetStream", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseGetStream", {"hipsparseGetStream", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCreateCsrsv2Info", {"hipsparseCreateCsrsv2Info", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDestroyCsrsv2Info", {"hipsparseDestroyCsrsv2Info", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCreateCsrsm2Info", {"hipsparseCreateCsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyCsrsm2Info", {"hipsparseDestroyCsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateCsric02Info", {"hipsparseCreateCsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyCsric02Info", {"hipsparseDestroyCsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateCsrilu02Info", {"hipsparseCreateCsrilu02Info", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDestroyCsrilu02Info", {"hipsparseDestroyCsrilu02Info", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCreateBsrsv2Info", {"hipsparseCreateBsrsv2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyBsrsv2Info", {"hipsparseDestroyBsrsv2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateBsrsm2Info", {"hipsparseCreateBsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyBsrsm2Info", {"hipsparseDestroyBsrsm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateBsric02Inf", {"hipsparseCreateBsric02Inf", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyBsric02Info", {"hipsparseDestroyBsric02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateBsrilu02Info", {"hipsparseCreateBsrilu02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyBsrilu02Info", {"hipsparseDestroyBsrilu02Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreateCsrgemm2Info", {"hipsparseCreateCsrgemm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyCsrgemm2Info", {"hipsparseDestroyCsrgemm2Info", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCreatePruneInfo", {"hipsparseCreatePruneInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyPruneInfo", {"hipsparseDestroyPruneInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, // 6. cuSPARSE Level 1 Function Reference - {"cusparseSaxpyi", {"hipsparseSaxpyi", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDaxpyi", {"hipsparseDaxpyi", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCaxpyi", {"hipsparseCaxpyi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZaxpyi", {"hipsparseZaxpyi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSaxpyi", {"hipsparseSaxpyi", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDaxpyi", {"hipsparseDaxpyi", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCaxpyi", {"hipsparseCaxpyi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZaxpyi", {"hipsparseZaxpyi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSdoti", {"hipsparseSdoti", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDdoti", {"hipsparseDdoti", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCdoti", {"hipsparseCdoti", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZdoti", {"hipsparseZdoti", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSdoti", {"hipsparseSdoti", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDdoti", {"hipsparseDdoti", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCdoti", {"hipsparseCdoti", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZdoti", {"hipsparseZdoti", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCdotci", {"hipsparseCdotci", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZdotci", {"hipsparseZdotci", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCdotci", {"hipsparseCdotci", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZdotci", {"hipsparseZdotci", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSgthr", {"hipsparseSgthr", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDgthr", {"hipsparseDgthr", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCgthr", {"hipsparseCgthr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZgthr", {"hipsparseZgthr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSgthr", {"hipsparseSgthr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDgthr", {"hipsparseDgthr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCgthr", {"hipsparseCgthr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgthr", {"hipsparseZgthr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSgthrz", {"hipsparseSgthrz", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDgthrz", {"hipsparseDgthrz", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCgthrz", {"hipsparseCgthrz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZgthrz", {"hipsparseZgthrz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSgthrz", {"hipsparseSgthrz", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDgthrz", {"hipsparseDgthrz", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCgthrz", {"hipsparseCgthrz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgthrz", {"hipsparseZgthrz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSroti", {"hipsparseSroti", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDroti", {"hipsparseDroti", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseSroti", {"hipsparseSroti", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDroti", {"hipsparseDroti", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseSsctr", {"hipsparseSsctr", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDsctr", {"hipsparseDsctr", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCsctr", {"hipsparseCsctr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZsctr", {"hipsparseZsctr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSsctr", {"hipsparseSsctr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDsctr", {"hipsparseDsctr", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCsctr", {"hipsparseCsctr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZsctr", {"hipsparseZsctr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, // 7. cuSPARSE Level 2 Function Reference - {"cusparseSbsrmv", {"hipsparseSbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrmv", {"hipsparseDbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrmv", {"hipsparseCbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrmv", {"hipsparseZbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrmv", {"hipsparseSbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrmv", {"hipsparseDbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrmv", {"hipsparseCbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrmv", {"hipsparseZbsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsrxmv", {"hipsparseSbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrxmv", {"hipsparseDbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrxmv", {"hipsparseCbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrxmv", {"hipsparseZbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrxmv", {"hipsparseSbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrxmv", {"hipsparseDbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrxmv", {"hipsparseCbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrxmv", {"hipsparseZbsrxmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrmv", {"hipsparseScsrmv", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDcsrmv", {"hipsparseDcsrmv", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCcsrmv", {"hipsparseCcsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrmv", {"hipsparseZcsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrmv", {"hipsparseScsrmv", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrmv", {"hipsparseDcsrmv", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrmv", {"hipsparseCcsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrmv", {"hipsparseZcsrmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCsrmvEx", {"hipsparseCsrmvEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCsrmvEx_bufferSize", {"hipsparseCsrmvEx_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCsrmvEx", {"hipsparseCsrmvEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCsrmvEx_bufferSize", {"hipsparseCsrmvEx_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrmv_mp", {"hipsparseScsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrmv_mp", {"hipsparseDcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrmv_mp", {"hipsparseCcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrmv_mp", {"hipsparseZcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrmv_mp", {"hipsparseScsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrmv_mp", {"hipsparseDcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrmv_mp", {"hipsparseCcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrmv_mp", {"hipsparseZcsrmv_mp", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSgemvi", {"hipsparseSgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDgemvi", {"hipsparseDgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCgemvi", {"hipsparseCgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZgemvi", {"hipsparseZgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSgemvi", {"hipsparseSgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgemvi", {"hipsparseDgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgemvi", {"hipsparseCgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgemvi", {"hipsparseZgemvi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSgemvi_bufferSize", {"hipsparseSgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDgemvi_bufferSize", {"hipsparseDgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCgemvi_bufferSize", {"hipsparseCgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZgemvi_bufferSize", {"hipsparseZgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSgemvi_bufferSize", {"hipsparseSgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgemvi_bufferSize", {"hipsparseDgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgemvi_bufferSize", {"hipsparseCgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgemvi_bufferSize", {"hipsparseZgemvi_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsrsv2_bufferSize", {"hipsparseSbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrsv2_bufferSize", {"hipsparseDbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrsv2_bufferSize", {"hipsparseCbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrsv2_bufferSize", {"hipsparseZbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrsv2_bufferSize", {"hipsparseSbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrsv2_bufferSize", {"hipsparseDbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrsv2_bufferSize", {"hipsparseCbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrsv2_bufferSize", {"hipsparseZbsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsrsv2_analysis", {"hipsparseSbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrsv2_analysis", {"hipsparseDbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrsv2_analysis", {"hipsparseCbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrsv2_analysis", {"hipsparseZbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrsv2_analysis", {"hipsparseSbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrsv2_analysis", {"hipsparseDbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrsv2_analysis", {"hipsparseCbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrsv2_analysis", {"hipsparseZbsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsv_solve", {"hipsparseScsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrsv_solve", {"hipsparseDcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrsv_solve", {"hipsparseCcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsv_solve", {"hipsparseZcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsv_solve", {"hipsparseScsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsv_solve", {"hipsparseDcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsv_solve", {"hipsparseCcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv_solve", {"hipsparseZcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseXbsrsv2_zeroPivot", {"hipsparseXbsrsv2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseXbsrsv2_zeroPivot", {"hipsparseXbsrsv2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsv_analysis", {"hipsparseScsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrsv_analysis", {"hipsparseDcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrsv_analysis", {"hipsparseCcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsv_analysis", {"hipsparseZcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsv_analysis", {"hipsparseScsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsv_analysis", {"hipsparseDcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsv_analysis", {"hipsparseCcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv_analysis", {"hipsparseZcsrsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCsrsv_analysisEx", {"hipsparseCsrsv_analysisEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCsrsv_analysisEx", {"hipsparseCsrsv_analysisEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsv_solve", {"hipsparseScsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrsv_solve", {"hipsparseDcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrsv_solve", {"hipsparseCcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsv_solve", {"hipsparseZcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsv_solve", {"hipsparseScsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsv_solve", {"hipsparseDcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsv_solve", {"hipsparseCcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv_solve", {"hipsparseZcsrsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCsrsv_solveEx", {"hipsparseCsrsv_solveEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCsrsv_solveEx", {"hipsparseCsrsv_solveEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsv2_bufferSize", {"hipsparseScsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDcsrsv2_bufferSize", {"hipsparseDcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCcsrsv2_bufferSize", {"hipsparseCcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsv2_bufferSize", {"hipsparseZcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsv2_bufferSize", {"hipsparseScsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrsv2_bufferSize", {"hipsparseDcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrsv2_bufferSize", {"hipsparseCcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv2_bufferSize", {"hipsparseZcsrsv2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsv2_analysis", {"hipsparseScsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDcsrsv2_analysis", {"hipsparseDcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCcsrsv2_analysis", {"hipsparseCcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsv2_analysis", {"hipsparseZcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsv2_analysis", {"hipsparseScsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrsv2_analysis", {"hipsparseDcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrsv2_analysis", {"hipsparseCcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv2_analysis", {"hipsparseZcsrsv2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsv2_solve", {"hipsparseScsrsv2_solve", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDcsrsv2_solve", {"hipsparseDcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCcsrsv2_solve", {"hipsparseCcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsv2_solve", {"hipsparseZcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsv2_solve", {"hipsparseScsrsv2_solve", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrsv2_solve", {"hipsparseDcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrsv2_solve", {"hipsparseCcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsv2_solve", {"hipsparseZcsrsv2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseXcsrsv2_zeroPivot", {"hipsparseXcsrsv2_zeroPivot", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseXcsrsv2_zeroPivot", {"hipsparseXcsrsv2_zeroPivot", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseShybmv", {"hipsparseShybmv", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDhybmv", {"hipsparseDhybmv", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseChybmv", {"hipsparseChybmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZhybmv", {"hipsparseZhybmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseShybmv", {"hipsparseShybmv", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDhybmv", {"hipsparseDhybmv", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseChybmv", {"hipsparseChybmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZhybmv", {"hipsparseZhybmv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseShybsv_analysis", {"hipsparseShybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDhybsv_analysis", {"hipsparseDhybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseChybsv_analysis", {"hipsparseChybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZhybsv_analysis", {"hipsparseZhybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseShybsv_analysis", {"hipsparseShybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDhybsv_analysis", {"hipsparseDhybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseChybsv_analysis", {"hipsparseChybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZhybsv_analysis", {"hipsparseZhybsv_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseShybsv_solve", {"hipsparseShybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDhybsv_solve", {"hipsparseDhybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseChybsv_solve", {"hipsparseChybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZhybsv_solve", {"hipsparseZhybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseShybsv_solve", {"hipsparseShybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDhybsv_solve", {"hipsparseDhybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseChybsv_solve", {"hipsparseChybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZhybsv_solve", {"hipsparseZhybsv_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, // 8. cuSPARSE Level 3 Function Reference - {"cusparseScsrmm", {"hipsparseScsrmm", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDcsrmm", {"hipsparseDcsrmm", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCcsrmm", {"hipsparseCcsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrmm", {"hipsparseZcsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrmm", {"hipsparseScsrmm", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrmm", {"hipsparseDcsrmm", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrmm", {"hipsparseCcsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrmm", {"hipsparseZcsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrmm2", {"hipsparseScsrmm2", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDcsrmm2", {"hipsparseDcsrmm2", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCcsrmm2", {"hipsparseCcsrmm2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrmm2", {"hipsparseZcsrmm2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrmm2", {"hipsparseScsrmm2", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrmm2", {"hipsparseDcsrmm2", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrmm2", {"hipsparseCcsrmm2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrmm2", {"hipsparseZcsrmm2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsm_analysis", {"hipsparseScsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrsm_analysis", {"hipsparseDcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrsm_analysis", {"hipsparseCcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsm_analysis", {"hipsparseZcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsm_analysis", {"hipsparseScsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsm_analysis", {"hipsparseDcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsm_analysis", {"hipsparseCcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsm_analysis", {"hipsparseZcsrsm_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsm_solve", {"hipsparseScsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrsm_solve", {"hipsparseDcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrsm_solve", {"hipsparseCcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsm_solve", {"hipsparseZcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsm_solve", {"hipsparseScsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsm_solve", {"hipsparseDcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsm_solve", {"hipsparseCcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsm_solve", {"hipsparseZcsrsm_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsm2_bufferSizeExt", {"hipsparseScsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrsm2_bufferSizeExt", {"hipsparseDcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrsm2_bufferSizeExt", {"hipsparseCcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsm2_bufferSizeExt", {"hipsparseZcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsm2_bufferSizeExt", {"hipsparseScsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsm2_bufferSizeExt", {"hipsparseDcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsm2_bufferSizeExt", {"hipsparseCcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsm2_bufferSizeExt", {"hipsparseZcsrsm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsm2_analysis", {"hipsparseScsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrsm2_analysis", {"hipsparseDcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrsm2_analysis", {"hipsparseCcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsm2_analysis", {"hipsparseZcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsm2_analysis", {"hipsparseScsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsm2_analysis", {"hipsparseDcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsm2_analysis", {"hipsparseCcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsm2_analysis", {"hipsparseZcsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrsm2_solve", {"hipsparseScsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrsm2_solve", {"hipsparseDcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrsm2_solve", {"hipsparseCcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrsm2_solve", {"hipsparseZcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrsm2_solve", {"hipsparseScsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrsm2_solve", {"hipsparseDcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrsm2_solve", {"hipsparseCcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrsm2_solve", {"hipsparseZcsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseXcsrsm2_zeroPivot", {"hipsparseXcsrsm2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseXcsrsm2_zeroPivot", {"hipsparseXcsrsm2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsrmm", {"hipsparseSbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrmm", {"hipsparseDbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrmm", {"hipsparseCbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrmm", {"hipsparseZbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrmm", {"hipsparseSbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrmm", {"hipsparseDbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrmm", {"hipsparseCbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrmm", {"hipsparseZbsrmm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsrsm2_bufferSize", {"hipsparseCbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrsm2_bufferSize", {"hipsparseDbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrsm2_bufferSize", {"hipsparseCbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrsm2_bufferSize", {"hipsparseZbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrsm2_bufferSize", {"hipsparseCbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrsm2_bufferSize", {"hipsparseDbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrsm2_bufferSize", {"hipsparseCbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrsm2_bufferSize", {"hipsparseZbsrsm2_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsrsm2_analysis", {"hipsparseSbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrsm2_analysis", {"hipsparseDbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrsm2_analysis", {"hipsparseCbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrsm2_analysis", {"hipsparseZbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrsm2_analysis", {"hipsparseSbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrsm2_analysis", {"hipsparseDbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrsm2_analysis", {"hipsparseCbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrsm2_analysis", {"hipsparseZbsrsm2_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsrsm2_solve", {"hipsparseSbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrsm2_solve", {"hipsparseDbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrsm2_solve", {"hipsparseCbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrsm2_solve", {"hipsparseZbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrsm2_solve", {"hipsparseSbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrsm2_solve", {"hipsparseDbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrsm2_solve", {"hipsparseCbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrsm2_solve", {"hipsparseZbsrsm2_solve", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseXbsrsm2_zeroPivot", {"hipsparseXbsrsm2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseXbsrsm2_zeroPivot", {"hipsparseXbsrsm2_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSgemmi", {"hipsparseSgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDgemmi", {"hipsparseDgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCgemmi", {"hipsparseCgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZgemmi", {"hipsparseZgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSgemmi", {"hipsparseSgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgemmi", {"hipsparseDgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgemmi", {"hipsparseCgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgemmi", {"hipsparseZgemmi", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, // 9. cuSPARSE Extra Function Reference - {"cusparseXcsrgeamNnz", {"hipsparseXcsrgeamNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrgeam", {"hipsparseScsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrgeam", {"hipsparseDcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrgeam", {"hipsparseCcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseXcsrgeamNnz", {"hipsparseXcsrgeamNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrgeam", {"hipsparseScsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrgeam", {"hipsparseDcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrgeam", {"hipsparseCcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrgeam2_bufferSizeExt", {"hipsparseScsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrgeam2_bufferSizeExt", {"hipsparseDcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrgeam2_bufferSizeExt", {"hipsparseCcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrgeam2_bufferSizeExt", {"hipsparseZcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrgeam2_bufferSizeExt", {"hipsparseScsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrgeam2_bufferSizeExt", {"hipsparseDcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrgeam2_bufferSizeExt", {"hipsparseCcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrgeam2_bufferSizeExt", {"hipsparseZcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseXcsrgemmNnz", {"hipsparseXcsrgemmNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrgemm", {"hipsparseScsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrgemm", {"hipsparseDcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrgemm", {"hipsparseCcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseXcsrgemmNnz", {"hipsparseXcsrgemmNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrgemm", {"hipsparseScsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrgemm", {"hipsparseDcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrgemm", {"hipsparseCcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrgemm2_bufferSizeExt", {"hipsparseScsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrgemm2_bufferSizeExt", {"hipsparseDcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrgemm2_bufferSizeExt", {"hipsparseCcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrgemm2_bufferSizeExt", {"hipsparseZcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrgemm2_bufferSizeExt", {"hipsparseScsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrgemm2_bufferSizeExt", {"hipsparseDcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrgemm2_bufferSizeExt", {"hipsparseCcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrgemm2_bufferSizeExt", {"hipsparseZcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, // 10. cuSPARSE Preconditioners Reference // 10.1. Incomplete Cholesky Factorization : level 0 - {"cusparseScsric0", {"hipsparseScsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsric0", {"hipsparseDcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsric0", {"hipsparseCcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsric0", {"hipsparseZcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsric0", {"hipsparseScsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsric0", {"hipsparseDcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsric0", {"hipsparseCcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsric0", {"hipsparseZcsric0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsric02_bufferSize", {"hipsparseScsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsric02_bufferSize", {"hipsparseDcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsric02_bufferSize", {"hipsparseCcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsric02_bufferSize", {"hipsparseZcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsric02_bufferSize", {"hipsparseScsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsric02_bufferSize", {"hipsparseDcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsric02_bufferSize", {"hipsparseCcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsric02_bufferSize", {"hipsparseZcsric02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsric02_analysis", {"hipsparseScsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsric02_analysis", {"hipsparseDcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsric02_analysis", {"hipsparseCcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsric02_analysis", {"hipsparseZcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsric02_analysis", {"hipsparseScsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsric02_analysis", {"hipsparseDcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsric02_analysis", {"hipsparseCcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsric02_analysis", {"hipsparseZcsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsric02", {"hipsparseScsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsric02", {"hipsparseDcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsric02", {"hipsparseCcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsric02", {"hipsparseZcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsric02", {"hipsparseScsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsric02", {"hipsparseDcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsric02", {"hipsparseCcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsric02", {"hipsparseZcsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseXcsric02_zeroPivot", {"hipsparseXcsric02_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseXcsric02_zeroPivot", {"hipsparseXcsric02_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsric02_analysis", {"hipsparseSbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsric02_analysis", {"hipsparseDbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsric02_analysis", {"hipsparseCbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsric02_analysis", {"hipsparseZbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsric02_analysis", {"hipsparseSbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsric02_analysis", {"hipsparseDbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsric02_analysis", {"hipsparseCbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsric02_analysis", {"hipsparseZbsric02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsric02", {"hipsparseSbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsric02", {"hipsparseDbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsric02", {"hipsparseCbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsric02", {"hipsparseZbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsric02", {"hipsparseSbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsric02", {"hipsparseDbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsric02", {"hipsparseCbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsric02", {"hipsparseZbsric02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseXbsric02_zeroPivot", {"hipsparseXbsric02_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseXbsric02_zeroPivot", {"hipsparseXbsric02_zeroPivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, // 10.2. Incomplete LU Factorization: level 0 - {"cusparseScsrilu0", {"hipsparseScsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrilu0", {"hipsparseDcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrilu0", {"hipsparseCcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrilu0", {"hipsparseZcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrilu0", {"hipsparseScsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrilu0", {"hipsparseDcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrilu0", {"hipsparseCcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrilu0", {"hipsparseZcsrilu0", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCsrilu0Ex", {"hipsparseCsrilu0Ex", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCsrilu0Ex", {"hipsparseCsrilu0Ex", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrilu02_numericBoost", {"hipsparseScsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDcsrilu02_numericBoost", {"hipsparseDcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCcsrilu02_numericBoost", {"hipsparseCcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrilu02_numericBoost", {"hipsparseZcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrilu02_numericBoost", {"hipsparseScsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrilu02_numericBoost", {"hipsparseDcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrilu02_numericBoost", {"hipsparseCcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrilu02_numericBoost", {"hipsparseZcsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrilu02_bufferSize", {"hipsparseScsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDcsrilu02_bufferSize", {"hipsparseDcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCcsrilu02_bufferSize", {"hipsparseCcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrilu02_bufferSize", {"hipsparseZcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrilu02_bufferSize", {"hipsparseScsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrilu02_bufferSize", {"hipsparseDcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrilu02_bufferSize", {"hipsparseCcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrilu02_bufferSize", {"hipsparseZcsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrilu02_analysis", {"hipsparseScsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDcsrilu02_analysis", {"hipsparseDcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCcsrilu02_analysis", {"hipsparseCcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrilu02_analysis", {"hipsparseZcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrilu02_analysis", {"hipsparseScsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrilu02_analysis", {"hipsparseDcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrilu02_analysis", {"hipsparseCcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrilu02_analysis", {"hipsparseZcsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseScsrilu02", {"hipsparseScsrilu02", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseDcsrilu02", {"hipsparseDcsrilu02", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseCcsrilu02", {"hipsparseCcsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZcsrilu02", {"hipsparseZcsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsrilu02", {"hipsparseScsrilu02", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsrilu02", {"hipsparseDcsrilu02", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsrilu02", {"hipsparseCcsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrilu02", {"hipsparseZcsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseXbsric02_zeroPivot", {"hipsparseXcsrilu02_zeroPivot", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseXbsric02_zeroPivot", {"hipsparseXcsrilu02_zeroPivot", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseSbsrilu02_numericBoost", {"hipsparseSbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrilu02_numericBoost", {"hipsparseDbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrilu02_numericBoost", {"hipsparseCbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrilu02_numericBoost", {"hipsparseZbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrilu02_numericBoost", {"hipsparseSbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrilu02_numericBoost", {"hipsparseDbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrilu02_numericBoost", {"hipsparseCbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrilu02_numericBoost", {"hipsparseZbsrilu02_numericBoost", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsrilu02_bufferSize", {"hipsparseSbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrilu02_bufferSize", {"hipsparseDbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrilu02_bufferSize", {"hipsparseCbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrilu02_bufferSize", {"hipsparseZbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrilu02_bufferSize", {"hipsparseSbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrilu02_bufferSize", {"hipsparseDbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrilu02_bufferSize", {"hipsparseCbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrilu02_bufferSize", {"hipsparseZbsrilu02_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsrilu02_analysis", {"hipsparseSbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrilu02_analysis", {"hipsparseDbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrilu02_analysis", {"hipsparseCbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrilu02_analysis", {"hipsparseZbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrilu02_analysis", {"hipsparseSbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrilu02_analysis", {"hipsparseDbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrilu02_analysis", {"hipsparseCbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrilu02_analysis", {"hipsparseZbsrilu02_analysis", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseSbsrilu02", {"hipsparseSbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseDbsrilu02", {"hipsparseDbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseCbsrilu02", {"hipsparseCbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseZbsrilu02", {"hipsparseZbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSbsrilu02", {"hipsparseSbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsrilu02", {"hipsparseDbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsrilu02", {"hipsparseCbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsrilu02", {"hipsparseZbsrilu02", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, - {"cusparseXbsrilu02_zeroPivot", {"hipsparseXbsrilu02_zeroPivot", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseXbsrilu02_zeroPivot", {"hipsparseXbsrilu02_zeroPivot", CONV_LIB_FUNC, API_SPARSE}}, + + // 10.3. Tridiagonal Solve + {"cusparseSgtsv", {"hipsparseSgtsv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsv", {"hipsparseDgtsv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsv", {"hipsparseCgtsv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsv", {"hipsparseZgtsv", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgtsv_nopivot", {"hipsparseSgtsv_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsv_nopivot", {"hipsparseDgtsv_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsv_nopivot", {"hipsparseCgtsv_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsv_nopivot", {"hipsparseZgtsv_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgtsv2_bufferSizeExt", {"hipsparseSgtsv2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsv2_bufferSizeExt", {"hipsparseDgtsv2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsv2_bufferSizeExt", {"hipsparseCgtsv2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsv2_bufferSizeExt", {"hipsparseZgtsv2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgtsv2", {"hipsparseSgtsv2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsv2", {"hipsparseDgtsv2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsv2", {"hipsparseCgtsv2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsv2", {"hipsparseZgtsv2", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgtsv2_nopivot_bufferSizeExt", {"hipsparseSgtsv2_nopivot_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsv2_nopivot_bufferSizeExt", {"hipsparseDgtsv2_nopivot_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsv2_nopivot_bufferSizeExt", {"hipsparseCgtsv2_nopivot_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsv2_nopivot_bufferSizeExt", {"hipsparseZgtsv2_nopivot_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgtsv2_nopivot", {"hipsparseSgtsv2_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsv2_nopivot", {"hipsparseDgtsv2_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsv2_nopivot", {"hipsparseCgtsv2_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsv2_nopivot", {"hipsparseZgtsv2_nopivot", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + // 10.4. Batched Tridiagonal Solve + {"cusparseSgtsvStridedBatch", {"hipsparseSgtsvStridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsvStridedBatch", {"hipsparseDgtsvStridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsvStridedBatch", {"hipsparseCgtsvStridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsvStridedBatch", {"hipsparseZgtsvStridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgtsv2StridedBatch_bufferSizeExt", {"hipsparseSgtsv2StridedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsv2StridedBatch_bufferSizeExt", {"hipsparseDgtsv2StridedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsv2StridedBatch_bufferSizeExt", {"hipsparseCgtsv2StridedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsv2StridedBatch_bufferSizeExt", {"hipsparseZgtsv2StridedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgtsv2StridedBatch", {"hipsparseSgtsv2StridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsv2StridedBatch", {"hipsparseDgtsv2StridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsv2StridedBatch", {"hipsparseCgtsv2StridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsv2StridedBatch", {"hipsparseZgtsv2StridedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgtsvInterleavedBatch_bufferSizeExt", {"hipsparseSgtsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsvInterleavedBatch_bufferSizeExt", {"hipsparseDgtsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsvInterleavedBatch_bufferSizeExt", {"hipsparseCgtsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsvInterleavedBatch_bufferSizeExt", {"hipsparseZgtsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgtsvInterleavedBatch", {"hipsparseSgtsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgtsvInterleavedBatch", {"hipsparseDgtsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgtsvInterleavedBatch", {"hipsparseCgtsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgtsvInterleavedBatch", {"hipsparseZgtsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + // 10.5. Batched Pentadiagonal Solve + {"cusparseSgpsvInterleavedBatch_bufferSizeExt", {"hipsparseSgpsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgpsvInterleavedBatch_bufferSizeExt", {"hipsparseDgpsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgpsvInterleavedBatch_bufferSizeExt", {"hipsparseCgpsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgpsvInterleavedBatch_bufferSizeExt", {"hipsparseZgpsvInterleavedBatch_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgpsvInterleavedBatch", {"hipsparseSgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgpsvInterleavedBatch", {"hipsparseDgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgpsvInterleavedBatch", {"hipsparseCgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgpsvInterleavedBatch", {"hipsparseZgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, }; diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_07.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_07.cu new file mode 100644 index 0000000000..371f836a5f --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_07.cu @@ -0,0 +1,302 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +#include +// CHECK: #include +#include +// CHECK: #include +#include + +void printCsr( + int m, + int n, + int nnz, + // CHECK: const hipsparseMatDescr_t descrA, + const cusparseMatDescr_t descrA, + const float *csrValA, + const int *csrRowPtrA, + const int *csrColIndA, + const char* name) +{ + // CHECK: const int base = (hipsparseGetMatIndexBase(descrA) != HIPSPARSE_INDEX_BASE_ONE) ? 0 : 1; + const int base = (cusparseGetMatIndexBase(descrA) != CUSPARSE_INDEX_BASE_ONE) ? 0 : 1; + + printf("matrix %s is %d-by-%d, nnz=%d, base=%d, output base-1\n", name, m, n, nnz, base); + for (int row = 0; row < m; row++) { + const int start = csrRowPtrA[row] - base; + const int end = csrRowPtrA[row + 1] - base; + for (int colidx = start; colidx < end; colidx++) { + const int col = csrColIndA[colidx] - base; + const float Areg = csrValA[colidx]; + printf("%s(%d,%d) = %f\n", name, row + 1, col + 1, Areg); + } + } +} + +int main(int argc, char*argv[]) +{ + // CHECK: hipsparseHandle_t handle = NULL; + cusparseHandle_t handle = NULL; + // CHECK: hipStream_t stream = NULL; + cudaStream_t stream = NULL; + // CHECK: hipsparseMatDescr_t descrA = NULL; + cusparseMatDescr_t descrA = NULL; + // CHECK: hipsparseMatDescr_t descrC = NULL; + cusparseMatDescr_t descrC = NULL; + pruneInfo_t info = NULL; + // CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS; + cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS; + // CHECK: hipError_t cudaStat1 = hipSuccess; + cudaError_t cudaStat1 = cudaSuccess; + const int m = 4; + const int n = 4; + const int nnzA = 9; + /* + * | 1 0 2 -3 | + * | 0 4 0 0 | + * A = | 5 0 6 7 | + * | 0 8 0 9 | + * + */ + + const int csrRowPtrA[m + 1] = { 1, 4, 5, 8, 10 }; + const int csrColIndA[nnzA] = { 1, 3, 4, 2, 1, 3, 4, 2, 4 }; + const float csrValA[nnzA] = { 1, 2, -3, 4, 5, 6, 7, 8, 9 }; + + int* csrRowPtrC = NULL; + int* csrColIndC = NULL; + float* csrValC = NULL; + + int *d_csrRowPtrA = NULL; + int *d_csrColIndA = NULL; + float *d_csrValA = NULL; + + int *d_csrRowPtrC = NULL; + int *d_csrColIndC = NULL; + float *d_csrValC = NULL; + + size_t lworkInBytes = 0; + char *d_work = NULL; + + int nnzC = 0; + + float percentage = 20; /* remove 20% of nonzeros */ + + printf("example of pruneCsr2csrByPercentage \n"); + + printf("prune %.1f percent of nonzeros \n", percentage); + + /* step 1: create cusparse handle, bind a stream */ + // CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); + cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: status = hipsparseCreate(&handle); + status = cusparseCreate(&handle); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: status = hipsparseSetStream(handle, stream); + status = cusparseSetStream(handle, stream); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // TODO: status = hipsparseCreatePruneInfo(&info); + status = cusparseCreatePruneInfo(&info); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + /* step 2: configuration of matrix C */ + // CHECK: status = hipsparseCreateMatDescr(&descrA); + status = cusparseCreateMatDescr(&descrA); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + /* A is base-1*/ + // CHECK: hipsparseSetMatIndexBase(descrA, HIPSPARSE_INDEX_BASE_ONE); + cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ONE); + // CHECK: hipsparseSetMatType(descrA, HIPSPARSE_MATRIX_TYPE_GENERAL); + cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL); + // CHECK: status = hipsparseCreateMatDescr(&descrC); + status = cusparseCreateMatDescr(&descrC); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + /* C is base-0 */ + // CHECK: hipsparseSetMatIndexBase(descrC, HIPSPARSE_INDEX_BASE_ZERO); + cusparseSetMatIndexBase(descrC, CUSPARSE_INDEX_BASE_ZERO); + // CHECK: hipsparseSetMatType(descrC, HIPSPARSE_MATRIX_TYPE_GENERAL); + cusparseSetMatType(descrC, CUSPARSE_MATRIX_TYPE_GENERAL); + + printCsr(m, n, nnzA, descrA, csrValA, csrRowPtrA, csrColIndA, "A"); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrRowPtrA, sizeof(int)*(m + 1)); + cudaStat1 = cudaMalloc((void**)&d_csrRowPtrA, sizeof(int)*(m + 1)); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA); + cudaStat1 = cudaMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrValA, sizeof(float)*nnzA); + cudaStat1 = cudaMalloc((void**)&d_csrValA, sizeof(float)*nnzA); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1)); + cudaStat1 = cudaMalloc((void**)&d_csrRowPtrC, sizeof(int)*(m + 1)); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(m + 1), hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(m + 1), cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 3: query workspace */ + // TODO: status = hipsparseSpruneCsr2csrByPercentage_bufferSizeExt( + status = cusparseSpruneCsr2csrByPercentage_bufferSizeExt( + handle, + m, + n, + nnzA, + descrA, + d_csrValA, + d_csrRowPtrA, + d_csrColIndA, + percentage, + descrC, + d_csrValC, + d_csrRowPtrC, + d_csrColIndC, + info, + &lworkInBytes); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + printf("lworkInBytes = %lld \n", (long long)lworkInBytes); + // CHECK: if (NULL != d_work) { hipFree(d_work); } + if (NULL != d_work) { cudaFree(d_work); } + // CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes); + cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 4: compute csrRowPtrC and nnzC */ + // TODO: status = hipsparseSpruneCsr2csrNnzByPercentage( + status = cusparseSpruneCsr2csrNnzByPercentage( + handle, + m, + n, + nnzA, + descrA, + d_csrValA, + d_csrRowPtrA, + d_csrColIndA, + percentage, + descrC, + d_csrRowPtrC, + &nnzC, /* host */ + info, + d_work); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + printf("nnzC = %d\n", nnzC); + if (0 == nnzC) { + printf("C is empty \n"); + return 0; + } + + /* step 5: compute csrColIndC and csrValC */ + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC); + cudaStat1 = cudaMalloc((void**)&d_csrColIndC, sizeof(int) * nnzC); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrValC, sizeof(float) * nnzC); + cudaStat1 = cudaMalloc((void**)&d_csrValC, sizeof(float) * nnzC); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // TODO: status = hipsparseSpruneCsr2csrByPercentage( + status = cusparseSpruneCsr2csrByPercentage( + handle, + m, + n, + nnzA, + descrA, + d_csrValA, + d_csrRowPtrA, + d_csrColIndA, + percentage, + descrC, + d_csrValC, + d_csrRowPtrC, + d_csrColIndC, + info, + d_work); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 6: output C */ + csrRowPtrC = (int*)malloc(sizeof(int)*(m + 1)); + csrColIndC = (int*)malloc(sizeof(int)*nnzC); + csrValC = (float*)malloc(sizeof(float)*nnzC); + assert(NULL != csrRowPtrC); + assert(NULL != csrColIndC); + assert(NULL != csrValC); + // CHECK: cudaStat1 = hipMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(csrRowPtrC, d_csrRowPtrC, sizeof(int)*(m + 1), cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(csrColIndC, d_csrColIndC, sizeof(int)*nnzC, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(csrValC, d_csrValC, sizeof(float)*nnzC, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + printCsr(m, n, nnzC, descrC, csrValC, csrRowPtrC, csrColIndC, "C"); + + /* free resources */ + // CHECK: if (d_csrRowPtrA) hipFree(d_csrRowPtrA); + if (d_csrRowPtrA) cudaFree(d_csrRowPtrA); + // CHECK: if (d_csrColIndA) hipFree(d_csrColIndA); + if (d_csrColIndA) cudaFree(d_csrColIndA); + // CHECK: if (d_csrValA) hipFree(d_csrValA); + if (d_csrValA) cudaFree(d_csrValA); + // CHECK: if (d_csrRowPtrC) hipFree(d_csrRowPtrC); + if (d_csrRowPtrC) cudaFree(d_csrRowPtrC); + // CHECK: if (d_csrColIndC) hipFree(d_csrColIndC); + if (d_csrColIndC) cudaFree(d_csrColIndC); + // CHECK: if (d_csrValC) hipFree(d_csrValC); + if (d_csrValC) cudaFree(d_csrValC); + + if (csrRowPtrC) free(csrRowPtrC); + if (csrColIndC) free(csrColIndC); + if (csrValC) free(csrValC); + // CHECK: if (handle) hipsparseDestroy(handle); + if (handle) cusparseDestroy(handle); + // CHECK: if (stream) hipStreamDestroy(stream); + if (stream) cudaStreamDestroy(stream); + // CHECK: if (descrA) hipsparseDestroyMatDescr(descrA); + if (descrA) cusparseDestroyMatDescr(descrA); + // CHECK: if (descrC) hipsparseDestroyMatDescr(descrC); + if (descrC) cusparseDestroyMatDescr(descrC); + // TODO: if (info) hipsparseDestroyPruneInfo(info); + if (info) cusparseDestroyPruneInfo(info); + // CHECK: hipDeviceReset(); + cudaDeviceReset(); + + return 0; +} From 909609773ca1587d32a816cafe5e62bc4e24d2d3 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Thu, 29 Nov 2018 11:35:00 -0500 Subject: [PATCH 46/55] Revert "Fix issue in kernarg metadata parsing due to early finalization" This reverts commit 19acf86ceff876ac03f2ace039b55c414c37fe17. --- src/program_state.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/program_state.cpp b/src/program_state.cpp index 2fda546b54..7e42a44245 100644 --- a/src/program_state.cpp +++ b/src/program_state.cpp @@ -590,16 +590,14 @@ unordered_map>>& kernargs() { static once_flag f; call_once(f, []() { - for (auto&& blobs_for_one_arch : code_object_blobs()) { - for (auto && blob : blobs_for_one_arch.second) { - stringstream tmp{std::string{ - blob.cbegin(), blob.cend()}}; + for (auto&& blob : code_object_blobs()) { + stringstream tmp{std::string{ + blob.second.front().cbegin(), blob.second.front().cend()}}; - elfio reader; - if (!reader.load(tmp)) continue; + elfio reader; + if (!reader.load(tmp)) continue; - read_kernarg_metadata(reader, r); - } + read_kernarg_metadata(reader, r); } }); From 8eb9b38e76b265aeaad3eca29aa77a1431e01e14 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Thu, 29 Nov 2018 11:38:31 -0500 Subject: [PATCH 47/55] Revert "Missing handling nullary `__global__` functions for mixed arity cases." This reverts commit 4ebc229b9ad496d3974641273eba4a5cb8a7af72. --- src/program_state.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/program_state.cpp b/src/program_state.cpp index 7e42a44245..97e9035e0d 100644 --- a/src/program_state.cpp +++ b/src/program_state.cpp @@ -409,18 +409,13 @@ void read_kernarg_metadata( auto fn = tmp.substr(dx, tmp.find_first_of("'\n", dx) - dx); dx += fn.size(); - - auto dx1 = tmp.find("CodeProps", dx); dx = tmp.find("Args:", dx); - if (dx1 < dx) { - dx = dx1; - continue; - } if (dx == string::npos) break; static constexpr decltype(tmp.size()) args_sz{5}; - dx = parse_args(tmp, dx + args_sz, dx1, kernargs[fn]); + dx = parse_args( + tmp, dx + args_sz, tmp.find("CodeProps", dx), kernargs[fn]); } while (true); } } From aeca2c8cdcef36ebd5dab47dc23aa3a8c6f65e12 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Thu, 29 Nov 2018 11:38:34 -0500 Subject: [PATCH 48/55] Revert "Handle (odd) corner case of argumentless __global__ function." This reverts commit c0bd1a5af8636d0c5d3fa52fcd20d8676c25ff39. --- include/hip/hcc_detail/functional_grid_launch.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/hip/hcc_detail/functional_grid_launch.hpp b/include/hip/hcc_detail/functional_grid_launch.hpp index 5edddad6c5..ba9929c0a6 100644 --- a/include/hip/hcc_detail/functional_grid_launch.hpp +++ b/include/hip/hcc_detail/functional_grid_launch.hpp @@ -102,8 +102,6 @@ inline std::vector make_kernarg( static_assert(sizeof...(Formals) == sizeof...(Actuals), "The count of formal arguments must match the count of actuals."); - if (sizeof...(Formals) == 0) return {}; - const auto it = function_names().find( reinterpret_cast(kernel)); From 09f87e41d948883878ea0602c94aabf593dafbf6 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Thu, 29 Nov 2018 11:38:35 -0500 Subject: [PATCH 49/55] Revert "If we've already seen a `__global__` function we do not need to re-parse" This reverts commit f7ba987038cafd7799c5ea5f5e347b7098a39d85. --- src/program_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/program_state.cpp b/src/program_state.cpp index 97e9035e0d..6b88da288e 100644 --- a/src/program_state.cpp +++ b/src/program_state.cpp @@ -347,7 +347,6 @@ size_t parse_args( size_t l, vector>& size_align) { if (f == l) return f; - if (!size_align.empty()) return l; do { static constexpr size_t size_sz{5}; @@ -596,6 +595,7 @@ unordered_map>>& kernargs() { } }); + for (auto&& x : r) std::cerr << x.first << std::endl; return r; } From 71189c10c19ff840dd4b08c4c971fa372d2f4a95 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Thu, 29 Nov 2018 11:38:36 -0500 Subject: [PATCH 50/55] Revert "Handle the very confusing dual encoding of the symbol name." This reverts commit bce3de81624d9b3d114074d87cb6defc353bd2cb. --- src/program_state.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/program_state.cpp b/src/program_state.cpp index 6b88da288e..b490c0ee25 100644 --- a/src/program_state.cpp +++ b/src/program_state.cpp @@ -404,10 +404,11 @@ void read_kernarg_metadata( if (dx == string::npos) break; static constexpr decltype(tmp.size()) name_sz{5}; - dx = tmp.find_first_not_of(" '", dx + name_sz); + dx = tmp.find_first_not_of(' ', dx + name_sz); - auto fn = tmp.substr(dx, tmp.find_first_of("'\n", dx) - dx); + auto fn = tmp.substr(dx, tmp.find('\n', dx) - dx); dx += fn.size(); + dx = tmp.find("Args:", dx); if (dx == string::npos) break; @@ -595,7 +596,6 @@ unordered_map>>& kernargs() { } }); - for (auto&& x : r) std::cerr << x.first << std::endl; return r; } From 1fbf6399620aededcd558e9ec630af50ecfd03bc Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Thu, 29 Nov 2018 11:38:37 -0500 Subject: [PATCH 51/55] Revert "Rely on code object metadat for kernarg arguments alignof and sizeof." This reverts commit fe1e963299c1f4b63652e91a3f156d8a043d317b. --- .../hip/hcc_detail/functional_grid_launch.hpp | 37 ++----- include/hip/hcc_detail/program_state.hpp | 2 - src/program_state.cpp | 102 +----------------- 3 files changed, 9 insertions(+), 132 deletions(-) diff --git a/include/hip/hcc_detail/functional_grid_launch.hpp b/include/hip/hcc_detail/functional_grid_launch.hpp index ba9929c0a6..e678f25aa2 100644 --- a/include/hip/hcc_detail/functional_grid_launch.hpp +++ b/include/hip/hcc_detail/functional_grid_launch.hpp @@ -33,7 +33,6 @@ THE SOFTWARE. #include #include -#include #include #include #include @@ -57,9 +56,7 @@ template < typename... Ts, typename std::enable_if::type* = nullptr> inline std::vector make_kernarg( - const std::tuple&, - const std::vector>&, - std::vector kernarg) { + std::vector kernarg, const std::tuple&) { return kernarg; } @@ -68,9 +65,7 @@ template < typename... Ts, typename std::enable_if::type* = nullptr> inline std::vector make_kernarg( - const std::tuple& formals, - const std::vector>& size_align, - std::vector kernarg) { + std::vector kernarg, const std::tuple& formals) { using T = typename std::tuple_element>::type; static_assert( @@ -85,42 +80,24 @@ inline std::vector make_kernarg( #endif kernarg.resize(round_up_to_next_multiple_nonnegative( - kernarg.size(), size_align[n].second) + - size_align[n].first); + kernarg.size(), alignof(T)) + sizeof(T)); - std::memcpy( - kernarg.data() + kernarg.size() - size_align[n].first, - &std::get(formals), - size_align[n].first); + new (kernarg.data() + kernarg.size() - sizeof(T)) T{std::get(formals)}; - return make_kernarg(formals, size_align, std::move(kernarg)); + return make_kernarg(std::move(kernarg), formals); } template inline std::vector make_kernarg( - void (*kernel)(Formals...), std::tuple actuals) { + void (*)(Formals...), std::tuple actuals) { static_assert(sizeof...(Formals) == sizeof...(Actuals), "The count of formal arguments must match the count of actuals."); - const auto it = function_names().find( - reinterpret_cast(kernel)); - - if (it == function_names().cend()) { - throw std::runtime_error{"Undefined __global__ function."}; - } - - const auto it1 = kernargs().find(it->second); - - if (it1 == kernargs().end()) { - throw std::runtime_error{ - "Missing metadata for __global__ function: " + it->second}; - } - std::tuple to_formals{std::move(actuals)}; std::vector kernarg; kernarg.reserve(sizeof(to_formals)); - return make_kernarg<0>(to_formals, it1->second, std::move(kernarg)); + return make_kernarg<0>(std::move(kernarg), to_formals); } void hipLaunchKernelGGLImpl(std::uintptr_t function_address, const dim3& numBlocks, diff --git a/include/hip/hcc_detail/program_state.hpp b/include/hip/hcc_detail/program_state.hpp index 92bef22172..bdb87b3509 100644 --- a/include/hip/hcc_detail/program_state.hpp +++ b/include/hip/hcc_detail/program_state.hpp @@ -99,8 +99,6 @@ const std::unordered_map& function_names(bool rebuild = false); std::unordered_map& globals(bool rebuild = false); -std::unordered_map< - std::string, std::vector>>& kernargs(); hsa_executable_t load_executable(const std::string& file, hsa_executable_t executable, hsa_agent_t agent); diff --git a/src/program_state.cpp b/src/program_state.cpp index b490c0ee25..88cdeeb404 100644 --- a/src/program_state.cpp +++ b/src/program_state.cpp @@ -312,8 +312,8 @@ const unordered_map>& kernels(bool rebui void load_code_object_and_freeze_executable( const string& file, hsa_agent_t agent, - hsa_executable_t executable) { - // TODO: the following sequence is inefficient, should be refactored + hsa_executable_t + executable) { // TODO: the following sequence is inefficient, should be refactored // into a single load of the file and subsequent ELFIO // processing. static const auto cor_deleter = [](hsa_code_object_reader_t* p) { @@ -340,85 +340,6 @@ void load_code_object_and_freeze_executable( code_readers.push_back(move(tmp)); } } - -size_t parse_args( - const string& metadata, - size_t f, - size_t l, - vector>& size_align) { - if (f == l) return f; - - do { - static constexpr size_t size_sz{5}; - f = metadata.find("Size:", f) + size_sz; - - if (l <= f) return f; - - auto size = strtoul(&metadata[f], nullptr, 10); - - static constexpr size_t align_sz{6}; - f = metadata.find("Align:", f) + align_sz; - - char* l{}; - auto align = strtoul(&metadata[f], &l, 10); - - f += (l - &metadata[f]) + 1; - - size_align.emplace_back(size, align); - } while (true); -} - -void read_kernarg_metadata( - elfio& reader, - unordered_map>>& kernargs) -{ // TODO: this is inefficient. - auto it = find_section_if( - reader, [](const section* x) { return x->get_type() == SHT_NOTE; }); - - if (!it) return; - - const note_section_accessor acc{reader, it}; - for (decltype(acc.get_notes_num()) i = 0; i != acc.get_notes_num(); ++i) { - ELFIO::Elf_Word type{}; - string name{}; - void* desc{}; - Elf_Word desc_size{}; - - acc.get_note(i, type, name, desc, desc_size); - - if (name != "AMD") continue; // TODO: switch to using NT_AMD_AMDGPU_HSA_METADATA. - - string tmp{ - static_cast(desc), static_cast(desc) + desc_size}; - - auto dx = tmp.find("Kernels:"); - - if (dx == string::npos) continue; - - static constexpr decltype(tmp.size()) kernels_sz{8}; - dx += kernels_sz; - - do { - dx = tmp.find("Name:", dx); - - if (dx == string::npos) break; - - static constexpr decltype(tmp.size()) name_sz{5}; - dx = tmp.find_first_not_of(' ', dx + name_sz); - - auto fn = tmp.substr(dx, tmp.find('\n', dx) - dx); - dx += fn.size(); - - dx = tmp.find("Args:", dx); - - if (dx == string::npos) break; - - static constexpr decltype(tmp.size()) args_sz{5}; - dx = parse_args( - tmp, dx + args_sz, tmp.find("CodeProps", dx), kernargs[fn]); - } while (true); - } -} } // namespace namespace hip_impl { @@ -580,25 +501,6 @@ unordered_map& globals(bool rebuild) { return r; } -unordered_map>>& kernargs() { - static unordered_map>> r; - static once_flag f; - - call_once(f, []() { - for (auto&& blob : code_object_blobs()) { - stringstream tmp{std::string{ - blob.second.front().cbegin(), blob.second.front().cend()}}; - - elfio reader; - if (!reader.load(tmp)) continue; - - read_kernarg_metadata(reader, r); - } - }); - - return r; -} - hsa_executable_t load_executable(const string& file, hsa_executable_t executable, hsa_agent_t agent) { elfio reader; From 116b9191f78b6a4d2d3b8c57238f9b1d255adb74 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 30 Nov 2018 15:33:57 +0300 Subject: [PATCH 52/55] [HIPIFY][SPARSE] Matrix Reorderings and Format Conversion Reference + cuSPARSE is supported up to CUDA 10.0 + cuSPARSE_08 test (CUDA 10.0) + update CUSPARSE_API_supported_by_HIP.md + lit: add a rule for CUDA 10.0 tests excluding --- .../markdown/CUSPARSE_API_supported_by_HIP.md | 156 +++++++ .../src/CUDA2HIP_SPARSE_API_functions.cpp | 190 ++++++++ tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu | 413 ++++++++++++++++++ tests/hipify-clang/lit.cfg | 4 + 4 files changed, 763 insertions(+) create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu diff --git a/docs/markdown/CUSPARSE_API_supported_by_HIP.md b/docs/markdown/CUSPARSE_API_supported_by_HIP.md index 0d0ded1406..f552246f11 100644 --- a/docs/markdown/CUSPARSE_API_supported_by_HIP.md +++ b/docs/markdown/CUSPARSE_API_supported_by_HIP.md @@ -300,6 +300,7 @@ |`cusparseScsrgeam` | | |`cusparseDcsrgeam` | | |`cusparseCcsrgeam` | | +|`cusparseZcsrgeam` | | |`cusparseScsrgeam2_bufferSizeExt` | | |`cusparseDcsrgeam2_bufferSizeExt` | | |`cusparseCcsrgeam2_bufferSizeExt` | | @@ -308,6 +309,7 @@ |`cusparseScsrgemm` | | |`cusparseDcsrgemm` | | |`cusparseCcsrgemm` | | +|`cusparseZcsrgemm` | | |`cusparseScsrgemm2_bufferSizeExt` | | |`cusparseDcsrgemm2_bufferSizeExt` | | |`cusparseCcsrgemm2_bufferSizeExt` | | @@ -460,3 +462,157 @@ |`cusparseDgpsvInterleavedBatch` | | |`cusparseCgpsvInterleavedBatch` | | |`cusparseZgpsvInterleavedBatch` | | + +## **8. cuSPARSE Matrix Reorderings Reference** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseScsrcolor` | | +|`cusparseDcsrcolor` | | +|`cusparseCcsrcolor` | | +|`cusparseZcsrcolor` | | + +## **9. cuSPARSE Format Conversion Reference** + +| **CUDA** | **HIP** | +|-----------------------------------------------------------|-------------------------------------------------| +|`cusparseSbsr2csr` | | +|`cusparseDbsr2csr` | | +|`cusparseCbsr2csr` | | +|`cusparseZbsr2csr` | | +|`cusparseSgebsr2gebsc_bufferSize` | | +|`cusparseDgebsr2gebsc_bufferSize` | | +|`cusparseCgebsr2gebsc_bufferSize` | | +|`cusparseZgebsr2gebsc_bufferSize` | | +|`cusparseSgebsr2gebsc` | | +|`cusparseDgebsr2gebsc` | | +|`cusparseCgebsr2gebsc` | | +|`cusparseZgebsr2gebsc` | | +|`cusparseSgebsr2gebsr_bufferSize` | | +|`cusparseDgebsr2gebsr_bufferSize` | | +|`cusparseCgebsr2gebsr_bufferSize` | | +|`cusparseZgebsr2gebsr_bufferSize` | | +|`cusparseXgebsr2gebsrNnz` | | +|`cusparseSgebsr2gebsr` | | +|`cusparseDgebsr2gebsr` | | +|`cusparseCgebsr2gebsr` | | +|`cusparseZgebsr2gebsr` | | +|`cusparseSgebsr2csr` | | +|`cusparseDgebsr2csr` | | +|`cusparseCgebsr2csr` | | +|`cusparseZgebsr2csr` | | +|`cusparseScsr2gebsr_bufferSize` | | +|`cusparseDcsr2gebsr_bufferSize` | | +|`cusparseCcsr2gebsr_bufferSize` | | +|`cusparseZcsr2gebsr_bufferSize` | | +|`cusparseXcsr2gebsrNnz` | | +|`cusparseScsr2gebsr` | | +|`cusparseDcsr2gebsr` | | +|`cusparseCcsr2gebsr` | | +|`cusparseZcsr2gebsr` | | +|`cusparseXcoo2csr` |`hipsparseXcoo2csr` | +|`cusparseScsc2dense` | | +|`cusparseDcsc2dense` | | +|`cusparseCcsc2dense` | | +|`cusparseZcsc2dense` | | +|`cusparseScsc2hyb` | | +|`cusparseDcsc2hyb` | | +|`cusparseCcsc2hyb` | | +|`cusparseZcsc2hyb` | | +|`cusparseXcsr2bsrNnz` | | +|`cusparseScsr2bsr` | | +|`cusparseDcsr2bsr` | | +|`cusparseCcsr2bsr` | | +|`cusparseZcsr2bsr` | | +|`cusparseXcsr2coo` |`hipsparseXcsr2coo` | +|`cusparseScsr2csc` |`hipsparseScsr2csc` | +|`cusparseDcsr2csc` |`hipsparseDcsr2csc` | +|`cusparseCcsr2csc` | | +|`cusparseZcsr2csc` | | +|`cusparseCsr2cscEx` | | +|`cusparseScsr2dense` | | +|`cusparseDcsr2dense` | | +|`cusparseCcsr2dense` | | +|`cusparseZcsr2dense` | | +|`cusparseScsr2csr_compress` | | +|`cusparseDcsr2csr_compress` | | +|`cusparseCcsr2csr_compress` | | +|`cusparseZcsr2csr_compress` | | +|`cusparseScsr2hyb` |`hipsparseScsr2hyb` | +|`cusparseDcsr2hyb` |`hipsparseDcsr2hyb` | +|`cusparseCcsr2hyb` | | +|`cusparseZcsr2hyb` | | +|`cusparseSdense2csc` | | +|`cusparseDdense2csc` | | +|`cusparseCdense2csc` | | +|`cusparseZdense2csc` | | +|`cusparseSdense2csr` | | +|`cusparseDdense2csr` | | +|`cusparseCdense2csr` | | +|`cusparseZdense2csr` | | +|`cusparseSdense2hyb` | | +|`cusparseDdense2hyb` | | +|`cusparseCdense2hyb` | | +|`cusparseZdense2hyb` | | +|`cusparseShyb2csc` | | +|`cusparseDhyb2csc` | | +|`cusparseChyb2csc` | | +|`cusparseZhyb2csc` | | +|`cusparseShyb2csr` | | +|`cusparseDhyb2csr` | | +|`cusparseChyb2csr` | | +|`cusparseZhyb2csr` | | +|`cusparseShyb2dense` | | +|`cusparseDhyb2dense` | | +|`cusparseChyb2dense` | | +|`cusparseZhyb2dense` | | +|`cusparseSnnz` | | +|`cusparseDnnz` | | +|`cusparseCnnz` | | +|`cusparseZnnz` | | +|`cusparseCreateIdentityPermutation` |`hipsparseCreateIdentityPermutation` | +|`cusparseXcoosort_bufferSizeExt` |`hipsparseXcoosort_bufferSizeExt` | +|`cusparseXcoosortByRow` |`hipsparseXcoosortByRow` | +|`cusparseXcoosortByColumn` |`hipsparseXcoosortByColumn` | +|`cusparseXcsrsort_bufferSizeExt` |`hipsparseXcsrsort_bufferSizeExt` | +|`cusparseXcsrsort` |`hipsparseXcsrsort` | +|`cusparseScusparseXcscsort_bufferSizeExtnnz` | | +|`cusparseXcscsort` | | +|`cusparseCreateCsru2csrInfo` | | +|`cusparseDestroyCsru2csrInfo` | | +|`cusparseScsru2csr_bufferSizeExt` | | +|`cusparseDcsru2csr_bufferSizeExt` | | +|`cusparseCcsru2csr_bufferSizeExt` | | +|`cusparseZcsru2csr_bufferSizeExt` | | +|`cusparseScsru2csr` | | +|`cusparseDcsru2csr` | | +|`cusparseCcsru2csr` | | +|`cusparseZcsru2csr` | | +|`cusparseHpruneDense2csr_bufferSizeExt` | | +|`cusparseSpruneDense2csr_bufferSizeExt` | | +|`cusparseDpruneDense2csr_bufferSizeExt` | | +|`cusparseHpruneDense2csrNnz` | | +|`cusparseSpruneDense2csrNnz` | | +|`cusparseDpruneDense2csrNnz` | | +|`cusparseHpruneCsr2csr_bufferSizeExt` | | +|`cusparseSpruneCsr2csr_bufferSizeExt` | | +|`cusparseDpruneCsr2csr_bufferSizeExt` | | +|`cusparseHpruneCsr2csrNnz` | | +|`cusparseSpruneCsr2csrNnz` | | +|`cusparseDpruneCsr2csrNnz` | | +|`cusparseHpruneDense2csrByPercentage_bufferSizeExt` | | +|`cusparseSpruneDense2csrByPercentage_bufferSizeExt` | | +|`cusparseDpruneDense2csrByPercentage_bufferSizeExt` | | +|`cusparseHpruneDense2csrNnzByPercentage` | | +|`cusparseSpruneDense2csrNnzByPercentage` | | +|`cusparseDpruneDense2csrNnzByPercentage` | | +|`cusparseHpruneCsr2csrByPercentage_bufferSizeExt` | | +|`cusparseSpruneCsr2csrByPercentage_bufferSizeExt` | | +|`cusparseDpruneCsr2csrByPercentage_bufferSizeExt` | | +|`cusparseHpruneCsr2csrNnzByPercentage` | | +|`cusparseSpruneCsr2csrNnzByPercentage` | | +|`cusparseDpruneCsr2csrNnzByPercentage` | | +|`cusparseSnnz_compress` | | +|`cusparseDnnz_compress` | | +|`cusparseCnnz_compress` | | +|`cusparseZnnz_compress` | | diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp index fdb1a8381c..f3b0f0eb99 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -245,6 +245,7 @@ const std::map CUDA_SPARSE_FUNCTION_MAP{ {"cusparseScsrgeam", {"hipsparseScsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseDcsrgeam", {"hipsparseDcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseCcsrgeam", {"hipsparseCcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrgeam", {"hipsparseZcsrgeam", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseScsrgeam2_bufferSizeExt", {"hipsparseScsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseDcsrgeam2_bufferSizeExt", {"hipsparseDcsrgeam2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, @@ -255,6 +256,7 @@ const std::map CUDA_SPARSE_FUNCTION_MAP{ {"cusparseScsrgemm", {"hipsparseScsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseDcsrgemm", {"hipsparseDcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseCcsrgemm", {"hipsparseCcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrgemm", {"hipsparseZcsrgemm", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseScsrgemm2_bufferSizeExt", {"hipsparseScsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseDcsrgemm2_bufferSizeExt", {"hipsparseDcsrgemm2_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, @@ -416,4 +418,192 @@ const std::map CUDA_SPARSE_FUNCTION_MAP{ {"cusparseDgpsvInterleavedBatch", {"hipsparseDgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseCgpsvInterleavedBatch", {"hipsparseCgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseZgpsvInterleavedBatch", {"hipsparseZgpsvInterleavedBatch", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + // 11. cuSPARSE Matrix Reorderings Reference + {"cusparseScsrcolor", {"hipsparseScsrcolor", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsrcolor", {"hipsparseDcsrcolor", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsrcolor", {"hipsparseCcsrcolor", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsrcolor", {"hipsparseZcsrcolor", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + // 12. cuSPARSE Format Conversion Reference + {"cusparseSbsr2csr", {"hipsparseSbsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDbsr2csr", {"hipsparseDbsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCbsr2csr", {"hipsparseCbsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZbsr2csr", {"hipsparseZbsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgebsr2gebsc_bufferSize", {"hipsparseSgebsr2gebsc_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgebsr2gebsc_bufferSize", {"hipsparseDgebsr2gebsc_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgebsr2gebsc_bufferSize", {"hipsparseCgebsr2gebsc_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgebsr2gebsc_bufferSize", {"hipsparseZgebsr2gebsc_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgebsr2gebsc", {"hipsparseSgebsr2gebsc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgebsr2gebsc", {"hipsparseDgebsr2gebsc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgebsr2gebsc", {"hipsparseCgebsr2gebsc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgebsr2gebsc", {"hipsparseZgebsr2gebsc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgebsr2gebsr_bufferSize", {"hipsparseSgebsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgebsr2gebsr_bufferSize", {"hipsparseDgebsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgebsr2gebsr_bufferSize", {"hipsparseCgebsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgebsr2gebsr_bufferSize", {"hipsparseZgebsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSgebsr2csr", {"hipsparseSgebsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgebsr2csr", {"hipsparseDgebsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgebsr2csr", {"hipsparseCgebsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgebsr2csr", {"hipsparseZgebsr2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXgebsr2gebsrNnz", {"hipsparseXgebsr2gebsrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSgebsr2gebsr", {"hipsparseSgebsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDgebsr2gebsr", {"hipsparseDgebsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCgebsr2gebsr", {"hipsparseCgebsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZgebsr2gebsr", {"hipsparseZgebsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsr2gebsr_bufferSize", {"hipsparseScsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsr2gebsr_bufferSize", {"hipsparseDcsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsr2gebsr_bufferSize", {"hipsparseCcsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsr2gebsr_bufferSize", {"hipsparseZcsr2gebsr_bufferSize", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXcsr2gebsrNnz", {"hipsparseXcsr2gebsrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsr2gebsr", {"hipsparseScsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsr2gebsr", {"hipsparseDcsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsr2gebsr", {"hipsparseCcsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsr2gebsr", {"hipsparseZcsr2gebsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXcoo2csr", {"hipsparseXcoo2csr", CONV_LIB_FUNC, API_SPARSE}}, + + {"cusparseScsc2dense", {"hipsparseScsc2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsc2dense", {"hipsparseDcsc2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsc2dense", {"hipsparseCcsc2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsc2dense", {"hipsparseZcsc2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsc2hyb", {"hipsparseScsc2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsc2hyb", {"hipsparseDcsc2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsc2hyb", {"hipsparseCcsc2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsc2hyb", {"hipsparseZcsc2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXcsr2bsrNnz", {"hipsparseXcsr2bsrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseScsr2bsr", {"hipsparseScsr2bsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsr2bsr", {"hipsparseDcsr2bsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsr2bsr", {"hipsparseCcsr2bsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsr2bsr", {"hipsparseZcsr2bsr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseXcsr2coo", {"hipsparseXcsr2coo", CONV_LIB_FUNC, API_SPARSE}}, + + {"cusparseScsr2csc", {"hipsparseScsr2csc", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsr2csc", {"hipsparseDcsr2csc", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsr2csc", {"hipsparseCcsr2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsr2csc", {"hipsparseZcsr2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseCsr2cscEx", {"hipsparseCsr2cscEx", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsr2dense", {"hipsparseScsr2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsr2dense", {"hipsparseDcsr2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsr2dense", {"hipsparseCcsr2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsr2dense", {"hipsparseZcsr2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsr2csr_compress", {"hipsparseScsr2csr_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsr2csr_compress", {"hipsparseDcsr2csr_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsr2csr_compress", {"hipsparseDcsr2csr_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsr2csr_compress", {"hipsparseZcsr2csr_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsr2hyb", {"hipsparseScsr2hyb", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseDcsr2hyb", {"hipsparseDcsr2hyb", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseCcsr2hyb", {"hipsparseCcsr2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsr2hyb", {"hipsparseZcsr2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSdense2csc", {"hipsparseSdense2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDdense2csc", {"hipsparseDdense2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCdense2csc", {"hipsparseCdense2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZdense2csc", {"hipsparseZdense2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSdense2csr", {"hipsparseSdense2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDdense2csr", {"hipsparseDdense2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCdense2csr", {"hipsparseCdense2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZdense2csr", {"hipsparseZdense2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSdense2hyb", {"hipsparseSdense2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDdense2hyb", {"hipsparseDdense2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCdense2hyb", {"hipsparseCdense2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZdense2hyb", {"hipsparseZdense2hyb", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseShyb2csc", {"hipsparseShyb2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDhyb2csc", {"hipsparseDhyb2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseChyb2csc", {"hipsparseChyb2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZhyb2csc", {"hipsparseZhyb2csc", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseShyb2csr", {"hipsparseShyb2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDhyb2csr", {"hipsparseDhyb2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseChyb2csr", {"hipsparseChyb2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZhyb2csr", {"hipsparseZhyb2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseShyb2dense", {"hipsparseShyb2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDhyb2dense", {"hipsparseDhyb2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseChyb2dense", {"hipsparseChyb2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZhyb2dense", {"hipsparseZhyb2dense", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSnnz", {"hipsparseSnnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDnnz", {"hipsparseDnnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCnnz", {"hipsparseCnnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZnnz", {"hipsparseZnnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseCreateIdentityPermutation", {"hipsparseCreateIdentityPermutation", CONV_LIB_FUNC, API_SPARSE}}, + + {"cusparseXcoosort_bufferSizeExt", {"hipsparseXcoosort_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseXcoosortByRow", {"hipsparseXcoosortByRow", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseXcoosortByColumn", {"hipsparseXcoosortByColumn", CONV_LIB_FUNC, API_SPARSE}}, + + {"cusparseXcsrsort_bufferSizeExt", {"hipsparseXcsrsort_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE}}, + {"cusparseXcsrsort", {"hipsparseXcsrsort", CONV_LIB_FUNC, API_SPARSE}}, + + {"cusparseScusparseXcscsort_bufferSizeExtnnz", {"hipsparseXcscsort_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseXcscsort", {"hipsparseXcscsort", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseCreateCsru2csrInfo", {"hipsparseCreateCsru2csrInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDestroyCsru2csrInfo", {"hipsparseDestroyCsru2csrInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsru2csr_bufferSizeExt", {"hipsparseScsru2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsru2csr_bufferSizeExt", {"hipsparseDcsru2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsru2csr_bufferSizeExt", {"hipsparseCcsru2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsru2csr_bufferSizeExt", {"hipsparseZcsru2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseScsru2csr", {"hipsparseScsru2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDcsru2csr", {"hipsparseDcsru2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCcsru2csr", {"hipsparseCcsru2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZcsru2csr", {"hipsparseZcsru2csr", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseHpruneDense2csr_bufferSizeExt", {"hipsparseHpruneDense2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSpruneDense2csr_bufferSizeExt", {"hipsparseSpruneDense2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDpruneDense2csr_bufferSizeExt", {"hipsparseDpruneDense2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseHpruneDense2csrNnz", {"hipsparseHpruneDense2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSpruneDense2csrNnz", {"hipsparseSpruneDense2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDpruneDense2csrNnz", {"hipsparseDpruneDense2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseHpruneCsr2csr_bufferSizeExt", {"hipsparseHpruneCsr2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSpruneCsr2csr_bufferSizeExt", {"hipsparseSpruneCsr2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDpruneCsr2csr_bufferSizeExt", {"hipsparseDpruneCsr2csr_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseHpruneCsr2csrNnz", {"hipsparseHpruneCsr2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSpruneCsr2csrNnz", {"hipsparseSpruneCsr2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDpruneCsr2csrNnz", {"hipsparseDpruneCsr2csrNnz", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseHpruneDense2csrByPercentage_bufferSizeExt", {"hipsparseHpruneDense2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSpruneDense2csrByPercentage_bufferSizeExt", {"hipsparseSpruneDense2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDpruneDense2csrByPercentage_bufferSizeExt", {"hipsparseDpruneDense2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseHpruneDense2csrNnzByPercentage", {"hipsparseHpruneDense2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSpruneDense2csrNnzByPercentage", {"hipsparseSpruneDense2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDpruneDense2csrNnzByPercentage", {"hipsparseDpruneDense2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseHpruneCsr2csrByPercentage_bufferSizeExt", {"hipsparseHpruneCsr2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSpruneCsr2csrByPercentage_bufferSizeExt", {"hipsparseSpruneCsr2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDpruneCsr2csrByPercentage_bufferSizeExt", {"hipsparseDpruneCsr2csrByPercentage_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseHpruneCsr2csrNnzByPercentage", {"hipsparseHpruneCsr2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseSpruneCsr2csrNnzByPercentage", {"hipsparseSpruneCsr2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDpruneCsr2csrNnzByPercentage", {"hipsparseDpruneCsr2csrNnzByPercentage", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + + {"cusparseSnnz_compress", {"hipsparseSnnz_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseDnnz_compress", {"hipsparseDnnz_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseCnnz_compress", {"hipsparseCnnz_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseZnnz_compress", {"hipsparseZnnz_compress", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, }; diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu new file mode 100644 index 0000000000..fcfde8d3b2 --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu @@ -0,0 +1,413 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +#include +// CHECK: #include +#include +// CHECK: #include +#include +// CHECK: #include +#include + +// NOTE: CUDA 10.0 + +/* + * compute | b - A*x|_inf + */ +void residaul_eval( + int n, + const float *dl, + const float *d, + const float *du, + const float *b, + const float *x, + float *r_nrminf_ptr) +{ + float r_nrminf = 0; + for (int i = 0; i < n; i++) { + float dot = 0; + if (i > 0) { + dot += dl[i] * x[i - 1]; + } + dot += d[i] * x[i]; + if (i < (n - 1)) { + dot += du[i] * x[i + 1]; + } + float ri = b[i] - dot; + r_nrminf = (r_nrminf > fabs(ri)) ? r_nrminf : fabs(ri); + } + + *r_nrminf_ptr = r_nrminf; +} + +int main(int argc, char*argv[]) +{ + // CHECK: hipsparseHandle_t cusparseH = NULL; + cusparseHandle_t cusparseH = NULL; + // CHECK: hipblasHandle_t cublasH = NULL; + cublasHandle_t cublasH = NULL; + // CHECK: hipStream_t stream = NULL; + cudaStream_t stream = NULL; + // CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS; + cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS; + // CHECK: hipblasStatus_t cublasStat = HIPBLAS_STATUS_SUCCESS; + cublasStatus_t cublasStat = CUBLAS_STATUS_SUCCESS; + // CHECK: hipError_t cudaStat1 = hipSuccess; + cudaError_t cudaStat1 = cudaSuccess; + + const int n = 3; + const int batchSize = 2; + /* + * | 1 6 0 | | 1 | | -0.603960 | + * A1 =| 4 2 7 |, b1 = | 2 |, x1 = | 0.267327 | + * | 0 5 3 | | 3 | | 0.554455 | + * + * | 8 13 0 | | 4 | | -0.063291 | + * A2 =| 11 9 14 |, b2 = | 5 |, x2 = | 0.346641 | + * | 0 12 10 | | 6 | | 0.184031 | + */ + + /* + * A = (dl, d, du), B and X are in aggregate format + */ + const float dl[n * batchSize] = { 0, 4, 5, 0, 11, 12 }; + const float d[n * batchSize] = { 1, 2, 3, 8, 9, 10 }; + const float du[n * batchSize] = { 6, 7, 0, 13, 14, 0 }; + const float B[n * batchSize] = { 1, 2, 3, 4, 5, 6 }; + float X[n * batchSize]; /* Xj = Aj \ Bj */ + +/* device memory + * (d_dl0, d_d0, d_du0) is aggregate format + * (d_dl, d_d, d_du) is interleaved format + */ + float *d_dl0 = NULL; + float *d_d0 = NULL; + float *d_du0 = NULL; + float *d_dl = NULL; + float *d_d = NULL; + float *d_du = NULL; + float *d_B = NULL; + float *d_X = NULL; + + size_t lworkInBytes = 0; + char *d_work = NULL; + + /* + * algo = 0: cuThomas (unstable) + * algo = 1: LU with pivoting (stable) + * algo = 2: QR (stable) + */ + const int algo = 2; + + const float h_one = 1; + const float h_zero = 0; + + printf("example of gtsv (interleaved format) \n"); + printf("choose algo = 0,1,2 to select different algorithms \n"); + printf("n = %d, batchSize = %d, algo = %d \n", n, batchSize, algo); + + /* step 1: create cusparse/cublas handle, bind a stream */ + // CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); + cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: status = hipsparseCreate(&cusparseH); + status = cusparseCreate(&cusparseH); + //CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: status = hipsparseSetStream(cusparseH, stream); + status = cusparseSetStream(cusparseH, stream); + //CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cublasStat = hipblasCreate(&cublasH); + cublasStat = cublasCreate(&cublasH); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + // CHECK: cublasStat = hipblasSetStream(cublasH, stream); + cublasStat = cublasSetStream(cublasH, stream); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + /* step 2: allocate device memory */ + // CHECK: cudaStat1 = hipMalloc((void**)&d_dl0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_dl0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_d0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_d0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_du0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_du0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_dl, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_dl, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_d, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_d, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_du, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_du, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_B, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_B, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_X, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_X, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 3: prepare data in device, interleaved format */ + // CHECK: cudaStat1 = hipMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_d0, d, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_d0, d, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_du0, du, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_du0, du, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_B, B, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_B, B, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: hipDeviceSynchronize(); + cudaDeviceSynchronize(); + /* convert dl to interleaved format + * dl = transpose(dl0) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of dl */ + n, /* number of columns of dl */ + &h_one, + d_dl0, /* dl0 is n-by-batchSize */ + n, /* leading dimension of dl0 */ + &h_zero, + NULL, + n, /* don't cae */ + d_dl, /* dl is batchSize-by-n */ + batchSize /* leading dimension of dl */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + /* convert d to interleaved format + * d = transpose(d0) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of d */ + n, /* number of columns of d */ + &h_one, + d_d0, /* d0 is n-by-batchSize */ + n, /* leading dimension of d0 */ + &h_zero, + NULL, + n, /* don't cae */ + d_d, /* d is batchSize-by-n */ + batchSize /* leading dimension of d */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + /* convert du to interleaved format + * du = transpose(du0) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of du */ + n, /* number of columns of du */ + &h_one, + d_du0, /* du0 is n-by-batchSize */ + n, /* leading dimension of du0 */ + &h_zero, + NULL, + n, /* don't cae */ + d_du, /* du is batchSize-by-n */ + batchSize /* leading dimension of du */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + /* convert B to interleaved format + * X = transpose(B) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of X */ + n, /* number of columns of X */ + &h_one, + d_B, /* B is n-by-batchSize */ + n, /* leading dimension of B */ + &h_zero, + NULL, + n, /* don't cae */ + d_X, /* X is batchSize-by-n */ + batchSize /* leading dimension of X */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + /* step 4: prepare workspace */ + // NOTE: CUDA 10.0 + // CHECK: status = hipsparseSgtsvInterleavedBatch_bufferSizeExt( + status = cusparseSgtsvInterleavedBatch_bufferSizeExt( + cusparseH, + algo, + n, + d_dl, + d_d, + d_du, + d_X, + batchSize, + &lworkInBytes); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + printf("lworkInBytes = %lld \n", (long long)lworkInBytes); + // CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes); + cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 5: solve Aj*xj = bj */ + // NOTE: CUDA 10.0 + // CHECK: status = hipsparseSgtsvInterleavedBatch( + status = cusparseSgtsvInterleavedBatch( + cusparseH, + algo, + n, + d_dl, + d_d, + d_du, + d_X, + batchSize, + d_work); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 6: convert X back to aggregate format */ + /* B = transpose(X) */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + n, /* number of rows of B */ + batchSize, /* number of columns of B */ + &h_one, + d_X, /* X is batchSize-by-n */ + batchSize, /* leading dimension of X */ + &h_zero, + NULL, + n, /* don't cae */ + d_B, /* B is n-by-batchSize */ + n /* leading dimension of B */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + // CHECK: hipDeviceSynchronize(); + cudaDeviceSynchronize(); + + /* step 7: residual evaluation */ + // CHECK: cudaStat1 = hipMemcpy(X, d_B, sizeof(float)*n*batchSize, hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(X, d_B, sizeof(float)*n*batchSize, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: hipDeviceSynchronize(); + cudaDeviceSynchronize(); + printf("==== x1 = inv(A1)*b1 \n"); + for (int j = 0; j < n; j++) { + printf("x1[%d] = %f\n", j, X[j]); + } + + float r1_nrminf; + residaul_eval( + n, + dl, + d, + du, + B, + X, + &r1_nrminf + ); + printf("|b1 - A1*x1| = %E\n", r1_nrminf); + + printf("\n==== x2 = inv(A2)*b2 \n"); + for (int j = 0; j < n; j++) { + printf("x2[%d] = %f\n", j, X[n + j]); + } + + float r2_nrminf; + residaul_eval( + n, + dl + n, + d + n, + du + n, + B + n, + X + n, + &r2_nrminf + ); + printf("|b2 - A2*x2| = %E\n", r2_nrminf); + + /* free resources */ + // CHECK: if (d_dl0) hipFree(d_dl0); + if (d_dl0) cudaFree(d_dl0); + // CHECK: if (d_d0) hipFree(d_d0); + if (d_d0) cudaFree(d_d0); + // CHECK: if (d_du0) hipFree(d_du0); + if (d_du0) cudaFree(d_du0); + // CHECK: if (d_dl) hipFree(d_dl); + if (d_dl) cudaFree(d_dl); + // CHECK: if (d_d) hipFree(d_d); + if (d_d) cudaFree(d_d); + // CHECK: if (d_du) hipFree(d_du); + if (d_du) cudaFree(d_du); + // CHECK: if (d_B) hipFree(d_B); + if (d_B) cudaFree(d_B); + // CHECK: if (d_X) hipFree(d_X); + if (d_X) cudaFree(d_X); + // CHECK: if (cusparseH) hipsparseDestroy(cusparseH); + if (cusparseH) cusparseDestroy(cusparseH); + // CHECK: if (cublasH) hipblasDestroy(cublasH); + if (cublasH) cublasDestroy(cublasH); + // CHECK: if (stream) hipStreamDestroy(stream); + if (stream) cudaStreamDestroy(stream); + // CHECK: hipDeviceReset(); + cudaDeviceReset(); + + return 0; +} diff --git a/tests/hipify-clang/lit.cfg b/tests/hipify-clang/lit.cfg index 98961fe166..b9ff0b2495 100644 --- a/tests/hipify-clang/lit.cfg +++ b/tests/hipify-clang/lit.cfg @@ -23,6 +23,10 @@ config.test_source_root = os.path.dirname(__file__) config.excludes = ['cmdparser.hpp'] +config.cuda_version = "@CUDA_VERSION@" +if config.cuda_version not in ['10.0']: + config.excludes.append('cuSPARSE_08.cu') + # test_exec_root: The path where tests are located (default is the test suite root). #config.test_exec_root = config.test_source_root From dc5b0a1fe00dfcf2814976d34b72c2efaa0783e4 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 3 Dec 2018 08:54:13 +0530 Subject: [PATCH 53/55] [ci] Add rocm-2.0.x to CI test infrastructure Change-Id: I7fc0c40d1bf50a90ce3e210f2c8e83d1f4bf6d5c --- Jenkinsfile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index e6b60f398e..1257bfb0b4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -340,6 +340,51 @@ parallel rocm_1_9: */ } }, +rocm_2_0: +{ + node('hip-rocm') + { + String hcc_ver = 'rocm-2.0.x' + String from_image = 'ci_test_nodes/rocm-2.0.x/ubuntu-16.04:latest' + String inside_args = '--device=/dev/kfd --device=/dev/dri --group-add=video' + + // Checkout source code, dependencies and version files + String source_hip_rel = checkout_and_version( hcc_ver ) + + // Create/reuse a docker image that represents the hip build environment + def hip_build_image = docker_build_image( hcc_ver, 'hip', '', source_hip_rel, from_image ) + + // Print system information for the log + hip_build_image.inside( inside_args ) + { + sh """#!/usr/bin/env bash + set -x + /opt/rocm/bin/rocm_agent_enumerator -t ALL + /opt/rocm/bin/hcc --version + """ + } + + // Conctruct a binary directory path based on build config + String build_hip_rel = build_directory_rel( build_config ); + + // Build hip inside of the build environment + docker_build_inside_image( hip_build_image, inside_args, hcc_ver, '', build_config, source_hip_rel, build_hip_rel ) + + // Clean docker build image + docker_clean_images( 'hip', docker_build_image_name( ) ) + + // After a successful build, upload a docker image of the results + /* + String hip_image_name = docker_upload_artifactory( hcc_ver, job_name, from_image, source_hip_rel, build_hip_rel ) + if( params.push_image_to_docker_hub ) + { + docker_upload_dockerhub( job_name, hip_image_name, 'rocm' ) + docker_clean_images( 'rocm', hip_image_name ) + } + docker_clean_images( job_name, hip_image_name ) + */ + } +}, rocm_head: { node('hip-rocm') From 72d40db35893c5c9d1346a8ceab606cfd473ba5b Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 4 Dec 2018 19:24:29 +0300 Subject: [PATCH 54/55] [HIPIFY][SPARSE] Add 3 more CUDA 10.0 tests + lit update + fix typos --- .../markdown/CUSPARSE_API_supported_by_HIP.md | 2 +- .../src/CUDA2HIP_SPARSE_API_functions.cpp | 2 +- tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu | 6 +- tests/hipify-clang/cuSPARSE/cuSPARSE_09.cu | 414 ++++++++++++++ tests/hipify-clang/cuSPARSE/cuSPARSE_10.cu | 507 ++++++++++++++++++ tests/hipify-clang/cuSPARSE/cuSPARSE_11.cu | 327 +++++++++++ tests/hipify-clang/lit.cfg | 3 + 7 files changed, 1256 insertions(+), 5 deletions(-) create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_09.cu create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_10.cu create mode 100644 tests/hipify-clang/cuSPARSE/cuSPARSE_11.cu diff --git a/docs/markdown/CUSPARSE_API_supported_by_HIP.md b/docs/markdown/CUSPARSE_API_supported_by_HIP.md index f552246f11..4dadea2c93 100644 --- a/docs/markdown/CUSPARSE_API_supported_by_HIP.md +++ b/docs/markdown/CUSPARSE_API_supported_by_HIP.md @@ -576,7 +576,7 @@ |`cusparseXcoosortByColumn` |`hipsparseXcoosortByColumn` | |`cusparseXcsrsort_bufferSizeExt` |`hipsparseXcsrsort_bufferSizeExt` | |`cusparseXcsrsort` |`hipsparseXcsrsort` | -|`cusparseScusparseXcscsort_bufferSizeExtnnz` | | +|`cusparseXcscsort_bufferSizeExt` | | |`cusparseXcscsort` | | |`cusparseCreateCsru2csrInfo` | | |`cusparseDestroyCsru2csrInfo` | | diff --git a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp index f3b0f0eb99..29726a5048 100644 --- a/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp +++ b/hipify-clang/src/CUDA2HIP_SPARSE_API_functions.cpp @@ -554,7 +554,7 @@ const std::map CUDA_SPARSE_FUNCTION_MAP{ {"cusparseXcsrsort_bufferSizeExt", {"hipsparseXcsrsort_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE}}, {"cusparseXcsrsort", {"hipsparseXcsrsort", CONV_LIB_FUNC, API_SPARSE}}, - {"cusparseScusparseXcscsort_bufferSizeExtnnz", {"hipsparseXcscsort_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, + {"cusparseXcscsort_bufferSizeExt", {"hipsparseXcscsort_bufferSizeExt", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseXcscsort", {"hipsparseXcscsort", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, {"cusparseCreateCsru2csrInfo", {"hipsparseCreateCsru2csrInfo", CONV_LIB_FUNC, API_SPARSE, HIP_UNSUPPORTED}}, diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu index fcfde8d3b2..cf788c8f33 100644 --- a/tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu @@ -277,8 +277,8 @@ int main(int argc, char*argv[]) assert(CUBLAS_STATUS_SUCCESS == cublasStat); /* step 4: prepare workspace */ // NOTE: CUDA 10.0 - // CHECK: status = hipsparseSgtsvInterleavedBatch_bufferSizeExt( - status = cusparseSgtsvInterleavedBatch_bufferSizeExt( + // TODO: status = hipsparseSgtsvInterleavedBatch_bufferSizeExt( + status = cusparseSgtsvInterleavedBatch_bufferSizeExt( cusparseH, algo, n, @@ -299,7 +299,7 @@ int main(int argc, char*argv[]) /* step 5: solve Aj*xj = bj */ // NOTE: CUDA 10.0 - // CHECK: status = hipsparseSgtsvInterleavedBatch( + // TODO: status = hipsparseSgtsvInterleavedBatch( status = cusparseSgtsvInterleavedBatch( cusparseH, algo, diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_09.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_09.cu new file mode 100644 index 0000000000..9b1aaf623f --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_09.cu @@ -0,0 +1,414 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +#include +// CHECK: #include +#include +// CHECK: #include +#include +// CHECK: #include +#include + +// NOTE: CUDA 10.0 + +/* + * compute | b - A*x|_inf + */ +void residaul_eval( + int n, + const float *dl, + const float *d, + const float *du, + const float *b, + const float *x, + float *r_nrminf_ptr) +{ + float r_nrminf = 0; + for (int i = 0; i < n; i++) { + float dot = 0; + if (i > 0) { + dot += dl[i] * x[i - 1]; + } + dot += d[i] * x[i]; + if (i < (n - 1)) { + dot += du[i] * x[i + 1]; + } + float ri = b[i] - dot; + r_nrminf = (r_nrminf > fabs(ri)) ? r_nrminf : fabs(ri); + } + + *r_nrminf_ptr = r_nrminf; +} + +int main(int argc, char*argv[]) +{ + // CHECK: hipsparseHandle_t cusparseH = NULL; + cusparseHandle_t cusparseH = NULL; + // CHECK: hipblasHandle_t cublasH = NULL; + cublasHandle_t cublasH = NULL; + // CHECK: hipStream_t stream = NULL; + cudaStream_t stream = NULL; + // CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS; + cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS; + // CHECK: hipblasStatus_t cublasStat = HIPBLAS_STATUS_SUCCESS; + cublasStatus_t cublasStat = CUBLAS_STATUS_SUCCESS; + // CHECK: hipError_t cudaStat1 = hipSuccess; + cudaError_t cudaStat1 = cudaSuccess; + + const int n = 3; + const int batchSize = 2; + /* + * | 1 6 0 | | 1 | | -0.603960 | + * A1 =| 4 2 7 |, b1 = | 2 |, x1 = | 0.267327 | + * | 0 5 3 | | 3 | | 0.554455 | + * + * | 8 13 0 | | 4 | | -0.063291 | + * A2 =| 11 9 14 |, b2 = | 5 |, x2 = | 0.346641 | + * | 0 12 10 | | 6 | | 0.184031 | + */ + + /* + * A = (dl, d, du), B and X are in aggregate format + */ + const float dl[n * batchSize] = { 0, 4, 5, 0, 11, 12 }; + const float d[n * batchSize] = { 1, 2, 3, 8, 9, 10 }; + const float du[n * batchSize] = { 6, 7, 0, 13, 14, 0 }; + const float B[n * batchSize] = { 1, 2, 3, 4, 5, 6 }; + float X[n * batchSize]; /* Xj = Aj \ Bj */ + +/* device memory + * (d_dl0, d_d0, d_du0) is aggregate format + * (d_dl, d_d, d_du) is interleaved format + */ + float *d_dl0 = NULL; + float *d_d0 = NULL; + float *d_du0 = NULL; + float *d_dl = NULL; + float *d_d = NULL; + float *d_du = NULL; + float *d_B = NULL; + float *d_X = NULL; + + size_t lworkInBytes = 0; + char *d_work = NULL; + + /* + * algo = 0: cuThomas (unstable) + * algo = 1: LU with pivoting (stable) + * algo = 2: QR (stable) + */ + const int algo = 2; + + const float h_one = 1; + const float h_zero = 0; + + printf("example of gtsv (interleaved format) \n"); + printf("choose algo = 0,1,2 to select different algorithms \n"); + printf("n = %d, batchSize = %d, algo = %d \n", n, batchSize, algo); + + /* step 1: create cusparse/cublas handle, bind a stream */ + // CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); + cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: status = hipsparseCreate(&cusparseH); + status = cusparseCreate(&cusparseH); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: status = hipsparseSetStream(cusparseH, stream); + status = cusparseSetStream(cusparseH, stream); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cublasStat = hipblasCreate(&cublasH); + cublasStat = cublasCreate(&cublasH); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + // CHECK: cublasStat = hipblasSetStream(cublasH, stream); + cublasStat = cublasSetStream(cublasH, stream); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + /* step 2: allocate device memory */ + // CHECK: cudaStat1 = hipMalloc((void**)&d_dl0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_dl0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_d0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_d0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_du0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_du0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_dl, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_dl, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_d, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_d, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_du, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_du, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_B, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_B, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_X, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_X, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 3: prepare data in device, interleaved format */ + // CHECK: cudaStat1 = hipMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_d0, d, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_d0, d, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_du0, du, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_du0, du, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_B, B, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_B, B, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: hipDeviceSynchronize(); + cudaDeviceSynchronize(); + /* convert dl to interleaved format + * dl = transpose(dl0) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of dl */ + n, /* number of columns of dl */ + &h_one, + d_dl0, /* dl0 is n-by-batchSize */ + n, /* leading dimension of dl0 */ + &h_zero, + NULL, + n, /* don't care */ + d_dl, /* dl is batchSize-by-n */ + batchSize /* leading dimension of dl */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + /* convert d to interleaved format + * d = transpose(d0) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T + // CHECK: HIPBLAS_OP_T + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of d */ + n, /* number of columns of d */ + &h_one, + d_d0, /* d0 is n-by-batchSize */ + n, /* leading dimension of d0 */ + &h_zero, + NULL, + n, /* don't cae */ + d_d, /* d is batchSize-by-n */ + batchSize /* leading dimension of d */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + /* convert du to interleaved format + * du = transpose(du0) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T + // CHECK: HIPBLAS_OP_T + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of du */ + n, /* number of columns of du */ + &h_one, + d_du0, /* du0 is n-by-batchSize */ + n, /* leading dimension of du0 */ + &h_zero, + NULL, + n, /* don't cae */ + d_du, /* du is batchSize-by-n */ + batchSize /* leading dimension of du */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + /* convert B to interleaved format + * X = transpose(B) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T + // CHECK: HIPBLAS_OP_T + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of X */ + n, /* number of columns of X */ + &h_one, + d_B, /* B is n-by-batchSize */ + n, /* leading dimension of B */ + &h_zero, + NULL, + n, /* don't cae */ + d_X, /* X is batchSize-by-n */ + batchSize /* leading dimension of X */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + /* step 4: prepare workspace */ + // NOTE: CUDA 10.0 + // TODO: status = hipsparseSgtsvInterleavedBatch_bufferSizeExt( + status = cusparseSgtsvInterleavedBatch_bufferSizeExt( + cusparseH, + algo, + n, + d_dl, + d_d, + d_du, + d_X, + batchSize, + &lworkInBytes); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + printf("lworkInBytes = %lld \n", (long long)lworkInBytes); + // CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes); + cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 5: solve Aj*xj = bj */ + // NOTE: CUDA 10.0 + // TODO: status = hipsparseSgtsvInterleavedBatch( + status = cusparseSgtsvInterleavedBatch( + cusparseH, + algo, + n, + d_dl, + d_d, + d_du, + d_X, + batchSize, + d_work); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 6: convert X back to aggregate format */ + /* B = transpose(X) */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T + // CHECK: HIPBLAS_OP_T + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + n, /* number of rows of B */ + batchSize, /* number of columns of B */ + &h_one, + d_X, /* X is batchSize-by-n */ + batchSize, /* leading dimension of X */ + &h_zero, + NULL, + n, /* don't cae */ + d_B, /* B is n-by-batchSize */ + n /* leading dimension of B */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + // CHECK: hipDeviceSynchronize(); + cudaDeviceSynchronize(); + + /* step 7: residual evaluation */ + // CHECK: cudaStat1 = hipMemcpy(X, d_B, sizeof(float)*n*batchSize, hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(X, d_B, sizeof(float)*n*batchSize, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: hipDeviceSynchronize(); + cudaDeviceSynchronize(); + + printf("==== x1 = inv(A1)*b1 \n"); + for (int j = 0; j < n; j++) { + printf("x1[%d] = %f\n", j, X[j]); + } + + float r1_nrminf; + residaul_eval( + n, + dl, + d, + du, + B, + X, + &r1_nrminf + ); + printf("|b1 - A1*x1| = %E\n", r1_nrminf); + + printf("\n==== x2 = inv(A2)*b2 \n"); + for (int j = 0; j < n; j++) { + printf("x2[%d] = %f\n", j, X[n + j]); + } + + float r2_nrminf; + residaul_eval( + n, + dl + n, + d + n, + du + n, + B + n, + X + n, + &r2_nrminf + ); + printf("|b2 - A2*x2| = %E\n", r2_nrminf); + + /* free resources */ + // CHECK: if (d_dl0) hipFree(d_dl0); + if (d_dl0) cudaFree(d_dl0); + // CHECK: if (d_d0) hipFree(d_d0); + if (d_d0) cudaFree(d_d0); + // CHECK: if (d_du0) hipFree(d_du0); + if (d_du0) cudaFree(d_du0); + // CHECK: if (d_dl) hipFree(d_dl); + if (d_dl) cudaFree(d_dl); + // CHECK: if (d_d) hipFree(d_d); + if (d_d) cudaFree(d_d); + // CHECK: if (d_du) hipFree(d_du); + if (d_du) cudaFree(d_du); + // CHECK: if (d_B) hipFree(d_B); + if (d_B) cudaFree(d_B); + // CHECK: if (d_X) hipFree(d_X); + if (d_X) cudaFree(d_X); + // CHECK: if (cusparseH) hipsparseDestroy(cusparseH); + if (cusparseH) cusparseDestroy(cusparseH); + // CHECK: if (cublasH) hipblasDestroy(cublasH); + if (cublasH) cublasDestroy(cublasH); + // CHECK: if (stream) hipStreamDestroy(stream); + if (stream) cudaStreamDestroy(stream); + // CHECK: hipDeviceReset(); + cudaDeviceReset(); + + return 0; +} diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_10.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_10.cu new file mode 100644 index 0000000000..326c231de4 --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_10.cu @@ -0,0 +1,507 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +#include +// CHECK: #include +#include +// CHECK: #include +#include +// CHECK: #include +#include + +// NOTE: CUDA 10.0 + +/* + * compute | b - A*x|_inf + */ +void residaul_eval( + int n, + const float *ds, + const float *dl, + const float *d, + const float *du, + const float *dw, + const float *b, + const float *x, + float *r_nrminf_ptr) +{ + float r_nrminf = 0; + for (int i = 0; i < n; i++) { + float dot = 0; + if (i > 1) { + dot += ds[i] * x[i - 2]; + } + if (i > 0) { + dot += dl[i] * x[i - 1]; + } + dot += d[i] * x[i]; + if (i < (n - 1)) { + dot += du[i] * x[i + 1]; + } + if (i < (n - 2)) { + dot += dw[i] * x[i + 2]; + } + float ri = b[i] - dot; + r_nrminf = (r_nrminf > fabs(ri)) ? r_nrminf : fabs(ri); + } + + *r_nrminf_ptr = r_nrminf; +} + +int main(int argc, char*argv[]) +{ + // CHECK: hipsparseHandle_t cusparseH = NULL; + cusparseHandle_t cusparseH = NULL; + // CHECK: hipblasHandle_t cublasH = NULL; + cublasHandle_t cublasH = NULL; + // CHECK: hipStream_t stream = NULL; + cudaStream_t stream = NULL; + // CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS; + cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS; + // CHECK: hipblasStatus_t cublasStat = HIPBLAS_STATUS_SUCCESS; + cublasStatus_t cublasStat = CUBLAS_STATUS_SUCCESS; + // CHECK: hipError_t cudaStat1 = hipSuccess; + cudaError_t cudaStat1 = cudaSuccess; + + const int n = 4; + const int batchSize = 2; + + /* + * | 1 8 13 0 | | 1 | | -0.0592 | + * A1 =| 5 2 9 14 |, b1 = | 2 |, x1 = | 0.3428 | + * | 11 6 3 10 | | 3 | | -0.1295 | + * | 0 12 7 4 | | 4 | | 0.1982 | + * + * | 15 22 27 0 | | 5 | | -0.0012 | + * A2 =| 19 16 23 28 |, b2 = | 6 |, x2 = | 0.2792 | + * | 25 20 17 24 | | 7 | | -0.0416 | + * | 0 26 21 18 | | 8 | | 0.0898 | + */ + + /* + * A = (ds, dl, d, du, dw), B and X are in aggregate format + */ + const float ds[n * batchSize] = { 0, 0, 11, 12, 0, 0, 25, 26 }; + const float dl[n * batchSize] = { 0, 5, 6, 7, 0, 19, 20, 21 }; + const float d[n * batchSize] = { 1, 2, 3, 4, 15, 16, 17, 18 }; + const float du[n * batchSize] = { 8, 9, 10, 0, 22, 23, 24, 0 }; + const float dw[n * batchSize] = { 13,14, 0, 0, 27, 28, 0, 0 }; + const float B[n * batchSize] = { 1, 2, 3, 4, 5, 6, 7, 8 }; + float X[n * batchSize]; /* Xj = Aj \ Bj */ + +/* device memory + * (d_ds0, d_dl0, d_d0, d_du0, d_dw0) is aggregate format + * (d_ds, d_dl, d_d, d_du, d_dw) is interleaved format + */ + float *d_ds0 = NULL; + float *d_dl0 = NULL; + float *d_d0 = NULL; + float *d_du0 = NULL; + float *d_dw0 = NULL; + float *d_ds = NULL; + float *d_dl = NULL; + float *d_d = NULL; + float *d_du = NULL; + float *d_dw = NULL; + float *d_B = NULL; + float *d_X = NULL; + + size_t lworkInBytes = 0; + char *d_work = NULL; + + const float h_one = 1; + const float h_zero = 0; + + int algo = 0; /* QR factorization */ + + printf("example of gpsv (interleaved format) \n"); + printf("n = %d, batchSize = %d\n", n, batchSize); + + /* step 1: create cusparse/cublas handle, bind a stream */ + // CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); + cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: status = hipsparseCreate(&cusparseH); + status = cusparseCreate(&cusparseH); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: status = hipsparseSetStream(cusparseH, stream); + status = cusparseSetStream(cusparseH, stream); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cublasStat = hipblasCreate(&cublasH); + cublasStat = cublasCreate(cublasH); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + // CHECK: cublasStat = hipblasSetStream(cublasH, stream); + cublasStat = cublasSetStream(cublasH, stream); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + /* step 2: allocate device memory */ + // CHECK: cudaStat1 = hipMalloc((void**)&d_ds0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_ds0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_dl0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_dl0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_d0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_d0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_du0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_du0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_dw0, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_dw0, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_ds, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_ds, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_dl, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_dl, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_d, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_d, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_du, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_du, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_dw, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_dw, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_B, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_B, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_X, sizeof(float)*n*batchSize); + cudaStat1 = cudaMalloc((void**)&d_X, sizeof(float)*n*batchSize); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + /* step 3: prepare data in device, interleaved format */ + // CHECK: cudaStat1 = hipMemcpy(d_ds0, ds, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_ds0, ds, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_dl0, dl, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_d0, d, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_d0, d, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_du0, du, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_du0, du, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_dw0, dw, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_dw0, dw, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_B, B, sizeof(float)*n*batchSize, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_B, B, sizeof(float)*n*batchSize, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: hipDeviceSynchronize(); + cudaDeviceSynchronize(); + /* convert ds to interleaved format + * ds = transpose(ds0) */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of ds */ + n, /* number of columns of ds */ + &h_one, + d_ds0, /* ds0 is n-by-batchSize */ + n, /* leading dimension of ds0 */ + &h_zero, + NULL, + n, /* don't cae */ + d_ds, /* ds is batchSize-by-n */ + batchSize); /* leading dimension of ds */ + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + /* convert dl to interleaved format + * dl = transpose(dl0) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of dl */ + n, /* number of columns of dl */ + &h_one, + d_dl0, /* dl0 is n-by-batchSize */ + n, /* leading dimension of dl0 */ + &h_zero, + NULL, + n, /* don't cae */ + d_dl, /* dl is batchSize-by-n */ + batchSize /* leading dimension of dl */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + /* convert d to interleaved format + * d = transpose(d0) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of d */ + n, /* number of columns of d */ + &h_one, + d_d0, /* d0 is n-by-batchSize */ + n, /* leading dimension of d0 */ + &h_zero, + NULL, + n, /* don't cae */ + d_d, /* d is batchSize-by-n */ + batchSize /* leading dimension of d */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + /* convert du to interleaved format + * du = transpose(du0) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of du */ + n, /* number of columns of du */ + &h_one, + d_du0, /* du0 is n-by-batchSize */ + n, /* leading dimension of du0 */ + &h_zero, + NULL, + n, /* don't cae */ + d_du, /* du is batchSize-by-n */ + batchSize /* leading dimension of du */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + /* convert dw to interleaved format + * dw = transpose(dw0) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of dw */ + n, /* number of columns of dw */ + &h_one, + d_dw0, /* dw0 is n-by-batchSize */ + n, /* leading dimension of dw0 */ + &h_zero, + NULL, + n, /* don't cae */ + d_dw, /* dw is batchSize-by-n */ + batchSize /* leading dimension of dw */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + /* convert B to interleaved format + * X = transpose(B) + */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + batchSize, /* number of rows of X */ + n, /* number of columns of X */ + &h_one, + d_B, /* B is n-by-batchSize */ + n, /* leading dimension of B */ + &h_zero, + NULL, + n, /* don't cae */ + d_X, /* X is batchSize-by-n */ + batchSize /* leading dimension of X */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + + /* step 4: prepare workspace */ + // NOTE: CUDA 10.0 + // TODO: status = hipsparseSgpsvInterleavedBatch_bufferSizeExt( + status = cusparseSgpsvInterleavedBatch_bufferSizeExt( + cusparseH, + algo, + n, + d_ds, + d_dl, + d_d, + d_du, + d_dw, + d_X, + batchSize, + &lworkInBytes); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + printf("lworkInBytes = %lld \n", (long long)lworkInBytes); + // CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes); + cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + /* step 5: solve Aj*xj = bj */ + // NOTE: CUDA 10.0 + // TODO: status = hipsparseSgpsvInterleavedBatch( + status = cusparseSgpsvInterleavedBatch( + cusparseH, + algo, + n, + d_ds, + d_dl, + d_d, + d_du, + d_dw, + d_X, + batchSize, + d_work); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 6: convert X back to aggregate format */ + /* B = transpose(X) */ + // CHECK: cublasStat = hipblasSgeam( + // CHECK: HIPBLAS_OP_T, + // CHECK: HIPBLAS_OP_T, + cublasStat = cublasSgeam( + cublasH, + CUBLAS_OP_T, /* transa */ + CUBLAS_OP_T, /* transb, don't care */ + n, /* number of rows of B */ + batchSize, /* number of columns of B */ + &h_one, + d_X, /* X is batchSize-by-n */ + batchSize, /* leading dimension of X */ + &h_zero, + NULL, + n, /* don't cae */ + d_B, /* B is n-by-batchSize */ + n /* leading dimension of B */ + ); + // CHECK: assert(HIPBLAS_STATUS_SUCCESS == cublasStat); + assert(CUBLAS_STATUS_SUCCESS == cublasStat); + // CHECK: hipDeviceSynchronize(); + cudaDeviceSynchronize(); + + /* step 7: residual evaluation */ + // CHECK: cudaStat1 = hipMemcpy(X, d_B, sizeof(float)*n*batchSize, hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(X, d_B, sizeof(float)*n*batchSize, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: hipDeviceSynchronize(); + cudaDeviceSynchronize(); + + printf("==== x1 = inv(A1)*b1 \n"); + for (int j = 0; j < n; j++) { + printf("x1[%d] = %f\n", j, X[j]); + } + + float r1_nrminf; + residaul_eval( + n, + ds, + dl, + d, + du, + dw, + B, + X, + &r1_nrminf + ); + printf("|b1 - A1*x1| = %E\n", r1_nrminf); + printf("\n==== x2 = inv(A2)*b2 \n"); + for (int j = 0; j < n; j++) { + printf("x2[%d] = %f\n", j, X[n + j]); + } + + float r2_nrminf; + residaul_eval( + n, + ds + n, + dl + n, + d + n, + du + n, + dw + n, + B + n, + X + n, + &r2_nrminf + ); + printf("|b2 - A2*x2| = %E\n", r2_nrminf); + + /* free resources */ + // CHECK: if (d_ds0) hipFree(d_ds0); + if (d_ds0) cudaFree(d_ds0); + // CHECK: if (d_dl0) hipFree(d_dl0); + if (d_dl0) cudaFree(d_dl0); + // CHECK: if (d_d0) hipFree(d_d0); + if (d_d0) cudaFree(d_d0); + // CHECK: if (d_du0) hipFree(d_du0); + if (d_du0) cudaFree(d_du0); + // CHECK: if (d_dw0) hipFree(d_dw0); + if (d_dw0) cudaFree(d_dw0); + // CHECK: if (d_ds) hipFree(d_ds); + if (d_ds) cudaFree(d_ds); + // CHECK: if (d_dl) hipFree(d_dl); + if (d_dl) cudaFree(d_dl); + // CHECK: if (d_d) hipFree(d_d); + if (d_d) cudaFree(d_d); + // CHECK: if (d_du) hipFree(d_du); + if (d_du) cudaFree(d_du); + // CHECK: if (d_dw) hipFree(d_dw); + if (d_dw) cudaFree(d_dw); + // CHECK: if (d_B) hipFree(d_B); + if (d_B) cudaFree(d_B); + // CHECK: if (d_X) hipFree(d_X); + if (d_X) cudaFree(d_X); + // CHECK: if (cusparseH) hipsparseDestroy(cusparseH); + if (cusparseH) cusparseDestroy(cusparseH); + // CHECK: if (cublasH) hipblasDestroy(cublasH); + if (cublasH) cublasDestroy(cublasH); + // CHECK: if (stream) hipStreamDestroy(stream); + if (stream) cudaStreamDestroy(stream); + // CHECK: hipDeviceReset(); + cudaDeviceReset(); + + return 0; +} diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_11.cu b/tests/hipify-clang/cuSPARSE/cuSPARSE_11.cu new file mode 100644 index 0000000000..2d905bcf6d --- /dev/null +++ b/tests/hipify-clang/cuSPARSE/cuSPARSE_11.cu @@ -0,0 +1,327 @@ +// RUN: %run_test hipify "%s" "%t" %cuda_args +#include +#include +#include +// CHECK: #include +#include +// CHECK: #include +#include + +// NOTE: CUDA 10.0 + +/* compute | b - A*x|_inf */ +void residaul_eval( + int n, + // CHECK: const hipsparseMatDescr_t descrA, + const cusparseMatDescr_t descrA, + const float *csrVal, + const int *csrRowPtr, + const int *csrColInd, + const float *b, + const float *x, + float *r_nrminf_ptr) +{ + // CHECK: const int base = (hipsparseGetMatIndexBase(descrA) != HIPSPARSE_INDEX_BASE_ONE) ? 0 : 1; + const int base = (cusparseGetMatIndexBase(descrA) != CUSPARSE_INDEX_BASE_ONE) ? 0 : 1; + // CHECK: const int lower = (HIPSPARSE_FILL_MODE_LOWER == hipsparseGetMatFillMode(descrA)) ? 1 : 0; + const int lower = (CUSPARSE_FILL_MODE_LOWER == cusparseGetMatFillMode(descrA)) ? 1 : 0; + // CHECK: const int unit = (HIPSPARSE_DIAG_TYPE_UNIT == hipsparseGetMatDiagType(descrA)) ? 1 : 0; + const int unit = (CUSPARSE_DIAG_TYPE_UNIT == cusparseGetMatDiagType(descrA)) ? 1 : 0; + + float r_nrminf = 0; + for (int row = 0; row < n; row++) { + const int start = csrRowPtr[row] - base; + const int end = csrRowPtr[row + 1] - base; + float dot = 0; + for (int colidx = start; colidx < end; colidx++) { + const int col = csrColInd[colidx] - base; + float Aij = csrVal[colidx]; + float xj = x[col]; + if ((row == col) && unit) { + Aij = 1.0; + } + int valid = (row >= col) && lower || + (row <= col) && !lower; + if (valid) { + dot += Aij * xj; + } + } + float ri = b[row] - dot; + r_nrminf = (r_nrminf > fabs(ri)) ? r_nrminf : fabs(ri); + } + *r_nrminf_ptr = r_nrminf; +} + +int main(int argc, char*argv[]) +{ + // CHECK: hipsparseHandle_t handle = NULL; + cusparseHandle_t handle = NULL; + // CHECK: hipStream_t stream = NULL; + cudaStream_t stream = NULL; + // CHECK: hipsparseMatDescr_t descrA = NULL; + cusparseMatDescr_t descrA = NULL; + // NOTE: CUDA 10.0 + // TODO: csrsm2Info_t info = NULL; + csrsm2Info_t info = NULL; + // CHECK: hipsparseStatus_t status = HIPSPARSE_STATUS_SUCCESS; + cusparseStatus_t status = CUSPARSE_STATUS_SUCCESS; + // CHECK: hipError_t cudaStat1 = hipSuccess; + cudaError_t cudaStat1 = cudaSuccess; + const int nrhs = 2; + const int n = 4; + const int nnzA = 9; + // CHECK: const hipsparseSolvePolicy_t policy = HIPSPARSE_SOLVE_POLICY_NO_LEVEL; + const cusparseSolvePolicy_t policy = CUSPARSE_SOLVE_POLICY_NO_LEVEL; + const float h_one = 1.0; + /* + * | 1 0 2 -3 | + * | 0 4 0 0 | + * A = | 5 0 6 7 | + * | 0 8 0 9 | + * + * Regard A as a lower triangle matrix L with non-unit diagonal. + * | 1 5 | | 1 5 | + * Given B = | 2 6 |, X = L \ B = | 0.5 1.5 | + * | 3 7 | | -0.3333 -3 | + * | 4 8 | | 0 -0.4444 | + */ + const int csrRowPtrA[n + 1] = { 1, 4, 5, 8, 10 }; + const int csrColIndA[nnzA] = { 1, 3, 4, 2, 1, 3, 4, 2, 4 }; + const float csrValA[nnzA] = { 1, 2, -3, 4, 5, 6, 7, 8, 9 }; + const float B[n*nrhs] = { 1,2,3,4,5,6,7,8 }; + float X[n*nrhs]; + + int *d_csrRowPtrA = NULL; + int *d_csrColIndA = NULL; + float *d_csrValA = NULL; + float *d_B = NULL; + + size_t lworkInBytes = 0; + char *d_work = NULL; + + const int algo = 0; /* non-block version */ + + printf("example of csrsm2 \n"); + + /* step 1: create cusparse handle, bind a stream */ + // CHECK: cudaStat1 = hipStreamCreateWithFlags(&stream, hipStreamNonBlocking); + cudaStat1 = cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: status = hipsparseCreate(&handle); + status = cusparseCreate(&handle); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + status = cusparseSetStream(handle, stream); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + // NOTE: CUDA 10.0 + // TODO: status = hipsparseCreateCsrsm2Info(&info); + status = cusparseCreateCsrsm2Info(&info); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + /* step 2: configuration of matrix A */ + status = cusparseCreateMatDescr(&descrA); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + /* A is base-1*/ + // CHECK: hipsparseSetMatIndexBase(descrA, HIPSPARSE_INDEX_BASE_ONE); + cusparseSetMatIndexBase(descrA, CUSPARSE_INDEX_BASE_ONE); + // CHECK: hipsparseSetMatType(descrA, HIPSPARSE_MATRIX_TYPE_GENERAL); + cusparseSetMatType(descrA, CUSPARSE_MATRIX_TYPE_GENERAL); + /* A is lower triangle */ + // CHECK: hipsparseSetMatFillMode(descrA, HIPSPARSE_FILL_MODE_LOWER); + cusparseSetMatFillMode(descrA, CUSPARSE_FILL_MODE_LOWER); + /* A has non unit diagonal */ + // CHECK: hipsparseSetMatDiagType(descrA, HIPSPARSE_DIAG_TYPE_NON_UNIT); + cusparseSetMatDiagType(descrA, CUSPARSE_DIAG_TYPE_NON_UNIT); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrRowPtrA, sizeof(int)*(n + 1)); + cudaStat1 = cudaMalloc((void**)&d_csrRowPtrA, sizeof(int)*(n + 1)); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA); + cudaStat1 = cudaMalloc((void**)&d_csrColIndA, sizeof(int)*nnzA); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_csrValA, sizeof(float)*nnzA); + cudaStat1 = cudaMalloc((void**)&d_csrValA, sizeof(float)*nnzA); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMalloc((void**)&d_B, sizeof(float)*n*nrhs); + cudaStat1 = cudaMalloc((void**)&d_B, sizeof(float)*n*nrhs); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(n + 1), hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_csrRowPtrA, csrRowPtrA, sizeof(int)*(n + 1), cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_csrColIndA, csrColIndA, sizeof(int)*nnzA, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_csrValA, csrValA, sizeof(float)*nnzA, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: cudaStat1 = hipMemcpy(d_B, B, sizeof(float)*n*nrhs, hipMemcpyHostToDevice); + cudaStat1 = cudaMemcpy(d_B, B, sizeof(float)*n*nrhs, cudaMemcpyHostToDevice); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 3: query workspace */ + // NOTE: CUDA 10.0 + // TODO: status = hipsparseScsrsm2_bufferSizeExt( + // CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE, + // CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE, + status = cusparseScsrsm2_bufferSizeExt( + handle, + algo, + CUSPARSE_OPERATION_NON_TRANSPOSE, /* transA */ + CUSPARSE_OPERATION_NON_TRANSPOSE, /* transB */ + n, + nrhs, + nnzA, + &h_one, + descrA, + d_csrValA, + d_csrRowPtrA, + d_csrColIndA, + d_B, + n, /* ldb */ + info, + policy, + &lworkInBytes); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + + printf("lworkInBytes = %lld \n", (long long)lworkInBytes); + // CHECK: if (NULL != d_work) { hipFree(d_work); } + if (NULL != d_work) { cudaFree(d_work); } + // CHECK: cudaStat1 = hipMalloc((void**)&d_work, lworkInBytes); + cudaStat1 = cudaMalloc((void**)&d_work, lworkInBytes); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 4: analysis */ + // NOTE: CUDA 10.0 + // TODO: status = hipsparseScsrsm2_analysis( + // CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE, + // CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE, + status = cusparseScsrsm2_analysis( + handle, + algo, + CUSPARSE_OPERATION_NON_TRANSPOSE, /* transA */ + CUSPARSE_OPERATION_NON_TRANSPOSE, /* transB */ + n, + nrhs, + nnzA, + &h_one, + descrA, + d_csrValA, + d_csrRowPtrA, + d_csrColIndA, + d_B, + n, /* ldb */ + info, + policy, + d_work); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + /* step 5: solve L * X = B */ + // NOTE: CUDA 10.0 + // TODO: status = hipsparseScsrsm2_solve( + // CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE, + // CHECK: HIPSPARSE_OPERATION_NON_TRANSPOSE, + status = cusparseScsrsm2_solve( + handle, + algo, + CUSPARSE_OPERATION_NON_TRANSPOSE, /* transA */ + CUSPARSE_OPERATION_NON_TRANSPOSE, /* transB */ + n, + nrhs, + nnzA, + &h_one, + descrA, + d_csrValA, + d_csrRowPtrA, + d_csrColIndA, + d_B, + n, /* ldb */ + info, + policy, + d_work); + // CHECK: assert(HIPSPARSE_STATUS_SUCCESS == status); + assert(CUSPARSE_STATUS_SUCCESS == status); + // CHECK: cudaStat1 = hipDeviceSynchronize(); + cudaStat1 = cudaDeviceSynchronize(); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + + /* step 6:measure residual B - A*X */ + // CHECK: cudaStat1 = hipMemcpy(X, d_B, sizeof(float)*n*nrhs, hipMemcpyDeviceToHost); + cudaStat1 = cudaMemcpy(X, d_B, sizeof(float)*n*nrhs, cudaMemcpyDeviceToHost); + // CHECK: assert(hipSuccess == cudaStat1); + assert(cudaSuccess == cudaStat1); + // CHECK: hipDeviceSynchronize(); + cudaDeviceSynchronize(); + + printf("==== x1 = inv(A)*b1 \n"); + for (int j = 0; j < n; j++) { + printf("x1[%d] = %f\n", j, X[j]); + } + float r1_nrminf; + residaul_eval( + n, + descrA, + csrValA, + csrRowPtrA, + csrColIndA, + B, + X, + &r1_nrminf + ); + printf("|b1 - A*x1| = %E\n", r1_nrminf); + + printf("==== x2 = inv(A)*b2 \n"); + for (int j = 0; j < n; j++) { + printf("x2[%d] = %f\n", j, X[n + j]); + } + float r2_nrminf; + residaul_eval( + n, + descrA, + csrValA, + csrRowPtrA, + csrColIndA, + B + n, + X + n, + &r2_nrminf + ); + printf("|b2 - A*x2| = %E\n", r2_nrminf); + + /* free resources */ + // CHECK: if (d_csrRowPtrA) hipFree(d_csrRowPtrA); + if (d_csrRowPtrA) cudaFree(d_csrRowPtrA); + // CHECK: if (d_csrColIndA) hipFree(d_csrColIndA); + if (d_csrColIndA) cudaFree(d_csrColIndA); + // CHECK: if (d_csrValA) hipFree(d_csrValA); + if (d_csrValA) cudaFree(d_csrValA); + // CHECK: if (d_B) hipFree(d_B); + if (d_B) cudaFree(d_B); + // CHECK: if (handle) hipsparseDestroy(handle); + if (handle) cusparseDestroy(handle); + // CHECK: if (stream) hipStreamDestroy(stream); + if (stream) cudaStreamDestroy(stream); + // CHECK: if (descrA) hipsparseDestroyMatDescr(descrA); + if (descrA) cusparseDestroyMatDescr(descrA); + // NOTE: CUDA 10.0 + // TODO: if (info) hipsparseDestroyCsrsm2Info(info); + if (info) cusparseDestroyCsrsm2Info(info); + // CHECK: hipDeviceReset(); + cudaDeviceReset(); + + return 0; +} diff --git a/tests/hipify-clang/lit.cfg b/tests/hipify-clang/lit.cfg index b9ff0b2495..f959147cd6 100644 --- a/tests/hipify-clang/lit.cfg +++ b/tests/hipify-clang/lit.cfg @@ -26,6 +26,9 @@ config.excludes = ['cmdparser.hpp'] config.cuda_version = "@CUDA_VERSION@" if config.cuda_version not in ['10.0']: config.excludes.append('cuSPARSE_08.cu') + config.excludes.append('cuSPARSE_09.cu') + config.excludes.append('cuSPARSE_10.cu') + config.excludes.append('cuSPARSE_11.cu') # test_exec_root: The path where tests are located (default is the test suite root). #config.test_exec_root = config.test_source_root From 09612ac03fe70aae340967e95ac91801373a4643 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 4 Dec 2018 20:47:34 +0300 Subject: [PATCH 55/55] [HIPIFY][tests] Reorganization --- tests/hipify-clang/{ => unit_tests/headers}/headers_test_01.cu | 0 tests/hipify-clang/{ => unit_tests/headers}/headers_test_02.cu | 0 tests/hipify-clang/{ => unit_tests/headers}/headers_test_03.cu | 0 tests/hipify-clang/{ => unit_tests/headers}/headers_test_04.cu | 0 tests/hipify-clang/{ => unit_tests/headers}/headers_test_05.cu | 0 tests/hipify-clang/{ => unit_tests/headers}/headers_test_06.cu | 0 tests/hipify-clang/{ => unit_tests/headers}/headers_test_07.cu | 0 tests/hipify-clang/{ => unit_tests/headers}/headers_test_08.cu | 0 tests/hipify-clang/{ => unit_tests/headers}/headers_test_09.cu | 0 .../{ => unit_tests/libraries}/cuBLAS/cublas_0_based_indexing.cu | 0 .../{ => unit_tests/libraries}/cuBLAS/cublas_1_based_indexing.cu | 0 .../libraries}/cuBLAS/cublas_sgemm_matrix_multiplication.cu | 0 .../{ => unit_tests/libraries}/cuComplex/cuComplex_Julia.cu | 0 .../{ => unit_tests/libraries}/cuDNN/cudnn_convolution_forward.cu | 0 .../{ => unit_tests/libraries}/cuDNN/cudnn_softmax.cu | 0 .../hipify-clang/{ => unit_tests/libraries}/cuFFT/simple_cufft.cu | 0 .../libraries}/cuRAND/benchmark_curand_generate.cpp | 0 .../{ => unit_tests/libraries}/cuRAND/benchmark_curand_kernel.cpp | 0 .../hipify-clang/{ => unit_tests/libraries}/cuRAND/cmdparser.hpp | 0 .../{ => unit_tests/libraries}/cuRAND/poisson_api_example.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_01.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_02.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_03.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_04.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_05.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_06.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_07.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_08.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_09.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_10.cu | 0 .../{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_11.cu | 0 tests/hipify-clang/{ => unit_tests/samples}/allocators.cu | 0 tests/hipify-clang/{ => unit_tests/samples}/axpy.cu | 0 tests/hipify-clang/{ => unit_tests/samples}/coalescing.cu | 0 tests/hipify-clang/{ => unit_tests/samples}/cudaRegister.cu | 0 .../{ => unit_tests/samples}/dynamic_shared_memory.cu | 0 tests/hipify-clang/{ => unit_tests/samples}/intro.cu | 0 tests/hipify-clang/{ => unit_tests/samples}/square.cu | 0 .../hipify-clang/{ => unit_tests/samples}/static_shared_memory.cu | 0 tests/hipify-clang/{ => unit_tests/samples}/vec_add.cu | 0 40 files changed, 0 insertions(+), 0 deletions(-) rename tests/hipify-clang/{ => unit_tests/headers}/headers_test_01.cu (100%) rename tests/hipify-clang/{ => unit_tests/headers}/headers_test_02.cu (100%) rename tests/hipify-clang/{ => unit_tests/headers}/headers_test_03.cu (100%) rename tests/hipify-clang/{ => unit_tests/headers}/headers_test_04.cu (100%) rename tests/hipify-clang/{ => unit_tests/headers}/headers_test_05.cu (100%) rename tests/hipify-clang/{ => unit_tests/headers}/headers_test_06.cu (100%) rename tests/hipify-clang/{ => unit_tests/headers}/headers_test_07.cu (100%) rename tests/hipify-clang/{ => unit_tests/headers}/headers_test_08.cu (100%) rename tests/hipify-clang/{ => unit_tests/headers}/headers_test_09.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuBLAS/cublas_0_based_indexing.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuBLAS/cublas_1_based_indexing.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuBLAS/cublas_sgemm_matrix_multiplication.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuComplex/cuComplex_Julia.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuDNN/cudnn_convolution_forward.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuDNN/cudnn_softmax.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuFFT/simple_cufft.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuRAND/benchmark_curand_generate.cpp (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuRAND/benchmark_curand_kernel.cpp (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuRAND/cmdparser.hpp (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuRAND/poisson_api_example.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_01.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_02.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_03.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_04.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_05.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_06.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_07.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_08.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_09.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_10.cu (100%) rename tests/hipify-clang/{ => unit_tests/libraries}/cuSPARSE/cuSPARSE_11.cu (100%) rename tests/hipify-clang/{ => unit_tests/samples}/allocators.cu (100%) rename tests/hipify-clang/{ => unit_tests/samples}/axpy.cu (100%) rename tests/hipify-clang/{ => unit_tests/samples}/coalescing.cu (100%) rename tests/hipify-clang/{ => unit_tests/samples}/cudaRegister.cu (100%) rename tests/hipify-clang/{ => unit_tests/samples}/dynamic_shared_memory.cu (100%) rename tests/hipify-clang/{ => unit_tests/samples}/intro.cu (100%) rename tests/hipify-clang/{ => unit_tests/samples}/square.cu (100%) rename tests/hipify-clang/{ => unit_tests/samples}/static_shared_memory.cu (100%) rename tests/hipify-clang/{ => unit_tests/samples}/vec_add.cu (100%) diff --git a/tests/hipify-clang/headers_test_01.cu b/tests/hipify-clang/unit_tests/headers/headers_test_01.cu similarity index 100% rename from tests/hipify-clang/headers_test_01.cu rename to tests/hipify-clang/unit_tests/headers/headers_test_01.cu diff --git a/tests/hipify-clang/headers_test_02.cu b/tests/hipify-clang/unit_tests/headers/headers_test_02.cu similarity index 100% rename from tests/hipify-clang/headers_test_02.cu rename to tests/hipify-clang/unit_tests/headers/headers_test_02.cu diff --git a/tests/hipify-clang/headers_test_03.cu b/tests/hipify-clang/unit_tests/headers/headers_test_03.cu similarity index 100% rename from tests/hipify-clang/headers_test_03.cu rename to tests/hipify-clang/unit_tests/headers/headers_test_03.cu diff --git a/tests/hipify-clang/headers_test_04.cu b/tests/hipify-clang/unit_tests/headers/headers_test_04.cu similarity index 100% rename from tests/hipify-clang/headers_test_04.cu rename to tests/hipify-clang/unit_tests/headers/headers_test_04.cu diff --git a/tests/hipify-clang/headers_test_05.cu b/tests/hipify-clang/unit_tests/headers/headers_test_05.cu similarity index 100% rename from tests/hipify-clang/headers_test_05.cu rename to tests/hipify-clang/unit_tests/headers/headers_test_05.cu diff --git a/tests/hipify-clang/headers_test_06.cu b/tests/hipify-clang/unit_tests/headers/headers_test_06.cu similarity index 100% rename from tests/hipify-clang/headers_test_06.cu rename to tests/hipify-clang/unit_tests/headers/headers_test_06.cu diff --git a/tests/hipify-clang/headers_test_07.cu b/tests/hipify-clang/unit_tests/headers/headers_test_07.cu similarity index 100% rename from tests/hipify-clang/headers_test_07.cu rename to tests/hipify-clang/unit_tests/headers/headers_test_07.cu diff --git a/tests/hipify-clang/headers_test_08.cu b/tests/hipify-clang/unit_tests/headers/headers_test_08.cu similarity index 100% rename from tests/hipify-clang/headers_test_08.cu rename to tests/hipify-clang/unit_tests/headers/headers_test_08.cu diff --git a/tests/hipify-clang/headers_test_09.cu b/tests/hipify-clang/unit_tests/headers/headers_test_09.cu similarity index 100% rename from tests/hipify-clang/headers_test_09.cu rename to tests/hipify-clang/unit_tests/headers/headers_test_09.cu diff --git a/tests/hipify-clang/cuBLAS/cublas_0_based_indexing.cu b/tests/hipify-clang/unit_tests/libraries/cuBLAS/cublas_0_based_indexing.cu similarity index 100% rename from tests/hipify-clang/cuBLAS/cublas_0_based_indexing.cu rename to tests/hipify-clang/unit_tests/libraries/cuBLAS/cublas_0_based_indexing.cu diff --git a/tests/hipify-clang/cuBLAS/cublas_1_based_indexing.cu b/tests/hipify-clang/unit_tests/libraries/cuBLAS/cublas_1_based_indexing.cu similarity index 100% rename from tests/hipify-clang/cuBLAS/cublas_1_based_indexing.cu rename to tests/hipify-clang/unit_tests/libraries/cuBLAS/cublas_1_based_indexing.cu diff --git a/tests/hipify-clang/cuBLAS/cublas_sgemm_matrix_multiplication.cu b/tests/hipify-clang/unit_tests/libraries/cuBLAS/cublas_sgemm_matrix_multiplication.cu similarity index 100% rename from tests/hipify-clang/cuBLAS/cublas_sgemm_matrix_multiplication.cu rename to tests/hipify-clang/unit_tests/libraries/cuBLAS/cublas_sgemm_matrix_multiplication.cu diff --git a/tests/hipify-clang/cuComplex/cuComplex_Julia.cu b/tests/hipify-clang/unit_tests/libraries/cuComplex/cuComplex_Julia.cu similarity index 100% rename from tests/hipify-clang/cuComplex/cuComplex_Julia.cu rename to tests/hipify-clang/unit_tests/libraries/cuComplex/cuComplex_Julia.cu diff --git a/tests/hipify-clang/cuDNN/cudnn_convolution_forward.cu b/tests/hipify-clang/unit_tests/libraries/cuDNN/cudnn_convolution_forward.cu similarity index 100% rename from tests/hipify-clang/cuDNN/cudnn_convolution_forward.cu rename to tests/hipify-clang/unit_tests/libraries/cuDNN/cudnn_convolution_forward.cu diff --git a/tests/hipify-clang/cuDNN/cudnn_softmax.cu b/tests/hipify-clang/unit_tests/libraries/cuDNN/cudnn_softmax.cu similarity index 100% rename from tests/hipify-clang/cuDNN/cudnn_softmax.cu rename to tests/hipify-clang/unit_tests/libraries/cuDNN/cudnn_softmax.cu diff --git a/tests/hipify-clang/cuFFT/simple_cufft.cu b/tests/hipify-clang/unit_tests/libraries/cuFFT/simple_cufft.cu similarity index 100% rename from tests/hipify-clang/cuFFT/simple_cufft.cu rename to tests/hipify-clang/unit_tests/libraries/cuFFT/simple_cufft.cu diff --git a/tests/hipify-clang/cuRAND/benchmark_curand_generate.cpp b/tests/hipify-clang/unit_tests/libraries/cuRAND/benchmark_curand_generate.cpp similarity index 100% rename from tests/hipify-clang/cuRAND/benchmark_curand_generate.cpp rename to tests/hipify-clang/unit_tests/libraries/cuRAND/benchmark_curand_generate.cpp diff --git a/tests/hipify-clang/cuRAND/benchmark_curand_kernel.cpp b/tests/hipify-clang/unit_tests/libraries/cuRAND/benchmark_curand_kernel.cpp similarity index 100% rename from tests/hipify-clang/cuRAND/benchmark_curand_kernel.cpp rename to tests/hipify-clang/unit_tests/libraries/cuRAND/benchmark_curand_kernel.cpp diff --git a/tests/hipify-clang/cuRAND/cmdparser.hpp b/tests/hipify-clang/unit_tests/libraries/cuRAND/cmdparser.hpp similarity index 100% rename from tests/hipify-clang/cuRAND/cmdparser.hpp rename to tests/hipify-clang/unit_tests/libraries/cuRAND/cmdparser.hpp diff --git a/tests/hipify-clang/cuRAND/poisson_api_example.cu b/tests/hipify-clang/unit_tests/libraries/cuRAND/poisson_api_example.cu similarity index 100% rename from tests/hipify-clang/cuRAND/poisson_api_example.cu rename to tests/hipify-clang/unit_tests/libraries/cuRAND/poisson_api_example.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_01.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_01.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_01.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_02.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_02.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_02.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_03.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_03.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_03.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_03.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_04.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_04.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_04.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_04.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_05.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_05.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_05.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_05.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_06.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_06.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_06.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_06.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_07.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_07.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_07.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_07.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_08.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_08.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_08.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_09.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_09.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_09.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_09.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_10.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_10.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_10.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_10.cu diff --git a/tests/hipify-clang/cuSPARSE/cuSPARSE_11.cu b/tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_11.cu similarity index 100% rename from tests/hipify-clang/cuSPARSE/cuSPARSE_11.cu rename to tests/hipify-clang/unit_tests/libraries/cuSPARSE/cuSPARSE_11.cu diff --git a/tests/hipify-clang/allocators.cu b/tests/hipify-clang/unit_tests/samples/allocators.cu similarity index 100% rename from tests/hipify-clang/allocators.cu rename to tests/hipify-clang/unit_tests/samples/allocators.cu diff --git a/tests/hipify-clang/axpy.cu b/tests/hipify-clang/unit_tests/samples/axpy.cu similarity index 100% rename from tests/hipify-clang/axpy.cu rename to tests/hipify-clang/unit_tests/samples/axpy.cu diff --git a/tests/hipify-clang/coalescing.cu b/tests/hipify-clang/unit_tests/samples/coalescing.cu similarity index 100% rename from tests/hipify-clang/coalescing.cu rename to tests/hipify-clang/unit_tests/samples/coalescing.cu diff --git a/tests/hipify-clang/cudaRegister.cu b/tests/hipify-clang/unit_tests/samples/cudaRegister.cu similarity index 100% rename from tests/hipify-clang/cudaRegister.cu rename to tests/hipify-clang/unit_tests/samples/cudaRegister.cu diff --git a/tests/hipify-clang/dynamic_shared_memory.cu b/tests/hipify-clang/unit_tests/samples/dynamic_shared_memory.cu similarity index 100% rename from tests/hipify-clang/dynamic_shared_memory.cu rename to tests/hipify-clang/unit_tests/samples/dynamic_shared_memory.cu diff --git a/tests/hipify-clang/intro.cu b/tests/hipify-clang/unit_tests/samples/intro.cu similarity index 100% rename from tests/hipify-clang/intro.cu rename to tests/hipify-clang/unit_tests/samples/intro.cu diff --git a/tests/hipify-clang/square.cu b/tests/hipify-clang/unit_tests/samples/square.cu similarity index 100% rename from tests/hipify-clang/square.cu rename to tests/hipify-clang/unit_tests/samples/square.cu diff --git a/tests/hipify-clang/static_shared_memory.cu b/tests/hipify-clang/unit_tests/samples/static_shared_memory.cu similarity index 100% rename from tests/hipify-clang/static_shared_memory.cu rename to tests/hipify-clang/unit_tests/samples/static_shared_memory.cu diff --git a/tests/hipify-clang/vec_add.cu b/tests/hipify-clang/unit_tests/samples/vec_add.cu similarity index 100% rename from tests/hipify-clang/vec_add.cu rename to tests/hipify-clang/unit_tests/samples/vec_add.cu