Skip to content

Commit df0d100

Browse files
committed
Use inline declaration for static members
Signed-off-by: cyy <cyyever@outlook.com>
1 parent 2e4cf87 commit df0d100

File tree

7 files changed

+18
-158
lines changed

7 files changed

+18
-158
lines changed

src/DirectConv.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ class DirectConvCodeGenBase {
5353
int o1Xoc,
5454
int i1);
5555

56-
static std::mutex rtMutex_; ///< Control access to runtime;
56+
inline static std::mutex rtMutex_; ///< Control access to runtime;
5757

5858
// The hash depends on accumulate, mc, nc, ncb, kcb, nr, mr
59-
static CodeCache<
59+
inline static CodeCache<
6060
std::tuple<bool, int, int, int, int, int, int>,
6161
jit_micro_kernel_fp>
6262
codeCache_; ///< JIT Code Cache for reuse.
6363

6464
// The hash depends on accumulate, stride, mr, nr
65-
static CodeCache<
65+
inline static CodeCache<
6666
std::tuple<bool, int, int, int>,
6767
jit_micro_kernel_fp_convT>
6868
codeCacheT_; ///< JIT Code Cache for reuse.
@@ -205,19 +205,4 @@ class DirectConvCodeGenBase {
205205
}
206206
};
207207

208-
template <typename TA, typename TB, typename TC, typename accT>
209-
std::mutex DirectConvCodeGenBase<TA, TB, TC, accT>::rtMutex_;
210-
211-
template <typename TA, typename TB, typename TC, typename accT>
212-
CodeCache<
213-
std::tuple<bool, int, int, int, int, int, int>,
214-
typename DirectConvCodeGenBase<TA, TB, TC, accT>::jit_micro_kernel_fp>
215-
DirectConvCodeGenBase<TA, TB, TC, accT>::codeCache_;
216-
217-
template <typename TA, typename TB, typename TC, typename accT>
218-
CodeCache<
219-
std::tuple<bool, int, int, int>,
220-
typename DirectConvCodeGenBase<TA, TB, TC, accT>::jit_micro_kernel_fp_convT>
221-
DirectConvCodeGenBase<TA, TB, TC, accT>::codeCacheT_;
222-
223208
} // namespace fbgemm

src/EmbeddingSpMDM.cc

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ class GenEmbeddingSpMDMLookup {
117117
return rt;
118118
}
119119

120-
static std::mutex rtMutex_; ///< Controll access to runtime;
120+
inline static std::mutex rtMutex_; ///< Control access to runtime;
121121

122122
// The hash depends on embedding dimension (block size), weighted sls,
123-
// positional weights, normalize by lenths, prefetch distance, use_offsets,
123+
// positional weights, normalize by lengths, prefetch distance, use_offsets,
124124
// output_stride, input_stride, and scale_bias_last
125-
static CodeCache<
125+
inline static CodeCache<
126126
std::tuple<int, bool, bool, bool, int, bool, int, int, bool, bool, bool>,
127127
typename ReturnFunctionSignature<
128128
inType,
@@ -134,49 +134,6 @@ class GenEmbeddingSpMDMLookup {
134134
codeCache_; ///< JIT Code Cache for reuse.
135135
}; // GenEmbeddingSpmDMLookup
136136

137-
template <
138-
typename inType,
139-
typename indxType,
140-
typename offsetType,
141-
typename outType,
142-
inst_set_t instSet,
143-
bool ROWWISE_SPARSE,
144-
bool THREAD_LOCAL>
145-
std::mutex GenEmbeddingSpMDMLookup<
146-
inType,
147-
indxType,
148-
offsetType,
149-
outType,
150-
instSet,
151-
ROWWISE_SPARSE,
152-
THREAD_LOCAL>::rtMutex_;
153-
154-
template <
155-
typename inType,
156-
typename indxType,
157-
typename offsetType,
158-
typename outType,
159-
inst_set_t instSet,
160-
bool ROWWISE_SPARSE,
161-
bool THREAD_LOCAL>
162-
CodeCache<
163-
std::tuple<int, bool, bool, bool, int, bool, int, int, bool, bool, bool>,
164-
typename ReturnFunctionSignature<
165-
inType,
166-
indxType,
167-
offsetType,
168-
outType,
169-
ROWWISE_SPARSE>::jit_embedding_kernel,
170-
THREAD_LOCAL>
171-
GenEmbeddingSpMDMLookup<
172-
inType,
173-
indxType,
174-
offsetType,
175-
outType,
176-
instSet,
177-
ROWWISE_SPARSE,
178-
THREAD_LOCAL>::codeCache_;
179-
180137
template <
181138
typename inType,
182139
typename indxType,

