Browse Source

Merge pull request #2725 from martin-frbg/ccheck_c11

Have c_check probe availability of C11 atomics support and stdatomic.h
tags/v0.3.11^2
Martin Kroeker GitHub 5 years ago
parent
commit
fcfb7ffafb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 37 additions and 10 deletions
  1. +24
    -0
      c_check
  2. +1
    -1
      common.h
  3. +3
    -0
      ctest.c
  4. +1
    -1
      driver/level3/level3_gemm3m_thread.c
  5. +1
    -1
      driver/level3/level3_syrk_threaded.c
  6. +1
    -1
      driver/others/blas_server.c
  7. +3
    -3
      driver/others/blas_server_omp.c
  8. +1
    -1
      driver/others/memory.c
  9. +1
    -1
      lapack/getrf/getrf_parallel.c
  10. +1
    -1
      lapack/getrf/potrf_parallel.c

+ 24
- 0
c_check View File

@@ -249,6 +249,28 @@ if (($architecture eq "x86") || ($architecture eq "x86_64")) {
}
}

$c11_atomics = 0;
if ($data =~ /HAVE_C11/) {
eval "use File::Temp qw(tempfile)";
if ($@){
warn "could not load PERL module File::Temp, so could not check compiler compatibility with C11";
$c11_atomics = 0;
} else {
($fh,$tmpf) = tempfile( SUFFIX => '.c' , UNLINK => 1 );
print $tmpf "#include <stdatomic.h>\nint main(void){}\n";
$args = " -c -o $tmpf.o $tmpf";
my @cmd = ("$compiler_name $flags $args >/dev/null 2>/dev/null");
system(@cmd) == 0;
if ($? != 0) {
$c11_atomics = 0;
} else {
$c11_atomics = 1;
}
unlink("$tmpf.o");
}
}


$data = `$compiler_name $flags -S ctest1.c && grep globl ctest1.s | head -n 1 && rm -f ctest1.s`;

$data =~ /globl\s([_\.]*)(.*)/;
@@ -352,6 +374,8 @@ print CONFFILE "#define __32BIT__\t1\n" if $binformat eq bin32;
print CONFFILE "#define __64BIT__\t1\n" if $binformat eq bin64;
print CONFFILE "#define FUNDERSCORE\t$need_fu\n" if $need_fu ne "";
print CONFFILE "#define HAVE_MSA\t1\n" if $have_msa eq 1;
print CONFFILE "#define HAVE_C11\t1\n" if $c11_atomics eq 1;


if ($os eq "LINUX") {



+ 1
- 1
common.h View File

@@ -681,7 +681,7 @@ __declspec(dllimport) int __cdecl omp_in_parallel(void);
__declspec(dllimport) int __cdecl omp_get_num_procs(void);
#endif

#if (__STDC_VERSION__ >= 201112L)
#ifdef HAVE_C11
#if defined(C_GCC) && ( __GNUC__ < 7)
// workaround for GCC bug 65467
#ifndef _Atomic


+ 3
- 0
ctest.c View File

@@ -153,3 +153,6 @@ ARCH_ARM
ARCH_ARM64
#endif

#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
HAVE_C11
#endif

+ 1
- 1
driver/level3/level3_gemm3m_thread.c View File

@@ -91,7 +91,7 @@
#endif

typedef struct {
#if __STDC_VERSION__ >= 201112L
#ifdef HAVE_C11
_Atomic
#else
volatile


+ 1
- 1
driver/level3/level3_syrk_threaded.c View File

@@ -67,7 +67,7 @@
#endif

typedef struct {
#if __STDC_VERSION__ >= 201112L
#ifdef HAVE_C11
_Atomic
#else
volatile


+ 1
- 1
driver/others/blas_server.c View File

@@ -141,7 +141,7 @@ typedef struct {

} thread_status_t;

#if (__STDC_VERSION__ >= 201112L)
#ifdef HAVE_C11
#define atomic_load_queue(p) __atomic_load_n(p, __ATOMIC_RELAXED)
#define atomic_store_queue(p, v) __atomic_store_n(p, v, __ATOMIC_RELAXED)
#else


+ 3
- 3
driver/others/blas_server_omp.c View File

@@ -55,7 +55,7 @@
int blas_server_avail = 0;

static void * blas_thread_buffer[MAX_PARALLEL_NUMBER][MAX_CPU_NUMBER];
#if __STDC_VERSION__ >= 201112L
#ifdef HAVE_C11
static atomic_bool blas_buffer_inuse[MAX_PARALLEL_NUMBER];
#else
static _Bool blas_buffer_inuse[MAX_PARALLEL_NUMBER];
@@ -320,7 +320,7 @@ int exec_blas(BLASLONG num, blas_queue_t *queue){

while(true) {
for(i=0; i < MAX_PARALLEL_NUMBER; i++) {
#if __STDC_VERSION__ >= 201112L
#ifdef HAVE_C11
_Bool inuse = false;
if(atomic_compare_exchange_weak(&blas_buffer_inuse[i], &inuse, true)) {
#else
@@ -345,7 +345,7 @@ int exec_blas(BLASLONG num, blas_queue_t *queue){
exec_threads(&queue[i], buf_index);
}

#if __STDC_VERSION__ >= 201112L
#ifdef HAVE_C11
atomic_store(&blas_buffer_inuse[buf_index], false);
#else
blas_buffer_inuse[buf_index] = false;


+ 1
- 1
driver/others/memory.c View File

@@ -1095,7 +1095,7 @@ static BLASULONG base_address = 0UL;
static BLASULONG base_address = BASE_ADDRESS;
#endif

#if __STDC_VERSION__ >= 201112L
#ifdef HAVE_C11
static _Atomic int memory_initialized = 0;
#else
static volatile int memory_initialized = 0;


+ 1
- 1
lapack/getrf/getrf_parallel.c View File

@@ -68,7 +68,7 @@ double sqrt(double);
#define GETRF_FACTOR 1.00


#if (__STDC_VERSION__ >= 201112L)
#ifdef HAVE_C11
#define atomic_load_long(p) __atomic_load_n(p, __ATOMIC_RELAXED)
#define atomic_store_long(p, v) __atomic_store_n(p, v, __ATOMIC_RELAXED)
#else


+ 1
- 1
lapack/getrf/potrf_parallel.c View File

@@ -101,7 +101,7 @@ static FLOAT dm1 = -1.;
#endif

typedef struct {
#if __STDC_VERSION__ >= 201112L
#ifdef HAVE_C11
_Atomic
#else
volatile


Loading…
Cancel
Save