Skip to content

Commit e5bac2d

Browse files
Bruno Rosasoumith
authored andcommitted
Add critical section to BLAS gemm.
This is needed because of possible races in SpatialConvolutionMM (and others that use gemm) if the BLAS library is not thread-safe. In terms of performance, there's not much benefit to run two gemms in parallel, because the BLAS libraries have their own all-occupying gemms anyways.
1 parent 32fd4a3 commit e5bac2d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

generic/THTensorMath.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,7 @@ void THTensor_(addmm)(THTensor *r_, real beta, THTensor *t, real alpha, THTensor
13461346
m2_ = THTensor_(newContiguous)(m2);
13471347
}
13481348

1349+
#pragma omp critical(blasgemm)
13491350
/* do the operation */
13501351
THBlas_(gemm)(transpose_m1,
13511352
transpose_m2,

0 commit comments

Comments
 (0)