diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/core/c++/chunk.hpp | 3 | ||||
| -rw-r--r-- | lib/sycl/c++/data.hpp | 25 |
2 files changed, 18 insertions, 10 deletions
diff --git a/lib/core/c++/chunk.hpp b/lib/core/c++/chunk.hpp index bfef358..38b567b 100644 --- a/lib/core/c++/chunk.hpp +++ b/lib/core/c++/chunk.hpp @@ -32,7 +32,10 @@ using SuperChunk = Array<ChunkSchema,Dim>; namespace saw { template<typename Sch, uint64_t Dim, uint64_t Side, uint64_t Ghost, typename Encode> class data<kel::lbm::sch::Chunk<Sch,Dim,Side,Ghost>,Encode> final { +public: + using Schema = kel::lbm::sch::Chunk<Sch,Dim,Side,Ghost>; private: + data<Schema::InnerSchema, Encode> public: }; } diff --git a/lib/sycl/c++/data.hpp b/lib/sycl/c++/data.hpp index 67422e2..53a35bc 100644 --- a/lib/sycl/c++/data.hpp +++ b/lib/sycl/c++/data.hpp @@ -12,7 +12,7 @@ struct Sycl { namespace impl { template<typename Schema> -struct struct_has_only_equal_dimension_array +struct struct_has_only_equal_dimension_array{}; } } } @@ -37,9 +37,14 @@ public: q_{nullptr} {} + data(StorageT members__, kel::lbm::sycl::queue& q__): + members_{members__}, + q_{&q__} + {} + ~data(){ SAW_ASSERT(q_){ - exit(-1); + return; } std::visit([this](auto arg){ if(not arg){ @@ -61,14 +66,8 @@ public: SAW_ASSERT(ptr); return *ptr; } - - void set_queue(kel::lbm::sycl::queue& q){ - q_ = &q; - } }; -} - namespace kel { namespace lbm { namespace impl { @@ -80,9 +79,11 @@ struct sycl_malloc_struct_helper<sch::Struct<Members...>, Encode> final { template<uint64_t i> static saw::error_or<void> allocate_on_device_member(typename data<Sch,encode::Sycl<Encode>>::StorageT& storage, sycl::queue& q){ if constexpr (i < sizeof...(Members)){ + using M = typename saw::parameter_pack_type<i,Members...>::type; auto& ptr = std::get<i>(storage); + ptr = sycl::malloc_device<M::ValueType::InnerSchema>(,q); - return allocate_on_device_member<i+1u>(sycl_data,q); + return allocate_on_device_member<i+1u>(storage,q); } return saw::make_void(); @@ -90,7 +91,11 @@ struct sycl_malloc_struct_helper<sch::Struct<Members...>, Encode> final { static saw::error_or<void> allocate_on_device(data<Sch,encode::Sycl<Encode>>& sycl_data, sycl::queue& q){ typename data<Sch,encode::Sycl<Encode>>::StorageT storage; - return allocate_on_device_member<0u>(storage,q); + + auto eov = allocate_on_device_member<0u>(storage,q); + sycl_data = {storage, q}; + + return eov; } }; } |
