Skip to content

Commit

Permalink
Added unspecialized array populating functions
Browse files Browse the repository at this point in the history
  • Loading branch information
chudur-budur committed Oct 20, 2023
1 parent 053347f commit 190f90b
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 5 deletions.
3 changes: 3 additions & 0 deletions numba_dpex/core/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ find_package(Dpctl REQUIRED)
find_package(NumPy REQUIRED)
find_package(IntelSYCL REQUIRED)

message(STATUS "==========> NumPy_INCLUDE_DIRS =" "${NumPy_INCLUDE_DIRS}")
message(STATUS "==========> Numba_INCLUDE_DIRS =" "${Numba_INCLUDE_DIRS}")

# Includes
include(GNUInstallDirs)
include_directories(${Python_INCLUDE_DIRS})
Expand Down
3 changes: 3 additions & 0 deletions numba_dpex/core/runtime/kernels/api.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include "dpctl_capi.h"
#include "dpctl_sycl_interface.h"

#ifdef __cplusplus
extern "C"
{
Expand Down
3 changes: 3 additions & 0 deletions numba_dpex/core/runtime/kernels/dispatch.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef __DISPATCH_HPP__
#define __DISPATCH_HPP__

#include <CL/sycl.hpp>
#include <complex>

namespace ndpx
{
namespace runtime
Expand Down
101 changes: 98 additions & 3 deletions numba_dpex/core/runtime/kernels/sequences.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#include <iostream>
#include <stdexcept>

#include "sequences.hpp"
#include "api.h"
#include "dispatch.hpp"

#include "types.hpp"
#include <iostream>

#include "dispatch.hpp"

#include <numpy/npy_common.h>

#include "api.h"

static ndpx::runtime::kernel::tensor::sequence_step_ptr_t
sequence_step_dispatch_vector[ndpx::runtime::kernel::types::num_types];
Expand Down Expand Up @@ -32,3 +39,91 @@ void init_affine_sequence_dispatch_vectors(void)
dvb.populate_dispatch_vector(affine_sequence_step_dispatch_vector);
std::cout << "-----> init_affine_sequence_dispatch_vectors()" << std::endl;
}

uint ndpx::runtime::kernel::tensor::populate_arystruct_sequence(
void *start,
void *dt,
arystruct_t *dst,
int ndim,
int is_c_contiguous,
const DPCTLSyclQueueRef exec_q,
const DPCTLEventVectorRef depends)
{
if (ndim != 1) {
throw std::logic_error(
"populate_arystruct_linseq(): array must be 1D.");
}
if (!is_c_contiguous) {
throw std::logic_error(
"populate_arystruct_linseq(): array must be c-contiguous.");
}

/**
auto array_types = td_ns::usm_ndarray_types();
int dst_typenum = dst.get_typenum();
int dst_typeid = array_types.typenum_to_lookup_id(dst_typenum);
py::ssize_t len = dst.get_shape(0);
if (len == 0) {
// nothing to do
return std::make_pair(sycl::event{}, sycl::event{});
}
char *dst_data = reinterpret_cast<char*>(dst->data);
sycl::event linspace_step_event;
auto fn = lin_space_step_dispatch_vector[dst_typeid];
linspace_step_event =
fn(exec_q, static_cast<size_t>(len), start, dt, dst_data, depends);
return std::make_pair(keep_args_alive(exec_q, {dst}, {linspace_step_event}),
linspace_step_event);
*/

return 0;
}

uint ndpx::runtime::kernel::tensor::populate_arystruct_affine_sequence(
void *start,
void *end,
arystruct_t *dst,
int include_endpoint,
int ndim,
int is_c_contiguous,
const DPCTLSyclQueueRef exec_q,
const DPCTLEventVectorRef depends)
{
if (ndim != 1) {
throw std::logic_error(
"populate_arystruct_linseq(): array must be 1D.");
}
if (!is_c_contiguous) {
throw std::logic_error(
"populate_arystruct_linseq(): array must be c-contiguous.");
}
/**
auto array_types = td_ns::usm_ndarray_types();
int dst_typenum = dst.get_typenum();
int dst_typeid = array_types.typenum_to_lookup_id(dst_typenum);
py::ssize_t len = dst.get_shape(0);
if (len == 0) {
// nothing to do
return std::make_pair(sycl::event{}, sycl::event{});
}
char *dst_data = dst.get_data();
sycl::event linspace_affine_event;
auto fn = lin_space_affine_dispatch_vector[dst_typeid];
linspace_affine_event = fn(exec_q, static_cast<size_t>(len), start, end,
include_endpoint, dst_data, depends);
return std::make_pair(
keep_args_alive(exec_q, {dst}, {linspace_affine_event}),
linspace_affine_event);
*/
return 0;
}
30 changes: 28 additions & 2 deletions numba_dpex/core/runtime/kernels/sequences.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#ifndef __SEQUENCES_HPP__
#define __SEQUENCES_HPP__

#include "types.hpp"
#include <CL/sycl.hpp>
#include <complex>
#include <exception>
#include <iostream>

#include <numpy/npy_common.h>

#include <Python.h>

#include <numba/_arraystruct.h>

#include "dpctl_capi.h"
#include "dpctl_sycl_interface.h"

#include "types.hpp"

namespace ndpx
{
namespace runtime
Expand Down Expand Up @@ -227,6 +236,23 @@ typedef sycl::event (*affine_sequence_step_ptr_t)(
char *, // dst_data_ptr
const std::vector<sycl::event> &);

uint populate_arystruct_sequence(void *start,
void *dt,
arystruct_t *dst,
int ndim,
int is_c_contiguous,
const DPCTLSyclQueueRef exec_q,
const DPCTLEventVectorRef depends);

uint populate_arystruct_affine_sequence(void *start,
void *end,
arystruct_t *dst,
int include_endpoint,
int ndim,
int is_c_contiguous,
const DPCTLSyclQueueRef exec_q,
const DPCTLEventVectorRef depends);

} // namespace tensor
} // namespace kernel
} // namespace runtime
Expand Down

0 comments on commit 190f90b

Please sign in to comment.