Skip to content

Commit b4d811a

Browse files
Diptorup Deboleksandr-pavlyk
andauthored
DPCTL C API headers are not always truly C complaint (e.g. -Wstrict-prototype) (#463)
* Changes to make dpctl-capi headers C complaint and satisfy `-Wstrict-prototype` Co-authored-by: Oleksandr Pavlyk <[email protected]>
1 parent c1d7bcc commit b4d811a

12 files changed

+56
-78
lines changed

dpctl-capi/include/dpctl_sycl_device_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ DPCTLDevice_Copy(__dpctl_keep const DPCTLSyclDeviceRef DRef);
6262
* @ingroup DeviceInterface
6363
*/
6464
DPCTL_API
65-
__dpctl_give DPCTLSyclDeviceRef DPCTLDevice_Create();
65+
__dpctl_give DPCTLSyclDeviceRef DPCTLDevice_Create(void);
6666

6767
/*!
6868
* @brief Returns a new DPCTLSyclDeviceRef opaque object created using the

dpctl-capi/include/dpctl_sycl_device_selector_interface.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ DPCTL_C_EXTERN_C_BEGIN
4444
* @ingroup DeviceSelectors
4545
*/
4646
DPCTL_API
47-
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLAcceleratorSelector_Create();
47+
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLAcceleratorSelector_Create(void);
4848

4949
/*!
5050
* @brief Returns an opaque wrapper for sycl::default_selector object.
@@ -53,7 +53,7 @@ __dpctl_give DPCTLSyclDeviceSelectorRef DPCTLAcceleratorSelector_Create();
5353
* @ingroup DeviceSelectors
5454
*/
5555
DPCTL_API
56-
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLDefaultSelector_Create();
56+
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLDefaultSelector_Create(void);
5757

5858
/*!
5959
* @brief Returns an opaque wrapper for sycl::cpu_selector object.
@@ -62,7 +62,7 @@ __dpctl_give DPCTLSyclDeviceSelectorRef DPCTLDefaultSelector_Create();
6262
* @ingroup DeviceSelectors
6363
*/
6464
DPCTL_API
65-
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLCPUSelector_Create();
65+
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLCPUSelector_Create(void);
6666

6767
/*!
6868
* @brief Returns an opaque wrapper for sycl::ONEAPI::filter_selector object
@@ -84,7 +84,7 @@ DPCTLFilterSelector_Create(__dpctl_keep const char *filter_str);
8484
* @ingroup DeviceSelectors
8585
*/
8686
DPCTL_API
87-
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLGPUSelector_Create();
87+
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLGPUSelector_Create(void);
8888

8989
/*!
9090
* @brief Returns an opaque wrapper for sycl::host_selector object.
@@ -93,7 +93,7 @@ __dpctl_give DPCTLSyclDeviceSelectorRef DPCTLGPUSelector_Create();
9393
* @ingroup DeviceSelectors
9494
*/
9595
DPCTL_API
96-
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLHostSelector_Create();
96+
__dpctl_give DPCTLSyclDeviceSelectorRef DPCTLHostSelector_Create(void);
9797

9898
/*!
9999
* @brief Deletes the DPCTLSyclDeviceSelectorRef after casting it to a

dpctl-capi/include/dpctl_sycl_enum_types.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ DPCTL_C_EXTERN_C_BEGIN
3535
* @brief Redefinition of DPC++-specific Sycl backend types.
3636
*
3737
*/
38-
enum DPCTLSyclBackendType
38+
typedef enum
3939
{
4040
// clang-format off
4141
DPCTL_CUDA = 1 << 16,
@@ -45,13 +45,13 @@ enum DPCTLSyclBackendType
4545
DPCTL_UNKNOWN_BACKEND = 0,
4646
DPCTL_ALL_BACKENDS = ((1<<5)-1) << 16
4747
// clang-format on
48-
};
48+
} DPCTLSyclBackendType;
4949

