Skip to content

Commit

Permalink
Merge pull request #1955 from IntelPython/additional-qualified-cpp-types
Browse files Browse the repository at this point in the history
Additional qualified cpp types
  • Loading branch information
oleksandr-pavlyk authored Jan 6, 2025
2 parents 64ec889 + 5c92afe commit 1eebdf2
Show file tree
Hide file tree
Showing 18 changed files with 178 additions and 151 deletions.
2 changes: 1 addition & 1 deletion dpctl/tensor/libtensor/include/kernels/clip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ClipContigFunctor
const std::uint16_t sgSize =
ndit.get_sub_group().get_local_range()[0];
const std::size_t gid = ndit.get_global_linear_id();
const uint16_t nelems_per_sg = sgSize * nelems_per_wi;
const std::uint16_t nelems_per_sg = sgSize * nelems_per_wi;

const std::size_t start =
(gid / sgSize) * (nelems_per_sg - sgSize) + gid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ using ConjStridedFunctor = elementwise_common::
template <typename T> struct ConjOutputType
{
using value_type = typename std::disjunction<
td_ns::TypeMapResultEntry<T, bool, int8_t>,
td_ns::TypeMapResultEntry<T, bool, std::int8_t>,
td_ns::TypeMapResultEntry<T, std::uint8_t>,
td_ns::TypeMapResultEntry<T, std::uint16_t>,
td_ns::TypeMapResultEntry<T, std::uint32_t>,
Expand Down
2 changes: 1 addition & 1 deletion dpctl/tensor/libtensor/include/utils/sycl_alloc_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ sycl::event async_smart_free(sycl::queue &exec_q,
cgh.depends_on(depends);

cgh.host_task([ptrs, dels]() {
for (size_t i = 0; i < ptrs.size(); ++i) {
for (std::size_t i = 0; i < ptrs.size(); ++i) {
dels[i](ptrs[i]);
}
});
Expand Down
55 changes: 28 additions & 27 deletions dpctl/tensor/libtensor/include/utils/type_dispatch_building.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#pragma once

#include <complex>
#include <cstdint>
#include <type_traits>

#include <sycl/sycl.hpp>
Expand Down Expand Up @@ -69,14 +70,14 @@ class DispatchTableBuilder
{
std::vector<funcPtrT> per_dstTy = {
factory<funcPtrT, dstTy, bool>{}.get(),
factory<funcPtrT, dstTy, int8_t>{}.get(),
factory<funcPtrT, dstTy, uint8_t>{}.get(),
factory<funcPtrT, dstTy, int16_t>{}.get(),
factory<funcPtrT, dstTy, uint16_t>{}.get(),
factory<funcPtrT, dstTy, int32_t>{}.get(),
factory<funcPtrT, dstTy, uint32_t>{}.get(),
factory<funcPtrT, dstTy, int64_t>{}.get(),
factory<funcPtrT, dstTy, uint64_t>{}.get(),
factory<funcPtrT, dstTy, std::int8_t>{}.get(),
factory<funcPtrT, dstTy, std::uint8_t>{}.get(),
factory<funcPtrT, dstTy, std::int16_t>{}.get(),
factory<funcPtrT, dstTy, std::uint16_t>{}.get(),
factory<funcPtrT, dstTy, std::int32_t>{}.get(),
factory<funcPtrT, dstTy, std::uint32_t>{}.get(),
factory<funcPtrT, dstTy, std::int64_t>{}.get(),
factory<funcPtrT, dstTy, std::uint64_t>{}.get(),
factory<funcPtrT, dstTy, sycl::half>{}.get(),
factory<funcPtrT, dstTy, float>{}.get(),
factory<funcPtrT, dstTy, double>{}.get(),
Expand All @@ -93,24 +94,24 @@ class DispatchTableBuilder
void populate_dispatch_table(funcPtrT table[][_num_types]) const
{
const auto map_by_dst_type = {row_per_dst_type<bool>(),
row_per_dst_type<int8_t>(),
row_per_dst_type<uint8_t>(),
row_per_dst_type<int16_t>(),
row_per_dst_type<uint16_t>(),
row_per_dst_type<int32_t>(),
row_per_dst_type<uint32_t>(),
row_per_dst_type<int64_t>(),
row_per_dst_type<uint64_t>(),
row_per_dst_type<std::int8_t>(),
row_per_dst_type<std::uint8_t>(),
row_per_dst_type<std::int16_t>(),
row_per_dst_type<std::uint16_t>(),
row_per_dst_type<std::int32_t>(),
row_per_dst_type<std::uint32_t>(),
row_per_dst_type<std::int64_t>(),
row_per_dst_type<std::uint64_t>(),
row_per_dst_type<sycl::half>(),
row_per_dst_type<float>(),
row_per_dst_type<double>(),
row_per_dst_type<std::complex<float>>(),
row_per_dst_type<std::complex<double>>()};
assert(map_by_dst_type.size() == _num_types);
int dst_id = 0;
for (auto &row : map_by_dst_type) {
for (const auto &row : map_by_dst_type) {
int src_id = 0;
for (auto &fn_ptr : row) {
for (const auto &fn_ptr : row) {
table[dst_id][src_id] = fn_ptr;
++src_id;
}
Expand Down Expand Up @@ -139,22 +140,22 @@ class DispatchVectorBuilder
void populate_dispatch_vector(funcPtrT vector[]) const
{
const auto fn_map_by_type = {func_per_type<bool>(),
func_per_type<int8_t>(),
func_per_type<uint8_t>(),
func_per_type<int16_t>(),
func_per_type<uint16_t>(),
func_per_type<int32_t>(),
func_per_type<uint32_t>(),
func_per_type<int64_t>(),
func_per_type<uint64_t>(),
func_per_type<std::int8_t>(),
func_per_type<std::uint8_t>(),
func_per_type<std::int16_t>(),
func_per_type<std::uint16_t>(),
func_per_type<std::int32_t>(),
func_per_type<std::uint32_t>(),
func_per_type<std::int64_t>(),
func_per_type<std::uint64_t>(),
func_per_type<sycl::half>(),
func_per_type<float>(),
func_per_type<double>(),
func_per_type<std::complex<float>>(),
func_per_type<std::complex<double>>()};
assert(fn_map_by_type.size() == _num_types);
int ty_id = 0;
for (auto &fn : fn_map_by_type) {
for (const auto &fn : fn_map_by_type) {
vector[ty_id] = fn;
++ty_id;
}
Expand Down
4 changes: 2 additions & 2 deletions dpctl/tensor/libtensor/source/integer_advanced_indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ usm_ndarray_take(const dpctl::tensor::usm_ndarray &src,
const py::object &py_ind,
const dpctl::tensor::usm_ndarray &dst,
int axis_start,
uint8_t mode,
std::uint8_t mode,
sycl::queue &exec_q,
const std::vector<sycl::event> &depends)
{
Expand Down Expand Up @@ -560,7 +560,7 @@ usm_ndarray_put(const dpctl::tensor::usm_ndarray &dst,
const py::object &py_ind,
const dpctl::tensor::usm_ndarray &val,
int axis_start,
uint8_t mode,
std::uint8_t mode,
sycl::queue &exec_q,
const std::vector<sycl::event> &depends)
{
Expand Down
4 changes: 2 additions & 2 deletions dpctl/tensor/libtensor/source/integer_advanced_indexing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ usm_ndarray_take(const dpctl::tensor::usm_ndarray &,
const py::object &,
const dpctl::tensor::usm_ndarray &,
int,
uint8_t,
std::uint8_t,
sycl::queue &,
const std::vector<sycl::event> & = {});

Expand All @@ -52,7 +52,7 @@ usm_ndarray_put(const dpctl::tensor::usm_ndarray &,
const py::object &,
const dpctl::tensor::usm_ndarray &,
int,
uint8_t,
std::uint8_t,
sycl::queue &,
const std::vector<sycl::event> & = {});

Expand Down
42 changes: 23 additions & 19 deletions libsyclinterface/source/dpctl_sycl_queue_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@
#include "dpctl_sycl_device_interface.h"
#include "dpctl_sycl_device_manager.h"
#include "dpctl_sycl_type_casters.hpp"

#include <stddef.h>
#include <stdint.h>

#include <cstdint>
#include <exception>
#include <sstream>
#include <stddef.h>
#include <stdexcept>
#include <sycl/sycl.hpp> /* SYCL headers */
#include <utility>
Expand All @@ -45,49 +49,49 @@ using namespace sycl;
switch ((ARGTY)) { \
case DPCTL_INT8_T: \
{ \
auto la = local_accessor<int8_t, NDIM>(R, CGH); \
auto la = local_accessor<std::int8_t, NDIM>(R, CGH); \
CGH.set_arg(IDX, la); \
return true; \
} \
case DPCTL_UINT8_T: \
{ \
auto la = local_accessor<uint8_t, NDIM>(R, CGH); \
auto la = local_accessor<std::uint8_t, NDIM>(R, CGH); \
CGH.set_arg(IDX, la); \
return true; \
} \
case DPCTL_INT16_T: \
{ \
auto la = local_accessor<int16_t, NDIM>(R, CGH); \
auto la = local_accessor<std::int16_t, NDIM>(R, CGH); \
CGH.set_arg(IDX, la); \
return true; \
} \
case DPCTL_UINT16_T: \
{ \
auto la = local_accessor<uint16_t, NDIM>(R, CGH); \
auto la = local_accessor<std::uint16_t, NDIM>(R, CGH); \
CGH.set_arg(IDX, la); \
return true; \
} \
case DPCTL_INT32_T: \
{ \
auto la = local_accessor<int32_t, NDIM>(R, CGH); \
auto la = local_accessor<std::int32_t, NDIM>(R, CGH); \
CGH.set_arg(IDX, la); \
return true; \
} \
case DPCTL_UINT32_T: \
{ \
auto la = local_accessor<uint32_t, NDIM>(R, CGH); \
auto la = local_accessor<std::uint32_t, NDIM>(R, CGH); \
CGH.set_arg(IDX, la); \
return true; \
} \
case DPCTL_INT64_T: \
{ \
auto la = local_accessor<int64_t, NDIM>(R, CGH); \
auto la = local_accessor<std::int64_t, NDIM>(R, CGH); \
CGH.set_arg(IDX, la); \
return true; \
} \
case DPCTL_UINT64_T: \
{ \
auto la = local_accessor<uint64_t, NDIM>(R, CGH); \
auto la = local_accessor<std::uint64_t, NDIM>(R, CGH); \
CGH.set_arg(IDX, la); \
return true; \
} \
Expand Down Expand Up @@ -119,8 +123,8 @@ using namespace dpctl::syclinterface;

typedef struct complex
{
uint64_t real;
uint64_t imag;
std::uint64_t real;
std::uint64_t imag;
} complexNumber;

void set_dependent_events(handler &cgh,
Expand Down Expand Up @@ -177,28 +181,28 @@ bool set_kernel_arg(handler &cgh,

switch (ArgTy) {
case DPCTL_INT8_T:
cgh.set_arg(idx, *(int8_t *)Arg);
cgh.set_arg(idx, *(std::int8_t *)Arg);
break;
case DPCTL_UINT8_T:
cgh.set_arg(idx, *(uint8_t *)Arg);
cgh.set_arg(idx, *(std::uint8_t *)Arg);
break;
case DPCTL_INT16_T:
cgh.set_arg(idx, *(int16_t *)Arg);
cgh.set_arg(idx, *(std::int16_t *)Arg);
break;
case DPCTL_UINT16_T:
cgh.set_arg(idx, *(uint16_t *)Arg);
cgh.set_arg(idx, *(std::uint16_t *)Arg);
break;
case DPCTL_INT32_T:
cgh.set_arg(idx, *(int32_t *)Arg);
cgh.set_arg(idx, *(std::int32_t *)Arg);
break;
case DPCTL_UINT32_T:
cgh.set_arg(idx, *(uint32_t *)Arg);
cgh.set_arg(idx, *(std::uint32_t *)Arg);
break;
case DPCTL_INT64_T:
cgh.set_arg(idx, *(int64_t *)Arg);
cgh.set_arg(idx, *(std::int64_t *)Arg);
break;
case DPCTL_UINT64_T:
cgh.set_arg(idx, *(uint64_t *)Arg);
cgh.set_arg(idx, *(std::uint64_t *)Arg);
break;
case DPCTL_FLOAT32_T:
cgh.set_arg(idx, *(float *)Arg);
Expand Down
4 changes: 3 additions & 1 deletion libsyclinterface/tests/test_sycl_context_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
#include "dpctl_sycl_device_interface.h"
#include "dpctl_sycl_device_selector_interface.h"
#include "dpctl_sycl_types.h"
#include <gtest/gtest.h>

#include <stddef.h>

#include <gtest/gtest.h>
#include <sycl/sycl.hpp>
#include <vector>

Expand Down
4 changes: 3 additions & 1 deletion libsyclinterface/tests/test_sycl_device_aspects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
#include "dpctl_sycl_enum_types.h"
#include "dpctl_sycl_type_casters.hpp"
#include "dpctl_utils_helper.h"
#include <gtest/gtest.h>

#include <stddef.h>

#include <gtest/gtest.h>
#include <sycl/sycl.hpp>
#include <utility>

Expand Down
4 changes: 3 additions & 1 deletion libsyclinterface/tests/test_sycl_device_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
#include "dpctl_sycl_platform_interface.h"
#include "dpctl_utils.h"
#include "dpctl_utils_helper.h"
#include <gtest/gtest.h>

#include <stddef.h>

#include <gtest/gtest.h>
#include <sycl/sycl.hpp>

using namespace sycl;
Expand Down
4 changes: 3 additions & 1 deletion libsyclinterface/tests/test_sycl_device_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
#include "dpctl_sycl_device_selector_interface.h"
#include "dpctl_utils.h"
#include "dpctl_utils_helper.h"
#include <gtest/gtest.h>

#include <stddef.h>

#include <gtest/gtest.h>
#include <string>

using dpctl::syclinterface::dpctl_default_selector;
Expand Down
5 changes: 3 additions & 2 deletions libsyclinterface/tests/test_sycl_device_subdevices.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//===--- test_sycl_device_interface.cpp - Test cases for device interface ===//
//
// Data Parallel Control (dpCtl)
Expand Down Expand Up @@ -32,8 +31,10 @@
#include "dpctl_sycl_type_casters.hpp"
#include "dpctl_utils.h"
#include "dpctl_utils_helper.h"
#include <gtest/gtest.h>

#include <stddef.h>

#include <gtest/gtest.h>
#include <sycl/sycl.hpp>

using namespace sycl;
Expand Down
4 changes: 3 additions & 1 deletion libsyclinterface/tests/test_sycl_kernel_bundle_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@
#include "dpctl_sycl_kernel_bundle_interface.h"
#include "dpctl_sycl_kernel_interface.h"
#include "dpctl_sycl_queue_interface.h"

#include <stddef.h>

#include <array>
#include <filesystem>
#include <fstream>
#include <gtest/gtest.h>
#include <stddef.h>
#include <sycl/sycl.hpp>

using namespace sycl;
Expand Down
4 changes: 3 additions & 1 deletion libsyclinterface/tests/test_sycl_kernel_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
#include "dpctl_sycl_kernel_interface.h"
#include "dpctl_sycl_queue_interface.h"
#include "dpctl_utils.h"

#include <stddef.h>

#include <array>
#include <gtest/gtest.h>
#include <stddef.h>
#include <sycl/sycl.hpp>

using namespace sycl;
Expand Down
4 changes: 3 additions & 1 deletion libsyclinterface/tests/test_sycl_queue_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
#include "dpctl_sycl_queue_interface.h"
#include "dpctl_sycl_type_casters.hpp"
#include "dpctl_sycl_usm_interface.h"
#include <gtest/gtest.h>

#include <stddef.h>

#include <gtest/gtest.h>
#include <sycl/sycl.hpp>

using namespace sycl;
Expand Down
Loading

0 comments on commit 1eebdf2

Please sign in to comment.