From af8d5553b37786e4a04352b09a560531f1c0b876 Mon Sep 17 00:00:00 2001 From: James Osborn Date: Sun, 17 Sep 2023 19:30:10 -0500 Subject: [PATCH] add missing file --- include/targets/cuda/special_ops_target.h | 229 ---------------------- include/targets/hip/special_ops_target.h | 29 +++ 2 files changed, 29 insertions(+), 229 deletions(-) create mode 100644 include/targets/hip/special_ops_target.h diff --git a/include/targets/cuda/special_ops_target.h b/include/targets/cuda/special_ops_target.h index 352d99e6b7..dbc4703d83 100644 --- a/include/targets/cuda/special_ops_target.h +++ b/include/targets/cuda/special_ops_target.h @@ -11,137 +11,6 @@ namespace quda { } }; -#if 0 - // blockSync - template - inline void blockSync(SpecialOps *ops) { - static_assert(hasBlockSync); - //if (ops->ndi == nullptr) { - // errorQuda("SpecialOps not set"); - //} -#ifdef __SYCL_DEVICE_ONLY__ - sycl::group_barrier(ops->ndi->get_group()); -#endif - } - template inline void blockSync(SpecialOps ops) { blockSync(&ops); } - - template static constexpr bool isOpConcurrent = false; - template static constexpr bool isOpConcurrent> = true; - - template static constexpr int getOpIndex = 0; - template static constexpr int getOpIndex> = getOpIndex; - template static constexpr int getOpIndex = - std::is_same_v ? 0 : (1 + getOpIndex); - - // getSpecialOp - template - inline SpecialOpsType getSpecialOp(const SpecialOps &ops) { - if constexpr (!isOpConcurrent && sizeof...(T) == 1 && isOpConcurrent) { - static constexpr int i = getOpIndex; - return getSpecialOp(ops); - } else { - static_assert(hasSpecialOpType); - //if (ops->ndi == nullptr || ops->smem == nullptr) { - // errorQuda("SpecialOps not set"); - //} - SpecialOpsType s; - s.ndi = ops.ndi; - //s.smem = ops->smem + sharedMemOffset()(ops->ndi->get_local_range()); // FIXME: need to pass arg - s.smem = ops.smem + sharedMemOffset()(getBlockDim()); // FIXME: need to pass arg - return s; - } - } - template - inline SpecialOpsType getSpecialOp(const SpecialOps *ops) { return getSpecialOp(*ops); } - template struct getSpecialOpF { - template inline SpecialOpsType operator()(const T &ops) { return getSpecialOp(ops); } - }; - - // getDependentOps - template - inline SpecialOpDependencies> getDependentOps(const SpecialOps &ops) { - static_assert(hasSpecialOpType); - //if (ops->ndi == nullptr || ops->smem == nullptr) { - //errorQuda("SpecialOps not set"); - //} - SpecialOpDependencies> s; - s.ndi = ops.ndi; - //s.smem = ops->smem + sharedMemOffset()(ops->ndi->get_local_range()); // FIXME: need to pass arg - s.smem = ops.smem + sharedMemOffset()(getBlockDim()); // FIXME: need to pass arg - return s; - } - - // getSharedMemPtr -#if 0 - template - //SpecialOpsElemType *getSharedMemPtr(SpecialOps *ops) { - sycl::local_ptr> getSharedMemPtr(SpecialOps *ops) { - static_assert(!std::is_same_v,void>); - //return reinterpret_cast*>(ops->smem); - //return reinterpret_cast*>(ops->smem.get()); - //sycl::local_ptr> smem = ops->smem.get(); - //return smem.get(); - //auto p = ops->smem.get(); - sycl::local_ptr v(ops->smem); - sycl::local_ptr> p(v); - return p; - //sycl::local_ptr> smem; - //using LT = decltype(smem.get()); - //LT pt = reinterpret_cast(p); - //sycl::local_ptr> smem2(pt); - //return smem2; - //return reinterpret_cast*>(0); - } - template - inline SpecialOpsElemType *getSharedMemPtr(SpecialOps ops) { return getSharedMemPtr(&ops); } -#endif - - template > - inline sycl::local_ptr getSharedMemPtr(const only_SharedMemory &ops) { - //if (ops->ndi == nullptr || ops->smem == nullptr) { - //errorQuda("SpecialOps not set"); - //} - sycl::local_ptr v(ops.smem); - sycl::local_ptr p(v); - return p; - } - //template - //inline sycl::local_ptr getSharedMemPtr(only_SharedMemory ops) { return getSharedMemPtr(&ops); } - template - inline auto getSharedMemPtr(const SpecialOps &ops) { - SpecialOps op = getSpecialOp(ops); - return getSharedMemPtr(op); - } - - template - inline auto getSharedMemory(O *ops) - { - auto s = getSpecialOp(ops); - return getSharedMemPtr(s); - } - - // base operation dependencies - struct depNone {}; - template <> struct sharedMemSizeS { - template - static constexpr unsigned int size(dim3 block, Arg &...arg) { return 0; } - }; - - struct depFullBlock {}; - template <> struct sharedMemSizeS { - template - static constexpr unsigned int size(dim3 block, Arg &...arg) { return 0; } - }; - - template - struct depSharedMem {}; - template struct sharedMemSizeS> { - template - static constexpr unsigned int size(dim3 block, Arg &...arg) { return S().template size(block, arg...); } - }; - -#endif - // op implementations struct op_blockSync : op_BaseT { //using dependencies = depFullBlock; @@ -157,102 +26,4 @@ namespace quda { static constexpr unsigned int shared_mem_size(dim3, Arg &...arg) { return 0; } }; -#if 0 - - template - struct op_thread_array : op_BaseT { - //using dependencies = depNone; - using dependencies = op_SharedMemory,opSizeBlock>; - }; - - template - struct op_BlockReduce : op_BaseT { - using concurrentOps = op_Concurrent>; - using opBlockSync = getSpecialOpF; - using opSharedMem = getSpecialOpF; - //using specialOps = SpecialOps; - using dependencies = concurrentOps; - }; - - template - struct op_SharedMemoryCache : op_BaseT { - template static constexpr dim3 dims(dim3 block, Arg &...arg) { return D::dims(block, arg...); } - using dependencies = op_Sequential>>; - }; - - template - struct op_SharedMemory : op_BaseT { - using dependencies = depSharedMem; - template - static constexpr unsigned int shared_mem_size(dim3 block, Arg &...arg) { return S::template size(block, arg...); } - }; - - // needsFullWarp? - - // needsFullBlock -#if 0 - template static constexpr bool needsFullBlock = needsFullBlock>; - template static constexpr bool needsFullBlockImpl = (needsFullBlockImpl || ...); - template <> static constexpr bool needsFullBlockImpl = false; - template <> static constexpr bool needsFullBlockImpl = true; - template static constexpr bool needsFullBlockImpl> = false; - template static constexpr bool needsFullBlockImpl> = needsFullBlockImpl; - template static constexpr bool needsFullBlockImpl> = needsFullBlockImpl; - template static constexpr bool needsFullBlockF() { - if constexpr (std::is_base_of::value) { - return needsFullBlockImpl; - } else { - //if constexpr (hasSpecialOps) { - //return needsFullBlock>; - //} else { - //return false; - return needsFullBlock; - //} - } - } - template static constexpr bool needsFullBlockImpl = needsFullBlockF(); - template <> static constexpr bool needsFullBlock = false; - template static constexpr bool needsFullBlock> = needsFullBlockImpl; -#else - template static constexpr bool needsFullBlock = needsFullBlock>; - template static constexpr bool needsFullBlock> = (needsFullBlock || ...); - template <> static constexpr bool needsFullBlock = false; -#endif - - - // needsSharedMem -#if 0 - template static constexpr bool needsSharedMem = needsSharedMem>; - template static constexpr bool needsSharedMemImpl = (needsSharedMemImpl || ...); - template <> static constexpr bool needsSharedMemImpl = false; - template <> static constexpr bool needsSharedMemImpl = false; - template static constexpr bool needsSharedMemImpl> = true; - template static constexpr bool needsSharedMemImpl> = needsSharedMemImpl; - template static constexpr bool needsSharedMemImpl> = needsSharedMemImpl; - template static constexpr bool needsSharedMemF() { - if constexpr (std::is_base_of::value) { - //if constexpr (is_instance) { - return needsSharedMemImpl; - } else { - //if constexpr (hasSpecialOps) { - //return needsSharedMem>; - //} else { - //return false; - return needsSharedMem; - //} - } - } - template static constexpr bool needsSharedMemImpl = needsSharedMemF(); - template <> static constexpr bool needsSharedMem = false; - template static constexpr bool needsSharedMem> = needsSharedMemImpl; -#else - //template static constexpr bool needsSharedMemImpl = (needsSharedMemImpl || ...); - template static constexpr bool needsSharedMemImpl = (T::shared_mem_size(dim3{8,8,8}) > 0); - template static constexpr bool needsSharedMemImpl> = (needsSharedMemImpl || ...); - template static constexpr bool needsSharedMem = needsSharedMem>; - template static constexpr bool needsSharedMem> = (needsSharedMemImpl || ...); - template <> static constexpr bool needsSharedMem = false; -#endif - -#endif } diff --git a/include/targets/hip/special_ops_target.h b/include/targets/hip/special_ops_target.h new file mode 100644 index 0000000000..dbc4703d83 --- /dev/null +++ b/include/targets/hip/special_ops_target.h @@ -0,0 +1,29 @@ +#pragma once +#include + +namespace quda { + + // SpecialOps + template + struct SpecialOps : SpecialOps_Base { + template constexpr void setSpecialOps(const SpecialOps &ops) { + static_assert(std::is_same_v,SpecialOps>); + } + }; + + // op implementations + struct op_blockSync : op_BaseT { + //using dependencies = depFullBlock; + template + static constexpr unsigned int shared_mem_size(dim3 block, Arg &...arg) { return 0; } + }; + + template + struct op_warp_combine : op_BaseT { + //using dependencies = depNone; + //using dependencies = depFullBlock; + template + static constexpr unsigned int shared_mem_size(dim3, Arg &...arg) { return 0; } + }; + +}