5050
/*!
5151
* @brief DPCTL device types that are equivalent to Sycl's device_type.
5252
*
5353
*/
54-
enum DPCTLSyclDeviceType
54+
typedef enum
5555
{
5656
// Note: before adding new values here look at DPCTLSyclBackendType enum.
5757
// The values should not overlap.
@@ -66,7 +66,7 @@ enum DPCTLSyclDeviceType
6666
DPCTL_ALL = (1 << 6) - 1,
6767
DPCTL_UNKNOWN_DEVICE = 0
6868
// clang-format on
69-
};
69+
} DPCTLSyclDeviceType;
7070

7171
/*!
7272
* @brief Supported types for kernel arguments to be passed to a Sycl kernel
@@ -100,7 +100,7 @@ typedef enum
100100
* characteristics of the device.
101101
*
102102
*/
103-
enum DPCTLSyclAspectType
103+
typedef enum
104104
{
105105
host,
106106
cpu,
@@ -120,13 +120,13 @@ enum DPCTLSyclAspectType
120120
usm_shared_allocations,
121121
usm_restricted_shared_allocations,
122122
usm_system_allocator
123-
};
123+
} DPCTLSyclAspectType;
124124

125125
/*!
126126
* @brief DPCTL analogue of ``sycl::info::partition_affinity_domain`` enum.
127127
*
128128
*/
129-
enum DPCTLPartitionAffinityDomainType
129+
typedef enum
130130
{
131131
not_applicable,
132132
numa,
@@ -135,7 +135,7 @@ enum DPCTLPartitionAffinityDomainType
135135
L2_cache,
136136
L1_cache,
137137
next_partitionable
138-
};
138+
} DPCTLPartitionAffinityDomainType;
139139

140140
/*!
141141
* @brief Enums to depict the properties that can be passed to a sycl::queue

dpctl-capi/include/dpctl_sycl_platform_interface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ DPCTLPlatform_Copy(__dpctl_keep const DPCTLSyclPlatformRef PRef);
5959
* @ingroup PlatformInterface
6060
*/
6161
DPCTL_API
62-
__dpctl_give DPCTLSyclPlatformRef DPCTLPlatform_Create();
62+
__dpctl_give DPCTLSyclPlatformRef DPCTLPlatform_Create(void);
6363

6464
/*!
6565
* @brief Creates a new DPCTLSyclPlatformRef for a SYCL platform constructed
@@ -140,6 +140,6 @@ DPCTLPlatform_GetVersion(__dpctl_keep const DPCTLSyclPlatformRef PRef);
140140
* @ingroup PlatformInterface
141141
*/
142142
DPCTL_API
143-
__dpctl_give DPCTLPlatformVectorRef DPCTLPlatform_GetPlatforms();
143+
__dpctl_give DPCTLPlatformVectorRef DPCTLPlatform_GetPlatforms(void);
144144

145145
DPCTL_C_EXTERN_C_END

dpctl-capi/include/dpctl_sycl_queue_manager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ DPCTL_C_EXTERN_C_BEGIN
5555
* @ingroup QueueManager
5656
*/
5757
DPCTL_API
58-
__dpctl_give DPCTLSyclQueueRef DPCTLQueueMgr_GetCurrentQueue();
58+
__dpctl_give DPCTLSyclQueueRef DPCTLQueueMgr_GetCurrentQueue(void);
5959

6060
/*!
6161
* @brief Returns true if the global queue set for the queue manager is also the
@@ -72,7 +72,7 @@ __dpctl_give DPCTLSyclQueueRef DPCTLQueueMgr_GetCurrentQueue();
7272
* @ingroup QueueManager
7373
*/
7474
DPCTL_API
75-
bool DPCTLQueueMgr_GlobalQueueIsCurrent();
75+
bool DPCTLQueueMgr_GlobalQueueIsCurrent(void);
7676

