summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src
diff options
context:
space:
mode:
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r--openmp/runtime/src/i18n/en_US.txt2
-rw-r--r--openmp/runtime/src/kmp.h2
-rw-r--r--openmp/runtime/src/z_Linux_util.c49
-rw-r--r--openmp/runtime/src/z_Windows_NT_util.c40
4 files changed, 50 insertions, 43 deletions
diff --git a/openmp/runtime/src/i18n/en_US.txt b/openmp/runtime/src/i18n/en_US.txt
index d3da38635b1..f2fabbf9d07 100644
--- a/openmp/runtime/src/i18n/en_US.txt
+++ b/openmp/runtime/src/i18n/en_US.txt
@@ -313,7 +313,7 @@ OBSOLETE "%1$s: OS proc %2$d maps to package %3$d core %4$d
OBSOLETE "%1$s: OS proc %2$d maps to package %3$d [core %4$d] thread %5$d"
OBSOLETE "%1$s: OS proc %2$d maps to package %3$d core %4$d thread %5$d"
OSProcMapToPack "%1$s: OS proc %2$d maps to %3$s"
-ChangeAffMask "%1$s: Internal thread %2$d changed affinity mask from %3$s to %4$s"
+OBSOLETE "%1$s: Internal thread %2$d changed affinity mask from %3$s to %4$s"
OBSOLETE "%1$s: OS proc %2$d maps to package %3$d, CPU %4$d, TPU %5$d"
OBSOLETE "%1$s: OS proc %2$d maps to package %3$d, CPU %4$d"
OBSOLETE "%1$s: HT enabled; %2$d packages; %3$d TPU; %4$d TPUs per package"
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index ec7e8babeaa..90110a1abb7 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -2936,8 +2936,6 @@ extern void __kmp_affinity_set_init_mask(int gtid, int isa_root); /* set affinit
#if OMP_40_ENABLED
extern void __kmp_affinity_set_place(int gtid);
#endif
-extern void __kmp_change_thread_affinity_mask( int gtid, kmp_affin_mask_t *new_mask,
- kmp_affin_mask_t *old_mask );
extern void __kmp_affinity_determine_capable( const char *env_var );
extern int __kmp_aux_set_affinity(void **mask);
extern int __kmp_aux_get_affinity(void **mask);
diff --git a/openmp/runtime/src/z_Linux_util.c b/openmp/runtime/src/z_Linux_util.c
index 75b61f12855..93126a74bc5 100644
--- a/openmp/runtime/src/z_Linux_util.c
+++ b/openmp/runtime/src/z_Linux_util.c
@@ -499,6 +499,55 @@ __kmp_test_then_and8( volatile kmp_int8 *p, kmp_int8 d )
}
}
+
+/*
+ * Change thread to the affinity mask pointed to by affin_mask argument
+ * and return a pointer to the old value in the old_mask argument, if argument
+ * is non-NULL.
+ */
+
+void
+__kmp_change_thread_affinity_mask( int gtid, kmp_affin_mask_t *new_mask,
+ kmp_affin_mask_t *old_mask )
+{
+ KMP_DEBUG_ASSERT( gtid == __kmp_get_gtid() );
+ if ( KMP_AFFINITY_CAPABLE() ) {
+ int status;
+ kmp_info_t *th = __kmp_threads[ gtid ];
+
+ KMP_DEBUG_ASSERT( new_mask != NULL );
+
+ if ( old_mask != NULL ) {
+ status = __kmp_get_system_affinity( old_mask, TRUE );
+ int error = errno;
+ if ( status != 0 ) {
+ __kmp_msg(
+ kmp_ms_fatal,
+ KMP_MSG( ChangeThreadAffMaskError ),
+ KMP_ERR( error ),
+ __kmp_msg_null
+ );
+ }
+ }
+
+ __kmp_set_system_affinity( new_mask, TRUE );
+
+ if (__kmp_affinity_verbose) {
+ char old_buf[KMP_AFFIN_MASK_PRINT_LEN];
+ char new_buf[KMP_AFFIN_MASK_PRINT_LEN];
+ __kmp_affinity_print_mask(old_buf, KMP_AFFIN_MASK_PRINT_LEN, old_mask);
+ __kmp_affinity_print_mask(new_buf, KMP_AFFIN_MASK_PRINT_LEN, new_mask);
+ KMP_INFORM( ChangeAffMask, "KMP_AFFINITY (Bind)", gtid, old_buf, new_buf );
+
+ }
+
+ /* Make sure old value is correct in thread data structures */
+ KMP_DEBUG_ASSERT( old_mask != NULL && (memcmp(old_mask,
+ th->th.th_affin_mask, __kmp_affin_mask_size) == 0) );
+ KMP_CPU_COPY( th->th.th_affin_mask, new_mask );
+ }
+}
+
#endif // KMP_OS_LINUX && KMP_AFFINITY_SUPPORTED
/* ------------------------------------------------------------------------ */
diff --git a/openmp/runtime/src/z_Windows_NT_util.c b/openmp/runtime/src/z_Windows_NT_util.c
index 023a4db7461..69b01be4300 100644
--- a/openmp/runtime/src/z_Windows_NT_util.c
+++ b/openmp/runtime/src/z_Windows_NT_util.c
@@ -1155,46 +1155,6 @@ __kmp_read_system_time( double *delta )
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
-/*
- * Change thread to the affinity mask pointed to by affin_mask argument
- * and return a pointer to the old value in the old_mask argument, if argument
- * is non-NULL.
- */
-
-void
-__kmp_change_thread_affinity_mask( int gtid, kmp_affin_mask_t *new_mask,
- kmp_affin_mask_t *old_mask )
-{
- kmp_info_t *th = __kmp_threads[ gtid ];
-
- KMP_DEBUG_ASSERT( *new_mask != 0 );
-
- if ( old_mask != NULL ) {
- *old_mask = SetThreadAffinityMask( th -> th.th_info.ds.ds_thread, *new_mask );
-
- if (! *old_mask ) {
- DWORD error = GetLastError();
- __kmp_msg(
- kmp_ms_fatal,
- KMP_MSG( CantSetThreadAffMask ),
- KMP_ERR( error ),
- __kmp_msg_null
- );
- }
- }
- if (__kmp_affinity_verbose)
- KMP_INFORM( ChangeAffMask, "KMP_AFFINITY (Bind)", gtid, *old_mask, *new_mask );
-
- /* Make sure old value is correct in thread data structures */
- KMP_DEBUG_ASSERT( old_mask != NULL && *old_mask == *(th -> th.th_affin_mask ));
-
- KMP_CPU_COPY(th -> th.th_affin_mask, new_mask);
-}
-
-
-/* ------------------------------------------------------------------------ */
-/* ------------------------------------------------------------------------ */
-
void * __stdcall
__kmp_launch_worker( void *arg )
{
OpenPOWER on IntegriCloud