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

Issue in macOS with the OpenCL atom_add function when array is of long type #637

Open
stratika opened this issue Mar 13, 2025 · 0 comments
Assignees
Labels

Comments

@stratika
Copy link
Collaborator

Describe the bug

In macOS, I noticed that the TestAtomics unit-tests have one test failing. The error is related to the cl2Metal conversion which implies that the Metal clang implementation probably does not support the long type for atom_add.

This issue seems to be OS-specific. Hence, I am opening it in order to document it and provide a patch as workaround.

How To Reproduce

Build TornadoVM with OpenCL backend on macOS:

./bin/tornadovm-installer --jdk jdk21 --backend opencl

Then run:

tornado-test -V uk.ac.manchester.tornado.unittests.atomics.TestAtomics#testAtomic18_parallel_api_LongArray

WARNING: Using incubator modules: jdk.incubator.vector
UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed

[ERROR] TornadoVM JIT Compiler - OpenCL Build Error Log:

program_source:21:13: error: call to 'atom_add' is ambiguous
    l_8  =  atom_add((volatile __global long *) ul_7, 1L);
            ^~~~~~~~
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.406/include/opencl-c.h:13111:12: note: candidate function
int __ovld atom_add(volatile __global int *p, int val);
           ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.406/include/opencl-c.h:13112:13: note: candidate function
uint __ovld atom_add(volatile __global uint *p, uint val);

Expected behavior

It seems that the Metal-based OpenCL implementation of the atom_add may not support long types.
If I change at the code gen the casted type to be int instead of long, it works:

l_8  =  atom_add((volatile __global int *) ul_7, 1L);

See the patch: ISSUE_637.patch

Computing system setup (please complete the following information):

  • OS: macOS 15.3.2
  • OpenCL and Driver versions: n/a
  • TornadoVM commit id: 4d8be35
  • TornadoVM version: 1.0.11-dev
  • branch: develop

@stratika stratika added the macOS label Mar 13, 2025
@stratika stratika self-assigned this Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant