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

Migration of cudaGetErrorString incorrect when used in macro #1950

Open
Ruyk opened this issue May 7, 2024 · 2 comments
Open

Migration of cudaGetErrorString incorrect when used in macro #1950

Ruyk opened this issue May 7, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Ruyk
Copy link
Contributor

Ruyk commented May 7, 2024

Describe the bug

The CUDA function "cudaGetErrorString", which converts a CUDA error code onto a user-readable error string, is incorrectly translated by syclomatic when used as parameter on a macro. Syclomatic translates the name of the function with a string, but the expectation is to keep the function name at that point so that it can be used in nested macros.

To reproduce

The code below:

#include <cstdio>
#include <cuda_runtime.h>

#define CHECK_CUDA_FUNCTION(errNo, errFunc) \
        errFunc(errNo)

#define CHECK_CUDA(errNo) \
        CHECK_CUDA_FUNCTION(errNo, cudaGetErrorString)


int main() {
        printf("%s \n", CHECK_CUDA(cudaSuccess));
};

is incorrectly converted to

#include <sycl/sycl.hpp>
#include <dpct/dpct.hpp>
#include <cstdio>

#define CHECK_CUDA_FUNCTION(errNo, errFunc) \
        errFunc(errNo)

#define CHECK_CUDA(errNo) CHECK_CUDA_FUNCTION(errNo, "<Placeholder string>")

int main() {
        /*
        DPCT1009:0: SYCL uses exceptions to report errors and does not use the
        error codes. The call was replaced by a placeholder string. You need to
        rewrite this code.
        */
        printf("%s \n", CHECK_CUDA(0));
};

Environment

No response

Additional context

No response

@Ruyk Ruyk added the bug Something isn't working label May 7, 2024
@tomflinda
Copy link
Contributor

tomflinda commented May 8, 2024

@Ruyk
We will introduce a new helper function to map cudaGetErrorString, and implement the migration logic in SYCLomatic.
@intwanghao will implement this PR later on.

@joeatodd
Copy link
Contributor

intel/llvm#15719

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants