diff options
Diffstat (limited to 'src/GroupwiseConv.h')
-rw-r--r-- | src/GroupwiseConv.h | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/GroupwiseConv.h b/src/GroupwiseConv.h index 4c5eea5..cbcf445 100644 --- a/src/GroupwiseConv.h +++ b/src/GroupwiseConv.h @@ -10,8 +10,10 @@ #include <cassert> #include <cstdint> #include <map> +#include <mutex> #include <string> #include <tuple> +#include "CodeCache.h" #include "fbgemm/ConvUtils.h" #include "fbgemm/Fbgemm.h" #include "fbgemm/Utils.h" @@ -217,16 +219,15 @@ class GenConvKernel { template <inst_set_t instSet> void storeResultRowoffset(x86::Emitter* a, int offset = 0); - static thread_local asmjit::JitRuntime rt_; ///< JIT Runtime for asmjit. - static thread_local asmjit::CodeHolder code_; ///< JIT Code Holder for asmjit. - static thread_local std:: - map<std::tuple<bool, int, int, int>, jit_conv_kernel_fp> - codeCache_; ///< JIT Code Cache for reuse. - static thread_local std:: - map<std::tuple<bool, int, int, int>, jit_rowoffset_kernel_fp> - codeCacheRowOffset_; ///< JIT Code Cache for row offset kernel. + static asmjit::JitRuntime rt_; ///< JIT Runtime for asmjit. + static std::mutex rtMutex_; ///< Controll access to rt_; - private: + static CodeCache<std::tuple<bool, int, int, int>, jit_conv_kernel_fp> + codeCache_; ///< JIT Code Cache for reuse. + static CodeCache<std::tuple<bool, int, int, int>, jit_rowoffset_kernel_fp> + codeCacheRowOffset_; ///< JIT Code Cache for row offset kernel. + +private: int vectorWidth_; ///< Vector width in bits. int VLEN_; ///< Vector width in elements. // avx2 specific @@ -272,4 +273,18 @@ class GenConvKernel { int W_PAD_; ///< Padding for width (left and right) }; +template <int SPATIAL_DIM, typename accT> +asmjit::JitRuntime GenConvKernel<SPATIAL_DIM, accT>::rt_; + +template <int SPATIAL_DIM, typename accT> +std::mutex GenConvKernel<SPATIAL_DIM, accT>::rtMutex_; + +template <int SPATIAL_DIM, typename accT> +CodeCache<std::tuple<bool, int, int, int>, jit_conv_kernel_fp> + GenConvKernel<SPATIAL_DIM, accT>::codeCache_; + +template <int SPATIAL_DIM, typename accT> +CodeCache<std::tuple<bool, int, int, int>, jit_rowoffset_kernel_fp> + GenConvKernel<SPATIAL_DIM, accT>::codeCacheRowOffset_; + } // namespace fbgemm |