7777
/*!
7878
* @brief Check if the queue argument is also the current queue.
@@ -121,7 +121,7 @@ void DPCTLQueueMgr_PushQueue(__dpctl_keep const DPCTLSyclQueueRef QRef);
121121
* @ingroup QueueManager
122122
*/
123123
DPCTL_API
124-
void DPCTLQueueMgr_PopQueue();
124+
void DPCTLQueueMgr_PopQueue(void);
125125

126126
/*!
127127
* @brief A helper function meant for unit testing. Returns the current number
@@ -132,6 +132,6 @@ void DPCTLQueueMgr_PopQueue();
132132
* @ingroup QueueManager
133133
*/
134134
DPCTL_API
135-
size_t DPCTLQueueMgr_GetQueueStackSize();
135+
size_t DPCTLQueueMgr_GetQueueStackSize(void);
136136

137137
DPCTL_C_EXTERN_C_END

dpctl-capi/include/dpctl_vector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ DPCTL_C_EXTERN_C_BEGIN
4747
@return Returns a new opaque pointer to a vector. \
4848
*/ \
4949
DPCTL_API \
50-
__dpctl_give DPCTL##EL##VectorRef DPCTL##EL##Vector_Create(); \
50+
__dpctl_give DPCTL##EL##VectorRef DPCTL##EL##Vector_Create(void); \
5151
/*! \
5252
@brief Create an opaque pointer to a std::vector created from the \
5353
input raw array. The elements of the input array are deep copied before \

dpctl/_backend.pxd

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,15 @@ cdef extern from "dpctl_utils.h":
3434

3535

3636
cdef extern from "dpctl_sycl_enum_types.h":
37-
cdef enum _backend_type 'DPCTLSyclBackendType':
37+
ctypedef enum _backend_type 'DPCTLSyclBackendType':
3838
_ALL_BACKENDS 'DPCTL_ALL_BACKENDS'
3939
_CUDA 'DPCTL_CUDA'
4040
_HOST 'DPCTL_HOST'
4141
_LEVEL_ZERO 'DPCTL_LEVEL_ZERO'
4242
_OPENCL 'DPCTL_OPENCL'
4343
_UNKNOWN_BACKEND 'DPCTL_UNKNOWN_BACKEND'
4444

45-
ctypedef _backend_type DPCTLSyclBackendType
46-
47-
cdef enum _device_type 'DPCTLSyclDeviceType':
45+
ctypedef enum _device_type 'DPCTLSyclDeviceType':
4846
_ACCELERATOR 'DPCTL_ACCELERATOR'
4947
_ALL_DEVICES 'DPCTL_ALL'
5048
_AUTOMATIC 'DPCTL_AUTOMATIC'
@@ -54,9 +52,7 @@ cdef extern from "dpctl_sycl_enum_types.h":
5452
_HOST_DEVICE 'DPCTL_HOST_DEVICE'
5553
_UNKNOWN_DEVICE 'DPCTL_UNKNOWN_DEVICE'
5654

57-
ctypedef _device_type DPCTLSyclDeviceType
58-
59-
cdef enum _arg_data_type 'DPCTLKernelArgType':
55+
ctypedef enum _arg_data_type 'DPCTLKernelArgType':
6056
_CHAR 'DPCTL_CHAR',
6157
_SIGNED_CHAR 'DPCTL_SIGNED_CHAR',
6258
_UNSIGNED_CHAR 'DPCTL_UNSIGNED_CHAR',
@@ -74,14 +70,12 @@ cdef extern from "dpctl_sycl_enum_types.h":
7470
_LONG_DOUBLE 'DPCTL_DOUBLE',
7571
_VOID_PTR 'DPCTL_VOID_PTR'
7672

77-
ctypedef _arg_data_type DPCTLKernelArgType
78-
7973
ctypedef enum _queue_property_type 'DPCTLQueuePropertyType':
8074
_DEFAULT_PROPERTY 'DPCTL_DEFAULT_PROPERTY'
8175
_ENABLE_PROFILING 'DPCTL_ENABLE_PROFILING'
8276
_IN_ORDER 'DPCTL_IN_ORDER'
8377

84-
cdef enum _aspect_type 'DPCTLSyclAspectType':
78+
ctypedef enum _aspect_type 'DPCTLSyclAspectType':
8579
_host 'host',
8680
_cpu 'cpu',
8781
_gpu 'gpu',
@@ -101,10 +95,7 @@ cdef extern from "dpctl_sycl_enum_types.h":
10195
_usm_restricted_shared_allocations 'usm_restricted_shared_allocations',
10296
_usm_system_allocator 'usm_system_allocator'
10397

104-
ctypedef _aspect_type DPCTLSyclAspectType
105-
106-
107-
cdef enum _partition_affinity_domain_type 'DPCTLPartitionAffinityDomainType':
98+
ctypedef enum _partition_affinity_domain_type 'DPCTLPartitionAffinityDomainType':
10899
_not_applicable 'not_applicable',
109100
_numa 'numa',
110101
_L4_cache 'L4_cache',
@@ -113,8 +104,6 @@ cdef extern from "dpctl_sycl_enum_types.h":
113104
_L1_cache 'L1_cache',
114105
_next_partitionable 'next_partitionable',
115106

116-
ctypedef _partition_affinity_domain_type DPCTLPartitionAffinityDomainType
117-
118107

119108
cdef extern from "dpctl_sycl_types.h":
120109
cdef struct DPCTLOpaqueSyclContext
@@ -151,10 +140,8 @@ cdef extern from "dpctl_sycl_device_interface.h":
151140
cdef DPCTLSyclDeviceRef DPCTLDevice_CreateFromSelector(
152141
const DPCTLSyclDeviceSelectorRef DSRef)
153142
cdef void DPCTLDevice_Delete(DPCTLSyclDeviceRef DRef)
154-
cdef DPCTLSyclBackendType DPCTLDevice_GetBackend(
155-
const DPCTLSyclDeviceRef DRef)
156-
cdef DPCTLSyclDeviceType DPCTLDevice_GetDeviceType(
157-
const DPCTLSyclDeviceRef DRef)
143+
cdef _backend_type DPCTLDevice_GetBackend(const DPCTLSyclDeviceRef)
144+
cdef _device_type DPCTLDevice_GetDeviceType(const DPCTLSyclDeviceRef)
158145
cdef const char *DPCTLDevice_GetDriverVersion(const DPCTLSyclDeviceRef DRef)
159146
cdef uint32_t DPCTLDevice_GetMaxComputeUnits(const DPCTLSyclDeviceRef DRef)
160147
cdef uint32_t DPCTLDevice_GetMaxNumSubGroups(const DPCTLSyclDeviceRef DRef)
@@ -178,8 +165,7 @@ cdef extern from "dpctl_sycl_device_interface.h":
178165
cdef uint32_t DPCTLDevice_GetPreferredVectorWidthFloat(const DPCTLSyclDeviceRef DRef)
179166
cdef uint32_t DPCTLDevice_GetPreferredVectorWidthDouble(const DPCTLSyclDeviceRef DRef)
180167
cdef uint32_t DPCTLDevice_GetPreferredVectorWidthHalf(const DPCTLSyclDeviceRef DRef)
181-
cpdef bool DPCTLDevice_HasAspect(
182-
const DPCTLSyclDeviceRef DRef, DPCTLSyclAspectType AT)
168+
cpdef bool DPCTLDevice_HasAspect(const DPCTLSyclDeviceRef, _aspect_type)
183169
cdef uint32_t DPCTLDevice_GetMaxReadImageArgs(const DPCTLSyclDeviceRef DRef)
184170
cdef uint32_t DPCTLDevice_GetMaxWriteImageArgs(const DPCTLSyclDeviceRef DRef)
185171
cdef size_t DPCTLDevice_GetImage2dMaxWidth(const DPCTLSyclDeviceRef DRef)
@@ -193,7 +179,7 @@ cdef extern from "dpctl_sycl_device_interface.h":
193179
const DPCTLSyclDeviceRef DRef, size_t *counts, size_t ncounts)
194180
cdef DPCTLDeviceVectorRef DPCTLDevice_CreateSubDevicesByAffinity(
195181
const DPCTLSyclDeviceRef DRef,
196-
DPCTLPartitionAffinityDomainType PartitionAffinityDomainTy)
182+
_partition_affinity_domain_type PartitionAffinityDomainTy)
197183
cdef DPCTLSyclDeviceRef DPCTLDevice_GetParentDevice(const DPCTLSyclDeviceRef DRef)
198184

199185

@@ -259,8 +245,7 @@ cdef extern from "dpctl_sycl_platform_interface.h":
259245
cdef DPCTLSyclPlatformRef DPCTLPlatform_CreateFromSelector(
260246
const DPCTLSyclDeviceSelectorRef)
261247
cdef void DPCTLPlatform_Delete(DPCTLSyclPlatformRef)
262-
cdef DPCTLSyclBackendType DPCTLPlatform_GetBackend(
263-
const DPCTLSyclPlatformRef)
248+
cdef _backend_type DPCTLPlatform_GetBackend(const DPCTLSyclPlatformRef)
264249
cdef const char *DPCTLPlatform_GetName(const DPCTLSyclPlatformRef)
265250
cdef const char *DPCTLPlatform_GetVendor(const DPCTLSyclPlatformRef)
266251
cdef const char *DPCTLPlatform_GetVersion(const DPCTLSyclPlatformRef)
@@ -283,8 +268,7 @@ cdef extern from "dpctl_sycl_context_interface.h":
283268
cdef size_t DPCTLContext_DeviceCount(const DPCTLSyclContextRef CRef)
284269
cdef bool DPCTLContext_AreEq(const DPCTLSyclContextRef CtxRef1,
285270
const DPCTLSyclContextRef CtxRef2)
286-
cdef DPCTLSyclBackendType DPCTLContext_GetBackend(
287-
const DPCTLSyclContextRef CtxRef)
271+
cdef _backend_type DPCTLContext_GetBackend(const DPCTLSyclContextRef)
288272
cdef void DPCTLContext_Delete(DPCTLSyclContextRef CtxRef)
289273

290274

@@ -320,14 +304,14 @@ cdef extern from "dpctl_sycl_queue_interface.h":
320304
int properties)
321305
cdef void DPCTLQueue_Delete(DPCTLSyclQueueRef QRef)
322306
cdef DPCTLSyclQueueRef DPCTLQueue_Copy(DPCTLSyclQueueRef QRef)
323-
cdef DPCTLSyclBackendType DPCTLQueue_GetBackend(const DPCTLSyclQueueRef Q)
307+
cdef _backend_type DPCTLQueue_GetBackend(const DPCTLSyclQueueRef Q)
324308
cdef DPCTLSyclContextRef DPCTLQueue_GetContext(const DPCTLSyclQueueRef Q)
325309
cdef DPCTLSyclDeviceRef DPCTLQueue_GetDevice(const DPCTLSyclQueueRef Q)
326310
cdef DPCTLSyclEventRef DPCTLQueue_SubmitRange(
327311
const DPCTLSyclKernelRef Ref,
328312
const DPCTLSyclQueueRef QRef,
329313
void **Args,
330-
const DPCTLKernelArgType *ArgTypes,
314+
const _arg_data_type *ArgTypes,
331315
size_t NArgs,
332316
const size_t Range[3],
333317
size_t NDims,
@@ -337,7 +321,7 @@ cdef extern from "dpctl_sycl_queue_interface.h":
337321
const DPCTLSyclKernelRef Ref,
338322
const DPCTLSyclQueueRef QRef,
339323
void **Args,
340-
const DPCTLKernelArgType *ArgTypes,
324+
const _arg_data_type *ArgTypes,
341325
size_t NArgs,
342326
const size_t gRange[3],
343327
const size_t lRange[3],

0 commit comments

Comments
 (0)