src/EmbeddingSpMDMNBit.cc

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ class GenEmbeddingSpMDMNBitLookup {
104104
private:
105105
static asmjit::JitRuntime& runtime() {
106106
static asmjit::JitRuntime rt; //< JIT Runtime for asmjit,
107-
// depents on other static
107+
// depends on other static
108108
// variables. Required to prevent
109109
// initialization order fiasco
110110
return rt;
111111
}
112112

113-
static mutex rtMutex_; ///< Controll access to runtime;
113+
inline static mutex rtMutex_; ///< Control access to runtime;
114114

115115
// The hash depends on bit_rate, embedding dimension (block size), weighted
116-
// sls, positional weights, normalize by lenths, prefetch distance,
116+
// sls, positional weights, normalize by lengths, prefetch distance,
117117
// use_offsets, output_stride, input_stride, and scale_bias_last
118-
static CodeCache<
118+
inline static CodeCache<
119119
tuple<int, int, bool, bool, bool, int, bool, int, int, bool, bool>,
120120
typename ReturnFunctionSignature<
121121
indxType,
@@ -126,44 +126,6 @@ class GenEmbeddingSpMDMNBitLookup {
126126
codeCache_; ///< JIT Code Cache for reuse.
127127
}; // GenEmbeddingSpmDMLookup
128128

129-
template <
130-
typename indxType,
131-
typename offsetType,
132-
typename outType,
133-
inst_set_t instSet,
134-
bool ROWWISE_SPARSE,
135-
bool THREAD_LOCAL>
136-
mutex GenEmbeddingSpMDMNBitLookup<
137-
indxType,
138-
offsetType,
139-
outType,
140-
instSet,
141-
ROWWISE_SPARSE,
142-
THREAD_LOCAL>::rtMutex_;
143-
144-
template <
145-
typename indxType,
146-
typename offsetType,
147-
typename outType,
148-
inst_set_t instSet,
149-
bool ROWWISE_SPARSE,
150-
bool THREAD_LOCAL>
151-
CodeCache<
152-
tuple<int, int, bool, bool, bool, int, bool, int, int, bool, bool>,
153-
typename ReturnFunctionSignature<
154-
indxType,
155-
offsetType,
156-
outType,
157-
ROWWISE_SPARSE>::jit_embedding_kernel,
158-
THREAD_LOCAL>
159-
GenEmbeddingSpMDMNBitLookup<
160-
indxType,
161-
offsetType,
162-
outType,
163-
instSet,
164-
ROWWISE_SPARSE,
165-
THREAD_LOCAL>::codeCache_;
166-
167129
template <
168130
typename indxType,
169131
typename offsetType,

src/GenerateKernel.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,13 @@ class CodeGenBase {
138138
return rt;
139139
}
140140

141-
static std::mutex rtMutex_; ///< Controll access to runtime;
141+
inline static std::mutex rtMutex_; ///< Controll access to runtime;
142142

143143
// The hash depends on accumulate, mc, nc, ncb, kcb, nr, mr
144-
static CodeCache<
144+
inline static CodeCache<
145145
std::tuple<bool, int, int, int, int, int, int>,
146146
jit_micro_kernel_fp>
147147
codeCache_; ///< JIT Code Cache for reuse.
148148
};
149149

150-
template <typename TA, typename TB, typename TC, typename accT>
151-
std::mutex CodeGenBase<TA, TB, TC, accT>::rtMutex_;
152-
153-
template <typename TA, typename TB, typename TC, typename accT>
154-
CodeCache<
155-
std::tuple<bool, int, int, int, int, int, int>,
156-
typename CodeGenBase<TA, TB, TC, accT>::jit_micro_kernel_fp>
157-
CodeGenBase<TA, TB, TC, accT>::codeCache_;
158-
159150
} // namespace fbgemm

