Merge pull request #2672 from mhillenibm/test_num_threads

cpp_thread_test: Change adjustment of concurrency on systems with <52 hw threads
This commit is contained in:
Martin Kroeker 2020-06-17 17:54:31 +02:00 committed by GitHub
commit 0eb6c4dded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -5,6 +5,14 @@ inline void pauser(){
std::getline(std::cin, dummy); std::getline(std::cin, dummy);
} }
void FailIfThreadsAreZero(uint32_t numConcurrentThreads) {
if(numConcurrentThreads == 0) {
std::cout<<"ERROR: Invalid parameter 0 for number of concurrent calls into OpenBLAS!"<<std::endl;
std::cout<<"CBLAS DGEMV thread safety test FAILED!"<<std::endl;
exit(-1);
}
}
void FillMatrices(std::vector<std::vector<double>>& matBlock, std::mt19937_64& PRNG, std::uniform_real_distribution<double>& rngdist, const blasint randomMatSize, const uint32_t numConcurrentThreads, const uint32_t numMat){ void FillMatrices(std::vector<std::vector<double>>& matBlock, std::mt19937_64& PRNG, std::uniform_real_distribution<double>& rngdist, const blasint randomMatSize, const uint32_t numConcurrentThreads, const uint32_t numMat){
for(uint32_t i=0; i<numMat; i++){ for(uint32_t i=0; i<numMat; i++){
for(uint32_t j = 0; j < static_cast<uint32_t>(randomMatSize*randomMatSize); j++){ for(uint32_t j = 0; j < static_cast<uint32_t>(randomMatSize*randomMatSize); j++){

View File

@ -47,6 +47,8 @@ int main(int argc, char* argv[]){
std::cout<<"Number of testing rounds : "<<numTestRounds<<'\n'; std::cout<<"Number of testing rounds : "<<numTestRounds<<'\n';
std::cout<<"This test will need "<<(static_cast<uint64_t>(randomMatSize*randomMatSize)*numConcurrentThreads*3*8)/static_cast<double>(1024*1024)<<" MiB of RAM\n"<<std::endl; std::cout<<"This test will need "<<(static_cast<uint64_t>(randomMatSize*randomMatSize)*numConcurrentThreads*3*8)/static_cast<double>(1024*1024)<<" MiB of RAM\n"<<std::endl;
FailIfThreadsAreZero(numConcurrentThreads);
std::cout<<"Initializing random number generator..."<<std::flush; std::cout<<"Initializing random number generator..."<<std::flush;
std::mt19937_64 PRNG = InitPRNG(); std::mt19937_64 PRNG = InitPRNG();
std::cout<<"done\n"; std::cout<<"done\n";

View File

@ -18,7 +18,7 @@ int main(int argc, char* argv[]){
uint32_t maxHwThreads = omp_get_max_threads(); uint32_t maxHwThreads = omp_get_max_threads();
if (maxHwThreads < 52) if (maxHwThreads < 52)
numConcurrentThreads = maxHwThreads -4; numConcurrentThreads = maxHwThreads;
if (argc > 4){ if (argc > 4){
std::cout<<"ERROR: too many arguments for thread safety tester"<<std::endl; std::cout<<"ERROR: too many arguments for thread safety tester"<<std::endl;
@ -48,6 +48,8 @@ int main(int argc, char* argv[]){
std::cout<<"Number of testing rounds : "<<numTestRounds<<'\n'; std::cout<<"Number of testing rounds : "<<numTestRounds<<'\n';
std::cout<<"This test will need "<<((static_cast<uint64_t>(randomMatSize*randomMatSize)*numConcurrentThreads*8)+(static_cast<uint64_t>(randomMatSize)*numConcurrentThreads*8*2))/static_cast<double>(1024*1024)<<" MiB of RAM\n"<<std::endl; std::cout<<"This test will need "<<((static_cast<uint64_t>(randomMatSize*randomMatSize)*numConcurrentThreads*8)+(static_cast<uint64_t>(randomMatSize)*numConcurrentThreads*8*2))/static_cast<double>(1024*1024)<<" MiB of RAM\n"<<std::endl;
FailIfThreadsAreZero(numConcurrentThreads);
std::cout<<"Initializing random number generator..."<<std::flush; std::cout<<"Initializing random number generator..."<<std::flush;
std::mt19937_64 PRNG = InitPRNG(); std::mt19937_64 PRNG = InitPRNG();
std::cout<<"done\n"; std::cout<<"done\n";