Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HIPIFY] HIPIFY converts CUDA_R_32F to HIPBLAS_R_32F instead of HIP_R_32F #383

Closed
hom0056 opened this issue Aug 11, 2021 · 4 comments
Closed
Assignees
Labels
feature Feature request or implementation

Comments

@hom0056
Copy link

hom0056 commented Aug 11, 2021

When hipifying cuda source containing cusparse code, CUDA_R_32F (of type cudaDataType) should be converted to HIP_R_32F (of type hipDataType), which is, according to nvcc_detail/hip_runtime_api.h, just a macro definition of the original cuda type and value. Instead, CUDA_R_32F gets hipified to HIPBLAS_R_32F, which is of type hipblasDatatype_t and is incompatible.

The original cuda code gets compiled using nvcc with no problem and runs OK, but after hipification, compilation with hipcc fails with errors like

my_sparse_test.hip.cpp(109): error: argument of type "hipblasDatatype_t" is incompatible with parameter of type "cudaDataType"

pointing to a line where (for example) hipsparseSpMV function is called.

Replacing HIPBLAS_R_32F with HIP_R_32F in the hipified code makes the code compile with no problem and the program runs OK.

I am on nvidia platform, using Ubuntu-18.04.
hipcc --version:

HIP version: 4.2.21155-37cb3a34
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Wed_Jun__2_19:15:15_PDT_2021
Cuda compilation tools, release 11.4, V11.4.48
Build cuda_11.4.r11.4/compiler.30033411_0

hipify-clang --version:

LLVM (http://llvm.org/):
  LLVM version 12.0.1
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: znver1

this probably applies to other values of the enum as well.
this applies to both hipify-perl and hipify-clang

edit:
on my amd-gpu machine the error message from hipcc is

my_sparse_test.hip.cpp:119:5: error: no matching function for call to 'hipsparseSpMV'
    hipsparseSpMV(sparseHandle, HIPSPARSE_OPERATION_NON_TRANSPOSE, &alpha, matA, vecX, &beta, vecY, HIPBLAS_R_32F, HIPSPARSE_MV_ALG_DEFAULT, workspace);
    ^~~~~~~~~~~~~
/home/hom0056/apps/hipSPARSE/installation/include/hipsparse.h:5510:19: note: candidate function not viable: no known conversion from 'hipblasDatatype_t' to 'hipDataType' for 8th argument

the cause seems to be the same.

@emankov emankov changed the title HIPIFY converts CUDA_R_32F to HIPBLAS_R_32F instead of HIP_R_32F [HIPIFY] HIPIFY converts CUDA_R_32F to HIPBLAS_R_32F instead of HIP_R_32F Aug 11, 2021
@emankov emankov self-assigned this Aug 11, 2021
@emankov emankov added the bug Something isn't working label Aug 11, 2021
@emankov
Copy link
Collaborator

emankov commented Aug 11, 2021

@hom0056, Could you provide your example, please?

@hom0056
Copy link
Author

hom0056 commented Aug 11, 2021

Sure. The simplest cuda program I can think of that produces the problem:

#include <cusparse.h>
#include <cublas_v2.h>

int main()
{
    int size = 10;

    float * d_x;
    cudaMalloc(&d_x, size * sizeof(float));

    cusparseHandle_t sparseHandle;
    cusparseCreate(&sparseHandle);

    cusparseDnVecDescr_t vec;
    cusparseCreateDnVec(&vec, size, d_x, CUDA_R_32F);
    cusparseDestroyDnVec(vec);

    cudaFree(d_x);
    
    cusparseDestroy(sparseHandle);

    return 0;
}

then hipify-clang my_sparse_test.cu -o my_sparse_test.hip.cpp and hipcc [includeflags] my_sparse_test.hip.cpp -o my_sparse_test.x [libflags]
Not including the cublas header just changes the error to error: identifier "HIPBLAS_R_32F" is undefined

If you need, I can also provide the full program I was hipifying originally.

@emankov
Copy link
Collaborator

emankov commented Aug 18, 2021

Hi @hom0056,

This issue will be fixed after fixing ROCm/hipBLAS#366 in hipBLAS and HIP.

@emankov emankov added feature Feature request or implementation and removed bug Something isn't working labels Aug 18, 2021
emankov added a commit to emankov/HIPIFY that referenced this issue Nov 15, 2023
+ [Reason] `cusparseGetStream` appeared in CUDA 8.0
+ [fix] Set the missing A-version for `cusparseGetStream`
+ Updated synthetic `SPARSE` tests and the regenerated `SPARSE` documentation
+ [TODO][ROCm#899][HIPIFY][ROCm#895][ROCm#383][hipBLAS-ROCm#366][workaround][temporary] Always convert cudaDataType_t to hipDataType under the `--use-hip-data-types` option
@emankov
Copy link
Collaborator

emankov commented Dec 28, 2023

Finally fixed in hipBLAS 6.0.0 and HIPIFY tools (#1065).

@emankov emankov closed this as completed Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or implementation
Projects
None yet
Development

No branches or pull requests

2 participants