-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Porting dispatch vector into numba-dpex, working on building generic …
…pointer
- Loading branch information
1 parent
5924b4f
commit 6173e73
Showing
7 changed files
with
142 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef __DISPATCH_VECTOR_HPP__ | ||
#define __DISPATCH_VECTOR_HPP__ | ||
|
||
namespace ndpx | ||
{ | ||
namespace runtime | ||
{ | ||
namespace dispatch_vector | ||
{ | ||
|
||
template <typename funcPtrT, | ||
template <typename fnT, typename T> | ||
typename factory, | ||
int _num_types> | ||
class DispatchVectorBuilder | ||
{ | ||
private: | ||
template <typename Ty> const funcPtrT func_per_type() const | ||
{ | ||
funcPtrT f = factory<funcPtrT, Ty>{}.get(); | ||
return f; | ||
} | ||
|
||
public: | ||
DispatchVectorBuilder() = default; | ||
~DispatchVectorBuilder() = default; | ||
|
||
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<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) { | ||
vector[ty_id] = fn; | ||
++ty_id; | ||
} | ||
} | ||
}; | ||
|
||
} // namespace dispatch_vector | ||
} // namespace runtime | ||
} // namespace ndpx | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,25 @@ | ||
#include "linear_sequences.hpp" | ||
#include "dispatch_vector.hpp" | ||
#include "type_utils.hpp" | ||
|
||
// using dpctl::tensor::kernels::constructors::lin_space_step_fn_ptr_t; | ||
// static lin_space_step_fn_ptr_t | ||
// lin_space_step_dispatch_vector[ndpx::runtime::type_utils::num_types]; | ||
|
||
void init_linear_sequences_dispatch_vectors(void) | ||
{ | ||
using ndpx::runtime::dispatch_vector::DispatchVectorBuilder; | ||
using ndpx::runtime::type_utils::num_types; | ||
// using dpctl::tensor::kernels::constructors::LinSpaceAffineFactory; | ||
using ndpx::runtime::tensor::LinSpaceStepFactory; | ||
|
||
// DispatchVectorBuilder<lin_space_step_fn_ptr_t, LinSpaceStepFactory, | ||
// num_types> | ||
// dvb1; | ||
// dvb1.populate_dispatch_vector(lin_space_step_dispatch_vector); | ||
|
||
// DispatchVectorBuilder<lin_space_affine_fn_ptr_t, LinSpaceAffineFactory, | ||
// num_types> | ||
// dvb2; | ||
// dvb2.populate_dispatch_vector(lin_space_affine_dispatch_vector); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters