HIP icon indicating copy to clipboard operation
HIP copied to clipboard

hipMallocPitch requires cast to void**

Open jakub-homola opened this issue 3 years ago • 3 comments

Hello, this is a minor issue, but it is quite inconvenient -- one needs to cast the first parameter of hipMallocPitch to void** in HIP. In CUDA (cudaMallocPitch), the cast is not needed.

The CUDA program

#include <cstdio>


int main()
{
    int width = 42, height = 69;
    size_t pitch;
    float * data;

    cudaMallocPitch(&data, &pitch, width * sizeof(float), height);
    cudaFree(data);

    return 0;
}

is compiled with nvcc source.cu -o program.cuda.x without any issues.

However, the equivalent HIP program

#include <cstdio>
#include "hip/hip_runtime.h"

int main()
{
    int width = 42, height = 69;
    size_t pitch;
    float * data;

    hipMallocPitch(&data, &pitch, width * sizeof(float), height);
    hipFree(data);

    return 0;
}

fails on compilation (hipcc source.hip.cpp -o program.hip.x) on the hipMallocPitch function:

source.hip.cpp(10): error: argument of type "float **" is incompatible with parameter of type "void **"

Not a huge problem, since casting the first parameter to void** solves it, but in CUDA we do not need to perform the cast, so I think that neither should we in HIP.

I am using nvcc V11.4.152, HIP version 4.4.21401-bedc5f61

jakub-homola avatar Feb 08 '22 18:02 jakub-homola