Fix Bug in DTL

When library is built as single thread and trace is enabled, the test
applications in test folder fail to compile. In the file aoclos.c the function
AOCL_gettid() uses "omp_get_thread_num() to get thread_id, which is only
enabled when OpenMP based parallel BLIS library is generated. To fix this in
single thread case we now return zero for thread id, openmp function is used
only when BLIS_ENABLE_OPENMP macro is defined. However this is not a complete
fix. If library is built with pthread, AOCL_gettid() always return 0, which is
not the intended behaviour.

Change-Id: I5b79ed57d27d0022d3dcab0e2a3a557c8e4ff8ee
This commit is contained in:
Kiran Varaganti
2020-11-02 12:05:09 +05:30
parent cd9a751aa0
commit 65daaab6ac
4 changed files with 26 additions and 18 deletions

View File

@@ -1,10 +1,10 @@
/*===================================================================
* File Name : aoclos.c
*
*
* Description : Abstraction for os services used by DTL.
*
* Copyright (C) 2020, Advanced Micro Devices, Inc
*
*
*==================================================================*/
#include "aocltpdef.h"
#include "aocldtl.h"
@@ -21,14 +21,14 @@
#if defined(__linux__)
/*
/*
Disable intrumentation for these functions as they will also be
called from compiler generated instumation code to trace
called from compiler generated instumation code to trace
function execution.
It needs to be part of declration in the C file so can't be
It needs to be part of declration in the C file so can't be
moved to header file.
*/
uint32 AOCL_gettid(void) __attribute__((no_instrument_function));
@@ -37,7 +37,15 @@ uint64 AOCL_getTimestamp(void) __attribute__((no_instrument_function));
uint32 AOCL_gettid(void)
{
return omp_get_thread_num();
#ifdef BLIS_ENABLE_OPENMP
return omp_get_thread_num();
#else
return 0; // will not work for pthread-based parallelization
#endif
}
pid_t AOCL_getpid(void)
@@ -52,7 +60,7 @@ uint64 AOCL_getTimestamp(void)
/* The C11 way */
if (clock_gettime(CLOCK_REALTIME, &tms))
{
return -1;
return -1;
}
/* seconds, multiplied with 1 million */
@@ -62,7 +70,7 @@ uint64 AOCL_getTimestamp(void)
/* round up if necessary */
if (tms.tv_nsec % 1000 >= 500)
{
++micros;
++micros;
}
return micros;
}

View File

@@ -38,7 +38,7 @@
#endif
#include "blis.h"
#define PRINT
//#define PRINT
// #define BLIS // For blis keep this line and comment CBLAS and BLAS
#ifdef BLIS_ENABLE_CBLAS
@@ -234,4 +234,4 @@ int main (int argc, char** argv )
bli_finalize();
return 0;
}
}

View File

@@ -64,12 +64,12 @@ int main( int argc, char** argv )
bli_init();
n_repeats = 1;
n_repeats = 3;
#ifndef PRINT
p_begin = 10;
p_end = 100;
p_inc = 10;
p_begin = 40;
p_end = 4000;
p_inc = 40;
n_input = -1;
#else

View File

@@ -106,7 +106,7 @@ int main( int argc, char** argv )
bli_param_map_blis_to_netlib_trans( transb, &f77_transb );
// printf("BLIS Library version is : %s\n", bli_info_get_version_str());
printf("BLIS Library version is : %s\n", bli_info_get_version_str());
@@ -129,9 +129,9 @@ int main( int argc, char** argv )
exit(1);
}
fprintf(fout, "m\t k\t n\t cs_a\t cs_b\t cs_c\t gflops\t GEMM_Algo\n");
fprintf(fout, "m\t k\t n\t cs_a\t cs_b\t cs_c\t gflops\n");
printf("~~~~~~~~~~_BLAS\t m\t k\t n\t cs_a\t cs_b\t cs_c \t gflops\t GEMM_Algo\n");
printf("~~~~~~~~~~_BLAS\t m\t k\t n\t cs_a\t cs_b\t cs_c \t gflops\n");
inc_t cs_a;
inc_t cs_b;