src/GroupwiseConv.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ class GenConvKernelBase {
171171
return rt;
172172
}
173173

174-
static std::mutex rtMutex_; ///< Control access to runtime;
174+
inline static std::mutex rtMutex_; ///< Control access to runtime;
175175

176-
static CodeCache<
176+
inline static CodeCache<
177177
kernel_sig_t,
178178
jit_conv_kernel_fp>
179179
codeCache_; ///< JIT Code Cache for reuse.
@@ -325,11 +325,4 @@ class FBGEMM_API GenConvKernel
325325
x86::Gp scratchReg2_;
326326
};
327327

328-
template <int SPATIAL_DIM, inst_set_t INST_SET>
329-
std::mutex GenConvKernelBase<SPATIAL_DIM, INST_SET>::rtMutex_;
330-
331-
template <int SPATIAL_DIM, inst_set_t INST_SET>
332-
CodeCache<kernel_sig_t, jit_conv_kernel_fp>
333-
GenConvKernelBase<SPATIAL_DIM, INST_SET>::codeCache_;
334-
335328
} // namespace fbgemm

src/RowWiseSparseAdagradFused.cc

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,38 +66,18 @@ class GenRowWiseSparseAdagradFused {
6666
return rt;
6767
}
6868

69-
static mutex rtMutex_; /// Controll access to runtime;
69+
inline static mutex rtMutex_; /// Control access to runtime;
7070

7171
// The hash depends on:
7272
// avx2 mask array, embedding dimension (block size), prefetch distance,
7373
// use_offsets and use_stochastic_rouding switch
74-
static CodeCache<
74+
inline static CodeCache<
7575
tuple<const int*, int, int, bool, bool, int>,
7676
typename ReturnFunctionSignature<indxType, offsetType, dataType>::
7777
jit_sparse_adagrad_kernel>
7878
codeCache_; ///< JIT Code Cache for reuse.
7979
}; // class GenRowWiseSparseAdagradFused
8080

81-
template <
82-
typename indxType,
83-
typename offsetType,
84-
typename dataType,
85-
inst_set_t instSet>
86-
mutex GenRowWiseSparseAdagradFused<indxType, offsetType, dataType, instSet>::
87-
rtMutex_;
88-
89-
template <
90-
typename indxType,
91-
typename offsetType,
92-
typename dataType,
93-
inst_set_t instSet>
94-
CodeCache<
95-
tuple<const int*, int, int, bool, bool, int>,
96-
typename ReturnFunctionSignature<indxType, offsetType, dataType>::
97-
jit_sparse_adagrad_kernel>
98-
GenRowWiseSparseAdagradFused<indxType, offsetType, dataType, instSet>::
99-
codeCache_;
100-
10181
template <
10282
typename indxType,
10383
typename offsetType,

src/SparseAdagrad.cc

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ class GenSparseAdagrad {
8989
return rt;
9090
}
9191

92-
static std::mutex rtMutex_; /// Controll access to runtime;
92+
inline static std::mutex rtMutex_; /// Controll access to runtime;
9393

9494
// The hash depends on embedding dimension (block size), prefetch distance,
9595
// rowwise, and has_weight_decay
96-
static CodeCache<
96+
inline static CodeCache<
9797
std::tuple<int, int, bool, bool>,
9898
typename ReturnFunctionSignature<indxType>::jit_sparse_adagrad_kernel>
9999
codeCache_; ///< JIT Code Cache for reuse.
@@ -111,14 +111,6 @@ class GenSparseAdagrad {
111111
x86::KReg reduce_mask_avx512_;
112112
}; // GenEmbeddingLookup
113113

114-
template <typename indxType, inst_set_t instSet>
115-
std::mutex GenSparseAdagrad<indxType, instSet>::rtMutex_;
116-
117-
template <typename indxType, inst_set_t instSet>
118-
CodeCache<
119-
std::tuple<int, int, bool, bool>,
120-
typename ReturnFunctionSignature<indxType>::jit_sparse_adagrad_kernel>
121-
GenSparseAdagrad<indxType, instSet>::codeCache_;
122114

123115
template <typename indxType, inst_set_t instSet>
124116
void GenSparseAdagrad<indxType, instSet>::genSparseAdagrad(

0 commit comments

Comments
 (0)