Skip to content

Commit

Permalink
Include stddef.h and use size_t in dpctl4pybind11
Browse files Browse the repository at this point in the history
  • Loading branch information
ndgrigorian committed Dec 30, 2024
1 parent 753226a commit fe02ce7
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions dpctl/apis/include/dpctl4pybind11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

#include "dpctl_capi.h"
#include <complex>
#include <cstddef>
#include <memory>
#include <pybind11/pybind11.h>
#include <stddef.h>
#include <stdexcept>
#include <sycl/sycl.hpp>
#include <utility>
Expand Down Expand Up @@ -94,9 +94,9 @@ class dpctl_capi
void *(*Memory_GetOpaquePointer_)(Py_MemoryObject *);
DPCTLSyclContextRef (*Memory_GetContextRef_)(Py_MemoryObject *);
DPCTLSyclQueueRef (*Memory_GetQueueRef_)(Py_MemoryObject *);
std::size_t (*Memory_GetNumBytes_)(Py_MemoryObject *);
size_t (*Memory_GetNumBytes_)(Py_MemoryObject *);
PyObject *(*Memory_Make_)(DPCTLSyclUSMRef,
std::size_t,
size_t,
DPCTLSyclQueueRef,
PyObject *);

Expand Down Expand Up @@ -126,7 +126,7 @@ class dpctl_capi
Py_MemoryObject *,
py::ssize_t,
char);
PyObject *(*UsmNDArray_MakeSimpleFromPtr_)(std::size_t,
PyObject *(*UsmNDArray_MakeSimpleFromPtr_)(size_t,
int,
DPCTLSyclUSMRef,
DPCTLSyclQueueRef,
Expand Down Expand Up @@ -760,7 +760,7 @@ class usm_memory : public py::object
* lifetime of the USM allocation.
*/
usm_memory(void *usm_ptr,
std::size_t nbytes,
size_t nbytes,
const sycl::queue &q,
std::shared_ptr<void> shptr)
{
Expand Down Expand Up @@ -820,7 +820,7 @@ class usm_memory : public py::object
return reinterpret_cast<char *>(MRef);
}

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

} // end of namespace detail

template <std::size_t num>
template <size_t num>
sycl::event keep_args_alive(sycl::queue &q,
const py::object (&py_objs)[num],
const std::vector<sycl::event> &depends = {})
{
std::size_t n_objects_held = 0;
size_t n_objects_held = 0;
std::array<std::shared_ptr<py::handle>, num> shp_arr{};

std::size_t n_usm_owners_held = 0;
size_t n_usm_owners_held = 0;
std::array<std::shared_ptr<void>, num> shp_usm{};

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

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

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

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

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

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

0 comments on commit fe02ce7

Please sign in to comment.