Skip to content

Commit e7f0da9

Browse files
authored
Merge pull request #2551 from martin-frbg/issue2538-2
Increase BUFFER_SIZEs and add a safeguard; supply GEMM_R for POWER8/9
2 parents 7905383 + e9bfa22 commit e7f0da9

File tree

7 files changed

+1333
-17
lines changed

7 files changed

+1333
-17
lines changed

common_arm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static inline int blas_quickdivide(blasint x, blasint y){
121121
#endif
122122
#define HUGE_PAGESIZE ( 4 << 20)
123123

124-
#define BUFFER_SIZE (16 << 20)
124+
#define BUFFER_SIZE (32 << 20)
125125

126126

127127
#define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)

common_arm64.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,17 @@ static inline int blas_quickdivide(blasint x, blasint y){
141141
#endif
142142
#define HUGE_PAGESIZE ( 4 << 20)
143143

144+
#ifndef BUFFERSIZE
144145
#if defined(CORTEXA57)
145146
#define BUFFER_SIZE (20 << 20)
147+
#elif defined(TSV110) || defined(EMAG8180)
148+
#define BUFFER_SIZE (32 << 20)
146149
#else
147150
#define BUFFER_SIZE (16 << 20)
148151
#endif
149-
152+
#else
153+
#define BUFFER_SIZE (32 << BUFFERSIZE)
154+
#endif
150155

151156
#define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
152157

common_x86_64.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,13 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){
226226
#define HUGE_PAGESIZE ( 2 << 20)
227227

228228
#ifndef BUFFERSIZE
229+
#if defined(SKYLAKEX)
230+
#define BUFFER_SIZE (32 << 21)
231+
#elif defined(HASWELL) || defined(ZEN)
232+
#define BUFFER_SIZE (32 << 22)
233+
#else
229234
#define BUFFER_SIZE (32 << 20)
235+
#endif
230236
#else
231237
#define BUFFER_SIZE (32 << BUFFERSIZE)
232238
#endif

common_zarch.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@ static inline int blas_quickdivide(blasint x, blasint y){
123123
#endif
124124
#define HUGE_PAGESIZE ( 4 << 20)
125125

126-
#if defined(CORTEXA57)
127-
#define BUFFER_SIZE (20 << 20)
128-
#else
129-
#define BUFFER_SIZE (16 << 20)
130-
#endif
126+
#define BUFFER_SIZE (32 << 22)
131127

132128

133129
#define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)

driver/others/memory.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,30 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8787
#endif
8888
#endif
8989

90+
/* Memory buffer must fit two matrix subblocks of maximal size */
91+
#define XSTR(x) STR(x)
92+
#define STR(x) #x
93+
#if BUFFER_SIZE < (SGEMM_DEFAULT_P * SGEMM_DEFAULT_Q * 4 * 2) || \
94+
BUFFER_SIZE < (SGEMM_DEFAULT_P * SGEMM_DEFAULT_R * 4 * 2) || \
95+
BUFFER_SIZE < (SGEMM_DEFAULT_R * SGEMM_DEFAULT_Q * 4 * 2)
96+
#warning BUFFER_SIZE is too small for P, Q, and R of SGEMM - large calculations may crash !
97+
#endif
98+
#if BUFFER_SIZE < (DGEMM_DEFAULT_P * DGEMM_DEFAULT_Q * 8 * 2) || \
99+
BUFFER_SIZE < (DGEMM_DEFAULT_P * DGEMM_DEFAULT_R * 8 * 2) || \
100+
BUFFER_SIZE < (DGEMM_DEFAULT_R * DGEMM_DEFAULT_Q * 8 * 2)
101+
#warning BUFFER_SIZE is too small for P, Q, and R of DGEMM - large calculations may crash !
102+
#endif
103+
#if BUFFER_SIZE < (CGEMM_DEFAULT_P * CGEMM_DEFAULT_Q * 8 * 2) || \
104+
BUFFER_SIZE < (CGEMM_DEFAULT_P * CGEMM_DEFAULT_R * 8 * 2) || \
105+
BUFFER_SIZE < (CGEMM_DEFAULT_R * CGEMM_DEFAULT_Q * 8 * 2)
106+
#warning BUFFER_SIZE is too small for P, Q, and R of CGEMM - large calculations may crash !
107+
#endif
108+
#if BUFFER_SIZE < (ZGEMM_DEFAULT_P * ZGEMM_DEFAULT_Q * 16 * 2) || \
109+
BUFFER_SIZE < (ZGEMM_DEFAULT_P * ZGEMM_DEFAULT_R * 16 * 2) || \
110+
BUFFER_SIZE < (ZGEMM_DEFAULT_R * ZGEMM_DEFAULT_Q * 16 * 2)
111+
#warning BUFFER_SIZE is too small for P, Q, and R of ZGEMM - large calculations may crash !
112+
#endif
113+
90114
#if defined(COMPILE_TLS)
91115

92116
#include <errno.h>
@@ -2740,7 +2764,7 @@ void *blas_memory_alloc(int procpos){
27402764
#ifdef DEBUG
27412765
printf(" Position -> %d\n", position);
27422766
#endif
2743-
WMB;
2767+
27442768
memory[position].used = 1;
27452769
#if (defined(SMP) || defined(USE_LOCKING)) && !defined(USE_OPENMP)
27462770
UNLOCK_COMMAND(&alloc_lock);

kernel/common_param.h

Lines changed: 1274 additions & 0 deletions
Large diffs are not rendered by default.

param.h

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,15 +2229,26 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22292229
#define ZGEMM_DEFAULT_UNROLL_M 8
22302230
#define ZGEMM_DEFAULT_UNROLL_N 2
22312231

2232-
#define SGEMM_DEFAULT_P 1280
2233-
#define DGEMM_DEFAULT_P 640
2234-
#define CGEMM_DEFAULT_P 640
2235-
#define ZGEMM_DEFAULT_P 320
2236-
2237-
#define SGEMM_DEFAULT_Q 640
2238-
#define DGEMM_DEFAULT_Q 720
2239-
#define CGEMM_DEFAULT_Q 640
2240-
#define ZGEMM_DEFAULT_Q 640
2232+
#define SGEMM_DEFAULT_P 1280UL
2233+
#define DGEMM_DEFAULT_P 640UL
2234+
#define CGEMM_DEFAULT_P 640UL
2235+
#define ZGEMM_DEFAULT_P 320UL
2236+
2237+
#define SGEMM_DEFAULT_Q 640UL
2238+
#define DGEMM_DEFAULT_Q 720UL
2239+
#define CGEMM_DEFAULT_Q 640UL
2240+
#define ZGEMM_DEFAULT_Q 640UL
2241+
2242+
#if 0
2243+
#define SGEMM_DEFAULT_R SGEMM_DEFAULT_P
2244+
#define DGEMM_DEFAULT_R DGEMM_DEFAULT_P
2245+
#define CGEMM_DEFAULT_R CGEMM_DEFAULT_P
2246+
#define ZGEMM_DEFAULT_R ZGEMM_DEFAULT_P
2247+
#endif
2248+
#define SGEMM_DEFAULT_R 4096
2249+
#define DGEMM_DEFAULT_R 4096
2250+
#define CGEMM_DEFAULT_R 4096
2251+
#define ZGEMM_DEFAULT_R 512
22412252

22422253
#define SYMV_P 8
22432254

0 commit comments

Comments
 (0)