Skip to content

Add thread yield function for spin-loops. #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/dunnington/bli_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#define BLIS_KERNEL_H


#define BLIS_YIELD bli_intel_yield


// -- LEVEL-3 MICRO-KERNEL CONSTANTS -------------------------------------------

#undef BLIS_SIMD_ALIGN_SIZE
Expand Down
3 changes: 3 additions & 0 deletions config/haswell/bli_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#define BLIS_KERNEL_H


#define BLIS_YIELD bli_intel_yield


// -- LEVEL-3 MICRO-KERNEL CONSTANTS AND DEFINITIONS ---------------------------

//
Expand Down
3 changes: 3 additions & 0 deletions config/sandybridge/bli_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#define BLIS_KERNEL_H


#define BLIS_YIELD bli_intel_yield


// -- LEVEL-3 MICRO-KERNEL CONSTANTS AND DEFINITIONS ---------------------------

//
Expand Down
2 changes: 2 additions & 0 deletions frame/base/bli_threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,3 +848,5 @@ dim_t bli_lcm( dim_t x, dim_t y)
{
return x * y / bli_gcd( x, y );
}

void bli_default_yield( void ) {}
2 changes: 2 additions & 0 deletions frame/base/bli_threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,6 @@ void bli_level3_thread_decorator
dim_t bli_gcd( dim_t x, dim_t y );
dim_t bli_lcm( dim_t x, dim_t y );

void bli_default_yield( void );

#endif
4 changes: 2 additions & 2 deletions frame/base/bli_threading_omp.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void bli_barrier( thread_comm_t* communicator, dim_t t_id )
}
else {
volatile bool_t* listener = &communicator->barrier_sense;
while( *listener == my_sense ) {}
while( *listener == my_sense ) { BLIS_YIELD(); }
}
}

Expand Down Expand Up @@ -208,7 +208,7 @@ void tree_barrier( barrier_t* barack )
}
else {
volatile int* listener = &barack->signal;
while( *listener == my_signal ) {}
while( *listener == my_signal ) { BLIS_YIELD(); }
}
}

Expand Down
2 changes: 1 addition & 1 deletion frame/base/bli_threading_pthreads.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int pthread_barrier_wait(pthread_barrier_t *barrier)
}
else {
volatile bool_t* listener = &barrier->sense;
while( *listener == my_sense ) {}
while( *listener == my_sense ) { BLIS_YIELD(); }
}
return 0;
}
Expand Down
12 changes: 12 additions & 0 deletions frame/include/bli_kernel_macro_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
#define BLIS_KERNEL_MACRO_DEFS_H


// -- THREAD YIELDING ----------------------------------------------------------

// Thread yield function for spin-loops.
//
// void BLIS_YIELD( void );
//

#ifndef BLIS_YIELD
#define BLIS_YIELD bli_default_yield
#endif


// -- MEMORY ALLOCATION --------------------------------------------------------

// Memory allocation functions. These macros define the three types of
Expand Down
4 changes: 4 additions & 0 deletions frame/include/bli_kernel_prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#ifndef BLIS_KERNEL_PROTOTYPES_H
#define BLIS_KERNEL_PROTOTYPES_H

// Generate prototype for thread yield function.

void BLIS_YIELD( void );

// Generate prototypes for level-3 micro-kernels.

//
Expand Down
6 changes: 6 additions & 0 deletions kernels/x86_64/haswell/3/bli_gemm_asm_d6x8.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@

#include "blis.h"

void bli_intel_yield()
{
//_mm_pause();
__asm__ __volatile__ ("pause");
}


#define SGEMM_INPUT_GS_BETA_NZ \
"vmovlps (%%rcx ), %%xmm0, %%xmm0 \n\t" \
Expand Down
6 changes: 6 additions & 0 deletions kernels/x86_64/penryn/3/bli_gemm_asm_d4x4.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@

#include "blis.h"

void bli_intel_yield()
{
//_mm_pause();
__asm__ __volatile__ ("pause");
}

void bli_sgemm_asm_8x4
(
dim_t k,
Expand Down
6 changes: 6 additions & 0 deletions kernels/x86_64/sandybridge/3/bli_gemm_asm_d8x4.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@

#include "blis.h"

void bli_intel_yield()
{
//_mm_pause();
__asm__ __volatile__ ("pause");
}

void bli_sgemm_asm_8x8
(
dim_t k,
Expand Down