Closed
Description
A simple Cython extension that involved cimport dpctl translated to C can not be compiled.
# File: a.pyx
# cython: language=c
# cython: language_level=3
cimport dpctl as c_dpctl
import dpctl
def foo(c_dpctl.SyclQueue q):
return q.sycl_device.max_compute_unitThen execute cythonize a.pyx to produce a.c. Compile the file using
gcc -fmax-errors=1 a.c -I$(python -c "import dpctl; print(dpctl.get_include())") -I$(python3-config --includes)This results in a compilation error due to undefined type bool:
In file included from a.c:638:
/localdisk/repos/dpctl/dpctl/include/dpctl_sycl_device_interface.h:99:1: error: unknown type name ‘bool’
99 | bool DPCTLDevice_IsAccelerator(__dpctl_keep const DPCTLSyclDeviceRef DRef);
| ^~~~
compilation terminated due to -fmax-errors=1.
Metadata
Metadata
Assignees
Labels
No labels
Activity
oleksandr-pavlyk commentedon Sep 13, 2021
I suppose DPCTL-capi headers should define
booltype when the compiler is not__cplusplus__.diptorupd commentedon Sep 23, 2021
@oleksandr-pavlyk can you try
gcc -fmax-errors=1 a.c -I$(python -c "import dpctl; print(dpctl.get_include())") -I$(python3-config --includes) -std=c99.boolis in the C99 standard and we should not need anything extra unless we need older C standard support.oleksandr-pavlyk commentedon Sep 23, 2021
Using
-std=c99does not seem to help:The compiler is not old:
By the way, it would be cool if
dpctlprovided__main__.pyto enable generation of includes with-I$(python -m dpctl --includes).oleksandr-pavlyk commentedon Sep 28, 2021
Evidently, one needs to
#include <stdbool.h>.Closes #585