diff --git a/cpp_thread_test/dgemm_thread_safety.cpp b/cpp_thread_test/dgemm_thread_safety.cpp index 9d42829dc..2275f6ef0 100644 --- a/cpp_thread_test/dgemm_thread_safety.cpp +++ b/cpp_thread_test/dgemm_thread_safety.cpp @@ -3,60 +3,34 @@ #include #include #include -#include "/opt/OpenBLAS_zen_serial/include/cblas.h" +#include "../cblas.h" +#include "cpp_thread_safety_common.h" -const blasint randomMatSize = 1024; //dimension of the random square matrices used -const uint32_t numConcurrentThreads = 52; //number of concurrent calls of the functions being tested -const uint32_t numTestRounds = 8; //number of testing rounds before success exit - -inline void pauser(){ - /// a portable way to pause a program - std::string dummy; - std::cout << "Press enter to continue..."; - std::getline(std::cin, dummy); -} - -void launch_cblas_dgemm(double* A, double* B, double* C){ +void launch_cblas_dgemm(double* A, double* B, double* C, const blasint randomMatSize){ cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, randomMatSize, randomMatSize, randomMatSize, 1.0, A, randomMatSize, B, randomMatSize, 0.1, C, randomMatSize); } -void FillMatrices(std::vector>& matBlock, std::mt19937_64& PRNG, std::uniform_real_distribution& rngdist){ - for(uint32_t i=0; i<3; i++){ - for(uint32_t j=0; j<(randomMatSize*randomMatSize); j++){ - matBlock[i][j] = rngdist(PRNG); +int main(int argc, char* argv[]){ + blasint randomMatSize = 1024; //dimension of the random square matrices used + uint32_t numConcurrentThreads = 52; //number of concurrent calls of the functions being tested + uint32_t numTestRounds = 16; //number of testing rounds before success exit + + if (argc > 4){ + std::cout<<"ERROR: too many arguments for thread safety tester"< cliArgs; + for (int i = 1; i < argc; i++){ + cliArgs.push_back(argv[i]); + std::cout< rngdist{-1.0, 1.0}; - //make sure the internal state of the PRNG is properly mixed by generating 10M random numbers - //PRNGs often have unreliable distribution uniformity and other statistical properties before their internal state is sufficiently mixed - for (uint32_t i=0;i<10000000;i++) rngdist(PRNG); - return PRNG; -} - -void PrintMatrices(const std::vector>& matBlock){ - for (uint32_t i=0;i rngdist{-1.0, 1.0}; std::vector> matBlock(numConcurrentThreads*3); std::vector> futureBlock(numConcurrentThreads); @@ -81,17 +55,17 @@ int main(){ std::cout<<"done\n"; //pauser(); std::cout<<"Filling matrices with random numbers..."<