aboutsummaryrefslogtreecommitdiff
path: root/src/fastblas.cpp
diff options
context:
space:
mode:
authorPjotr Prins2017-12-06 08:49:48 +0000
committerPjotr Prins2017-12-06 08:50:00 +0000
commit6042155a4b8d8fad3e5bacdb8fa3fe2f072b80fe (patch)
tree2fe66d57a2965331ca0dd126742705f6a5cfcee4 /src/fastblas.cpp
parent4aa3540f0be29f7db73d2c18dd1f91e514ead490 (diff)
downloadpangemma-6042155a4b8d8fad3e5bacdb8fa3fe2f072b80fe.tar.gz
Integer overflow checking for matrix dgemm and adding path for OpenBlas include files
Diffstat (limited to 'src/fastblas.cpp')
-rw-r--r--src/fastblas.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/fastblas.cpp b/src/fastblas.cpp
index 20456ef..7b10852 100644
--- a/src/fastblas.cpp
+++ b/src/fastblas.cpp
@@ -124,6 +124,21 @@ void fast_cblas_dgemm(const enum CBLAS_ORDER Order,
}
#endif // NDEBUG
+ // Check for (integer) overflows
+ enforce(M>0);
+ enforce(N>0);
+ enforce(K>0);
+
+ blasint mi = M;
+ blasint ni = N;
+ blasint ki = K;
+ auto x1 = mi * ki;
+ enforce_msg(x1 / mi == ki, "matrix integer overflow - please use long int");
+ auto x2 = ni * ki;
+ enforce_msg(x2 / ni == ki, "matrix integer overflow - please use long int");
+ auto x3 = mi * ni;
+ enforce_msg(x3 / mi == ni, "matrix integer overflow - please use long int");
+
cblas_dgemm(Order,TransA,TransB,M,N,K,alpha,A,lda,B,ldb,beta,C,ldc);
#ifndef NDEBUG