Skip to content

Commit fe02ce7

Browse files
committed
Include stddef.h and use size_t in dpctl4pybind11
1 parent 753226a commit fe02ce7

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

dpctl/apis/include/dpctl4pybind11.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
#include "dpctl_capi.h"
2929
#include <complex>
30-
#include <cstddef>
3130
#include <memory>
3231
#include <pybind11/pybind11.h>
32+
#include <stddef.h>
3333
#include <stdexcept>
3434
#include <sycl/sycl.hpp>
3535
#include <utility>
@@ -94,9 +94,9 @@ class dpctl_capi
9494
void *(*Memory_GetOpaquePointer_)(Py_MemoryObject *);
9595
DPCTLSyclContextRef (*Memory_GetContextRef_)(Py_MemoryObject *);
9696
DPCTLSyclQueueRef (*Memory_GetQueueRef_)(Py_MemoryObject *);
97-
std::size_t (*Memory_GetNumBytes_)(Py_MemoryObject *);
97+
size_t (*Memory_GetNumBytes_)(Py_MemoryObject *);
9898
PyObject *(*Memory_Make_)(DPCTLSyclUSMRef,
99-
std::size_t,
99+
size_t,
100100
DPCTLSyclQueueRef,
101101
PyObject *);
102102

@@ -126,7 +126,7 @@ class dpctl_capi
126126
Py_MemoryObject *,
127127
py::ssize_t,
128128
char);
129-
PyObject *(*UsmNDArray_MakeSimpleFromPtr_)(std::size_t,
129+
PyObject *(*UsmNDArray_MakeSimpleFromPtr_)(size_t,
130130
int,
131131
DPCTLSyclUSMRef,
132132
DPCTLSyclQueueRef,
@@ -760,7 +760,7 @@ class usm_memory : public py::object
760760
* lifetime of the USM allocation.
761761
*/
762762
usm_memory(void *usm_ptr,
763-
std::size_t nbytes,
763+
size_t nbytes,
764764
const sycl::queue &q,
765765
std::shared_ptr<void> shptr)
766766
{
@@ -820,7 +820,7 @@ class usm_memory : public py::object
820820
return reinterpret_cast<char *>(MRef);
821821
}
822822

823-
std::size_t get_nbytes() const
823+
size_t get_nbytes() const
824824
{
825825
auto const &api = ::dpctl::detail::dpctl_capi::get();
826826
Py_MemoryObject *mem_obj = reinterpret_cast<Py_MemoryObject *>(m_ptr);
@@ -1259,18 +1259,18 @@ struct ManagedMemory
12591259

12601260
} // end of namespace detail
12611261

1262-
template <std::size_t num>
1262+
template <size_t num>
12631263
sycl::event keep_args_alive(sycl::queue &q,
12641264
const py::object (&py_objs)[num],
12651265
const std::vector<sycl::event> &depends = {})
12661266
{
1267-
std::size_t n_objects_held = 0;
1267+
size_t n_objects_held = 0;
12681268
std::array<std::shared_ptr<py::handle>, num> shp_arr{};
12691269

1270-
std::size_t n_usm_owners_held = 0;
1270+
size_t n_usm_owners_held = 0;
12711271
std::array<std::shared_ptr<void>, num> shp_usm{};
12721272

1273-
for (std::size_t i = 0; i < num; ++i) {
1273+
for (size_t i = 0; i < num; ++i) {
12741274
const auto &py_obj_i = py_objs[i];
12751275
if (detail::ManagedMemory::is_usm_managed_by_shared_ptr(py_obj_i)) {
12761276
const auto &shp =
@@ -1317,7 +1317,7 @@ sycl::event keep_args_alive(sycl::queue &q,
13171317
cgh.host_task([n_objects_held, shp_arr = std::move(shp_arr)]() {
13181318
py::gil_scoped_acquire acquire;
13191319

1320-
for (std::size_t i = 0; i < n_objects_held; ++i) {
1320+
for (size_t i = 0; i < n_objects_held; ++i) {
13211321
shp_arr[i]->dec_ref();
13221322
}
13231323
});
@@ -1329,11 +1329,11 @@ sycl::event keep_args_alive(sycl::queue &q,
13291329

13301330
/*! @brief Check if all allocation queues are the same as the
13311331
execution queue */
1332-
template <std::size_t num>
1332+
template <size_t num>
13331333
bool queues_are_compatible(const sycl::queue &exec_q,
13341334
const sycl::queue (&alloc_qs)[num])
13351335
{
1336-
for (std::size_t i = 0; i < num; ++i) {
1336+
for (size_t i = 0; i < num; ++i) {
13371337

13381338
if (exec_q != alloc_qs[i]) {
13391339
return false;
@@ -1344,11 +1344,11 @@ bool queues_are_compatible(const sycl::queue &exec_q,
13441344

13451345
/*! @brief Check if all allocation queues of usm_ndarays are the same as
13461346
the execution queue */
1347-
template <std::size_t num>
1347+
template <size_t num>
13481348
bool queues_are_compatible(const sycl::queue &exec_q,
13491349
const ::dpctl::tensor::usm_ndarray (&arrs)[num])
13501350
{
1351-
for (std::size_t i = 0; i < num; ++i) {
1351+
for (size_t i = 0; i < num; ++i) {
13521352

13531353
if (exec_q != arrs[i].get_queue()) {
13541354
return false;

0 commit comments

Comments
 (0)