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

Signed/unsigned char on different platforms #45

Open
matthiasdiener opened this issue Dec 1, 2023 · 1 comment
Open

Signed/unsigned char on different platforms #45

matthiasdiener opened this issue Dec 1, 2023 · 1 comment

Comments

@matthiasdiener
Copy link

matthiasdiener commented Dec 1, 2023

I'm not sure how much difference it makes in practice, but the char type in C/C++ isn't guaranteed to be signed or unsigned.

By default, x86/M1 seem to treat char as signed, but ppc64le treats it as unsigned. This can also be modified by compiler options (e.g., https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/C-Dialect-Options.html#index-funsigned-char).

reg.get_or_register_dtype(["signed char", "char"], np.int8)

OpenCL seems to define it as signed: https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#built-in-scalar-data-types

@inducer
Copy link
Owner

inducer commented Dec 1, 2023

In terms of code generation, I believe it is the first item in the list that's relevant, i.e. an explicit signed char should be generated. The other items are for parsing string-ly arguments in pyopencl, where I think treating char as signed is a safe default if the user doesn't specify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants