Skip to content

Commit

Permalink
Add critical section to BLAS gemm.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bruno Rosa authored and soumith committed Jul 4, 2017
1 parent 32fd4a3 commit e5bac2d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions generic/THTensorMath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,7 @@ void THTensor_(addmm)(THTensor *r_, real beta, THTensor *t, real alpha, THTensor
m2_ = THTensor_(newContiguous)(m2);
}

#pragma omp critical(blasgemm)
/* do the operation */
THBlas_(gemm)(transpose_m1,
transpose_m2,
Expand Down

0 comments on commit e5bac2d

Please sign in to comment.