Skip to content

Commit

Permalink
use the query
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Hammond <[email protected]>
  • Loading branch information
jeffhammond committed May 3, 2022
1 parent e8510aa commit b82eb42
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
8 changes: 4 additions & 4 deletions frame/thread/bli_affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
// https://github.com/flame/blis/issues/604
// https://github.com/flame/blis/issues/603

#include "blis.h"

#ifndef BLIS_ENABLE_AFFINITY

// define the symbol for platforms like Windows and MacOS that do not support the Linux affinity API

int bli_affinity_get_hw_size(int scope)
dim_t bli_affinity_get_hw_size(bli_affinity_scope_t scope)
{
// this is the largest possible value returned by this function
// and it means that the affinity mask does not constrain the current scope.
Expand All @@ -62,13 +64,11 @@ int bli_affinity_get_hw_size(int scope)
#include <sched.h>
#include <unistd.h>

#include "blis.h"

// scope is either the calling process or the calling thread:
// 0 = calling process
// 1 = calling thread

int bli_affinity_get_hw_size(int scope)
dim_t bli_affinity_get_hw_size(bli_affinity_scope_t scope)
{
int rc;
int active_cpus;
Expand Down
6 changes: 4 additions & 2 deletions frame/thread/bli_affinity.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#ifndef BLIS_AFFINITY_H
#define BLIS_AFFINITY_H

int bli_affinity_get_hw_size(int scope);
dim_t bli_affinity_get_hw_size(int scope);

#endif BLIS_AFFINITY_H
typedef enum { process = 0, thread = 1 } bli_affinity_scope_t;

#endif // BLIS_AFFINITY_H
26 changes: 26 additions & 0 deletions frame/thread/bli_l3_decor_openmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ void bli_l3_thread_decorator_thread_check
)
{
dim_t n_threads_real = omp_get_num_threads();
dim_t n_threads_hwmask;
if ( omp_in_parallel() ) {
n_threads_hwmask = bli_affinity_get_hw_size(thread);
} else {
n_threads_hwmask = bli_affinity_get_hw_size(process);
}

// Check if the number of OpenMP threads created within this parallel
// region is different from the number of threads that were requested
Expand Down Expand Up @@ -241,6 +247,26 @@ void bli_l3_thread_decorator_thread_check

// Synchronize all threads and continue.
_Pragma( "omp barrier" )

return;
}

// Check if the number of OpenMP threads created within this parallel
// region is different from the number of threads that are available
// to BLIS in the calling context.
if ( n_threads_hwsize < n_threads || n_threads_hwsize < n_threads_real)
{
bli_print_msg( "The affinity mask on this process does not have "
"enough HW threads for your requested SW threads.",
__FILE__, __LINE__ );

bli_thrcomm_init( n_threads_hwsize, gl_comm );
bli_rntm_set_num_threads_only( n_threads_hwsize, rntm );
#warning HELP ME HERE
bli_rntm_set_ways_only( 1, 1, 1, 1, 1, rntm );

// Synchronize all threads and continue.
_Pragma( "omp barrier" )
}
}

Expand Down

0 comments on commit b82eb42

Please sign in to comment.