@@ -57,10 +57,10 @@ template <
|
||||
std::size_t n,
|
||||
typename... Ts,
|
||||
typename std::enable_if<n == sizeof...(Ts)>::type* = nullptr>
|
||||
inline std::vector<std::uint8_t> make_kernarg(
|
||||
inline hip_impl::kernarg make_kernarg(
|
||||
const std::tuple<Ts...>&,
|
||||
const kernargs_size_align&,
|
||||
std::vector<std::uint8_t> kernarg) {
|
||||
hip_impl::kernarg kernarg) {
|
||||
return kernarg;
|
||||
}
|
||||
|
||||
@@ -68,10 +68,10 @@ template <
|
||||
std::size_t n,
|
||||
typename... Ts,
|
||||
typename std::enable_if<n != sizeof...(Ts)>::type* = nullptr>
|
||||
inline std::vector<std::uint8_t> make_kernarg(
|
||||
inline hip_impl::kernarg make_kernarg(
|
||||
const std::tuple<Ts...>& formals,
|
||||
const kernargs_size_align& size_align,
|
||||
std::vector<std::uint8_t> kernarg) {
|
||||
hip_impl::kernarg kernarg) {
|
||||
using T = typename std::tuple_element<n, std::tuple<Ts...>>::type;
|
||||
|
||||
static_assert(
|
||||
@@ -96,7 +96,7 @@ inline std::vector<std::uint8_t> make_kernarg(
|
||||
}
|
||||
|
||||
template <typename... Formals, typename... Actuals>
|
||||
inline std::vector<std::uint8_t> make_kernarg(
|
||||
inline hip_impl::kernarg make_kernarg(
|
||||
void (*kernel)(Formals...), std::tuple<Actuals...> actuals) {
|
||||
static_assert(sizeof...(Formals) == sizeof...(Actuals),
|
||||
"The count of formal arguments must match the count of actuals.");
|
||||
@@ -104,7 +104,7 @@ inline std::vector<std::uint8_t> make_kernarg(
|
||||
if (sizeof...(Formals) == 0) return {};
|
||||
|
||||
std::tuple<Formals...> to_formals{std::move(actuals)};
|
||||
std::vector<std::uint8_t> kernarg;
|
||||
hip_impl::kernarg kernarg;
|
||||
kernarg.reserve(sizeof(to_formals));
|
||||
|
||||
auto& ps = hip_impl::get_program_state();
|
||||
|
||||
@@ -36,6 +36,20 @@ using hipFunction_t = ihipModuleSymbol_t*;
|
||||
|
||||
namespace hip_impl {
|
||||
|
||||
struct kernarg_impl;
|
||||
class kernarg {
|
||||
public:
|
||||
kernarg();
|
||||
kernarg(kernarg&&);
|
||||
~kernarg();
|
||||
std::uint8_t* data();
|
||||
std::size_t size();
|
||||
void reserve(std::size_t);
|
||||
void resize(std::size_t);
|
||||
private:
|
||||
kernarg_impl* impl;
|
||||
};
|
||||
|
||||
class kernargs_size_align;
|
||||
class program_state_impl;
|
||||
class program_state {
|
||||
|
||||
@@ -10,6 +10,34 @@
|
||||
#include <vector>
|
||||
|
||||
namespace hip_impl {
|
||||
|
||||
kernarg::kernarg() : impl(new kernarg_impl) {
|
||||
}
|
||||
|
||||
kernarg::kernarg(kernarg&& k) : impl(k.impl) {
|
||||
k.impl = nullptr;
|
||||
}
|
||||
|
||||
kernarg::~kernarg() {
|
||||
if (impl)
|
||||
delete(impl);
|
||||
}
|
||||
|
||||
std::uint8_t* kernarg::data() {
|
||||
return impl->v.data();
|
||||
}
|
||||
|
||||
std::size_t kernarg::size() {
|
||||
return impl->v.size();
|
||||
}
|
||||
|
||||
void kernarg::reserve(std::size_t c) {
|
||||
impl->v.reserve(c);
|
||||
}
|
||||
|
||||
void kernarg::resize(std::size_t c) {
|
||||
impl->v.resize(c);
|
||||
}
|
||||
|
||||
std::size_t kernargs_size_align::kernargs_size_align::size(std::size_t n) const{
|
||||
return (*reinterpret_cast<const std::vector<std::pair<std::size_t, std::size_t>>*>(handle))[n].first;
|
||||
|
||||
@@ -743,4 +743,9 @@ public:
|
||||
}
|
||||
}; // class program_state_impl
|
||||
|
||||
struct kernarg_impl {
|
||||
std::vector<std::uint8_t> v;
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
Odkázat v novém úkolu
Zablokovat Uživatele