aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/kmp_affinity.cpp
AgeCommit message (Collapse)Author
2019-10-08[OpenMP] Enable thread affinity on FreeBSDDavid Carlier
Reviewers: chandlerc, jlpeyton, jdoerfert, dim Reviewed-By: dim Differential Revision: https://reviews.llvm.org/D68580 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@374118 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-12[OpenMP] Remove OMP spec versioningJonathan Peyton
Remove all older OMP spec versioning from the runtime and build system. Patch by Terry Wilmarth Differential Revision: https://reviews.llvm.org/D64534 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@365963 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-03Fixed build warning with -DLIBOMP_USE_HWLOC=1Andrey Churbanov
Made type of depth of hwloc object to correapond with change from unsigned in hwloc 1,x to int in hwloc 2.x. This eliminates the warning on signed-unsigned comparison. Differential Revision: https://reviews.llvm.org/D62332 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@362401 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16Fix hwloc topology traversal code unable to handle situation where L2 cache ↵Paul Osmialowski
is common for the packages Currently cores within package that share the same L2 cache are grouped together. The current logic behind this assumes that the L2 cache is always at deeper (or the same) level than the package itself. In case when L2 cache is common for all packages (and the packages are at deeper level than L2 cache) the whole of the further topology discovery fails to find any computational units resulting in following assertion: Assertion failure at kmp_affinity.cpp(715): nActiveThreads == __kmp_avail_proc. OMP: Error #13: Assertion failure at kmp_affinity.cpp(715). This patch adds a bit of a logic that prevents such situation from occurring. Differential Revision: https://reviews.llvm.org/D61796 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@360890 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-30[OpenMP] Eliminate some compiler warningsJonathan Peyton
* Remove accidental == for = * Assign values to variables to appease compiler * Surround debug code with KMP_DEBUG * Remove unused local typedefs Differential Revision: https://reviews.llvm.org/D60983 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@359599 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19Update more file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@351648 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-16[OpenMP] Remove compiler warning about unused valueJoachim Protze
The compiler warns about an unused variable/statement: runtime/src/kmp_affinity.cpp:4958:18: warning: statement has no effect [-Wunused-value] KA_TRACE(1000, ; { ^ runtime/src/kmp_debug.h:84:24: note: in definition of macro 'KA_TRACE' __kmp_debug_printf x; \ ^ Instead of the unused reference to this function, this patch now calls the function with an empty string. The call to this function should have no effect. Patch provided by joachim.protze Reviewers: jlpeyton, hbae, AndreyChurbanov Reviewed By: AndreyChurbanov Tags: #openmp, #ompt Differential Revision: https://reviews.llvm.org/D56775 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@351323 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-15[OpenMP] Fix for nested proc_bind affinity bugJonathan Peyton
Using proc_bind clause on a nested #pragma omp parallel region with KMP_AFFINITY set causes an assertion error. This assertion occurs because the place-partition-var is not properly initialized in the nested master threads. Trying to get an intuitive result with KMP_AFFINITY + proc_bind is difficult because of how the KMP_AFFINITY gtid-to-place mapping occurs. This patch creates an initial place list no matter what affinity mechanism is used. For KMP_AFFINITY, the place-partition-var is initialized to all the places. Differential Revision: https://reviews.llvm.org/D55795 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@351227 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-13[OpenMP] Implement OpenMP 5.0 affinity format functionalityJonathan Peyton
This patch adds the affinity format functionality introduced in OpenMP 5.0. This patch adds: Two new environment variables: OMP_DISPLAY_AFFINITY=TRUE|FALSE OMP_AFFINITY_FORMAT=<string> and Four new API: 1) omp_set_affinity_format() 2) omp_get_affinity_format() 3) omp_display_affinity() 4) omp_capture_affinity() The affinity format functionality has two ICV's associated with it: affinity-display-var (bool) and affinity-format-var (string). The affinity-display-var enables/disables the functionality through the envirable OMP_DISPLAY_AFFINITY. The affinity-format-var is a formatted string with the special field types beginning with a '%' character similar to printf For example, the affinity-format-var could be: "OMP: host:%H pid:%P OStid:%i num_threads:%N thread_num:%n affinity:{%A}" The affinity-format-var is displayed by every thread implicitly at the beginning of a parallel region when any thread's affinity has changed (including a brand new thread being spawned), or explicitly using the omp_display_affinity() API. The omp_capture_affinity() function can capture the affinity-format-var in a char buffer. And omp_set|get_affinity_format() allow the user to set|get the affinity-format-var explicitly at runtime. omp_capture_affinity() and omp_get_affinity_format() both return the number of characters needed to hold the entire string it tried to make (not including NULL character). If not enough buffer space is available, both these functions truncate their output. Differential Revision: https://reviews.llvm.org/D55148 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@349089 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26[OpenMP] Fix balanced affinity so thread's private affinity mask is updatedJonathan Peyton
Balanced affinity only updated the thread's affinity with the operating system. This change also has the thread's private mask reflect that change as well so that any API that probes the thread's affinity mask will report the correct mask value. Differential Revision: https://reviews.llvm.org/D52379 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@343142 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24[OpenMP] Fixed affinity verbose double printing for balanced type.Jonathan Peyton
git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@340647 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09[OpenMP] Cleanup codeJonathan Peyton
This patch cleans up unused functions, variables, sign compare issues, and addresses some -Warning flags which are now enabled including -Wcast-qual. Not all the warning flags in LibompHandleFlags.cmake are enabled, but some are with this patch. Some __kmp_gtid_from_* macros in kmp.h are switched to static inline functions which allows us to remove the awkward definition of KMP_DEBUG_ASSERT() and KMP_ASSERT() macros which used the comma operator. This had to be done for the innumerable -Wunused-value warnings related to KMP_DEBUG_ASSERT() Differential Revision: https://reviews.llvm.org/D49105 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@339393 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09[OpenMP] Introduce hierarchical schedulingJonathan Peyton
This patch introduces the logic implementing hierarchical scheduling. First and foremost, hierarchical scheduling is off by default To enable, use -DLIBOMP_USE_HIER_SCHED=On during CMake's configure stage. This work is based off if the IWOMP paper: "Workstealing and Nested Parallelism in SMP Systems" Hierarchical scheduling is the layering of OpenMP schedules for different layers of the memory hierarchy. One can have multiple layers between the threads and the global iterations space. The threads will go up the hierarchy to grab iterations, using possibly a different schedule & chunk for each layer. [ Global iteration space (0-999) ] (use static) [ L1 | L1 | L1 | L1 ] (use dynamic,1) [ T0 T1 | T2 T3 | T4 T5 | T6 T7 ] In the example shown above, there are 8 threads and 4 L1 caches begin targeted. If the topology indicates that there are two threads per core, then two consecutive threads will share the data of one L1 cache unit. This example would have the iteration space (0-999) split statically across the four L1 caches (so the first L1 would get (0-249), the second would get (250-499), etc). Then the threads will use a dynamic,1 schedule to grab iterations from the L1 cache units. There are currently four supported layers: L1, L2, L3, NUMA OMP_SCHEDULE can now read a hierarchical schedule with this syntax: OMP_SCHEDULE='EXPERIMENTAL LAYER,SCHED[,CHUNK][:LAYER,SCHED[,CHUNK]...]:SCHED,CHUNK And OMP_SCHEDULE can still read the normal SCHED,CHUNK syntax from before I've kept most of the hierarchical scheduling logic inside kmp_dispatch_hier.h to try to keep it separate from the rest of the code. Differential Revision: https://reviews.llvm.org/D47962 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@336571 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-18[OpenMP] Fix affinity API for KMP_AFFINITY=none|compact|scatterJonathan Peyton
Currently, the affinity API reports garbage for the initial place list and any thread's place lists when using KMP_AFFINITY=none|compact|scatter. This patch does two things: for KMP_AFFINITY=none, Creates a one entry table for the places, this way, the initial place list is just a single place with all the proc ids in it. We also set the initial place of any thread to 0 instead of KMP_PLACE_ALL so that the thread reports that single place (place 0) instead of garbage (-1) when using the affinity API. When non-OMP_PROC_BIND affinity is used (including KMP_AFFINITY=compact|scatter), a thread's place list is populated correctly. We assume that each thread is assigned to a single place. This is implemented in two of the affinity API functions Differential Revision: https://reviews.llvm.org/D45527 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@330283 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13[AArch64] fix an issue with older /proc/cpuinfo layoutPaul Osmialowski
There are two /proc/cpuinfo layots in use for AArch64: old and new. The old one has all 'processor : n' lines in one section, hence checking for duplications does not make sense. Differential Revision: https://reviews.llvm.org/D41000 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@320593 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-08Fix thread affinity on non-x86 LinuxJonas Hahnfeld
To make thread affinity work according to the OpenMP spec, the runtime needs information about the hardware topology. On Linux the default way is to parse /proc/cpuinfo which contains this information for x86 machines but (at least) not for AArch64 and Power architectures. Fortunately, there is a different code path which is able to get that data from sysfs. The needed patch has landed in 2006 for Linux 2.6.16 which is safe to assume nowadays (even RHEL 5 had a kernel version derived from 2.6.18, and we are now at RHEL 7!). Differential Revision: https://reviews.llvm.org/D40357 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@320151 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-06Eliminate double printing of verbose affinity settingsJonathan Peyton
Redundant extra verbose output of binding to full mask in case affinity=balanced or OMP_PLACES=<any> or OMP_PROC_BIND=<any> Differential Revision: https://reviews.llvm.org/D40624 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@319960 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-30Extension of HWLOC topology discovery with NUMA nodes and tilesAndrey Churbanov
Patch by Olga Malysheva Differential Revision: https://reviews.llvm.org/D40309 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@319422 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-29Warning is emitted when tiles are requested but cannot be usedJonathan Peyton
Added two warnings: 1) Before building the topology map check if tiles are requested but the topo method is not hwloc; 2) After building the topology map check if tiles are requested but not detected by the library. Patch by Olga Malysheva Differential Revision: https://reviews.llvm.org/D40340 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@319374 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-20Apply formatting changesJonathan Peyton
.clang-format's comments are removed and a (hopefully) final set of formatting changes are applied. Differential Revision: https://reviews.llvm.org/D38837 Differential Revision: https://reviews.llvm.org/D38920 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@316227 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27Remove unnecessary semicolonsJonathan Peyton
Removes semicolons after if {} blocks, function definitions, etc. I was able to apply the large OMPT patch cleanly on top of this one with no conflicts. git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@314340 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-05Minor code cleanup of Klocwork issuesJonathan Peyton
Minor code cleanup of Klocwork issues. Fatal messages are given no return attribute. Define and use KMP_NORETURN to work for multiple C++ versions. Patch by Terry Wilmarth Differential Revision: https://reviews.llvm.org/D37275 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@312538 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-17OpenMP RTL cleanup: eliminated warnings with -Wcast-qual, patch 2.Andrey Churbanov
Changes are: got all atomics to accept volatile pointers that allowed to simplify many type conversions. Windows specific code fixed correspondingly. Differential Revision: https://reviews.llvm.org/D35417 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@308164 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-03OpenMP RTL cleanup: eliminated warnings with -Wcast-qual.Andrey Churbanov
Changes are: replaced C-style casts with cons_cast and reinterpret_cast; type of several counters changed to signed; type of parameters of 32-bit and 64-bit AND and OR intrinsics changes to unsigned; changed files formatted using clang-format version 3.8.1. Differential Revision: https://reviews.llvm.org/D34759 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@307020 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-01Fix minor formatting issuesJonathan Peyton
Some code was restructured to move it under KMP_DEBUG. The rest is formatting changes to fix some things broken by clang-format Patch by Terry Wilmarth Differential Revision: https://reviews.llvm.org/D33744 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@304438 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-31Fix for KMP_AFFINITY=disabled and KMP_TOPOLOGY_METHOD=hwlocJonathan Peyton
With these settings, the create_hwloc_map() method was being called causing an assert(). After some consideration, it was determined that disabling affinity explicitly should just disable hwloc as well. i.e., KMP_AFFINITY overrides KMP_TOPOLOGY_METHOD. This lets the user know that the Hwloc mechanism is being ignored when KMP_AFFINITY=disabled. Differential Revision: https://reviews.llvm.org/D33208 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@304344 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-15Fix for KMP_AFFINITY=respect with multiple processor groupsJonathan Peyton
An assert() was being tripped when KMP_AFFINITY=respect + Multiple Processor Groups. Let __kmp_affinity_create_proc_group_map() function be able to create address2os object which contains a single group by deleting restriction that process affinity mask must span multiple groups. git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@303101 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-12Clang-format and whitespace cleanup of source codeJonathan Peyton
This patch contains the clang-format and cleanup of the entire code base. Some of clang-formats changes made the code look worse in places. A best effort was made to resolve the bulk of these problems, but many remain. Most of the problems were mangling line-breaks and tabbing of comments. Patch by Terry Wilmarth Differential Revision: https://reviews.llvm.org/D32659 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@302929 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-25Fix Hwloc API IncompatibilityJonathan Peyton
Older Hwloc libraries (< 1.10.0) don't offer the HWLOC_OBJ_NUMANODE nor HWLOC_OBJ_PACKAGE types. Instead they are named HWLOC_OBJ_NODE and HWLOC_OBJ_SOCKET instead. This patch just defines the newer names based on the older names when using an older Hwloc. Differential Revision: https://reviews.llvm.org/D32496 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@301349 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13KMP_HW_SUBSET extended with NUMA support when HWLOC enabledAndrey Churbanov
Differential Revision: https://reviews.llvm.org/D31600 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@300220 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-20Fix incorrect initial value of __kmp_affinity_type.Jonathan Peyton
Affinity initialization code expects __kmp_affinity_type has the value affinity_default by default, but the cleanup code does not properly set the value back to affinity_default. This may introduce some issues when multiple roots are trying to initialize/uninitialize the runtime successively. Patch by Hansang Bae Differential Revision: https://reviews.llvm.org/D31012 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@298313 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-27Printing OS thread id, when KMP_AFFINITY is set.Jonathan Peyton
Patch by Vishakha Agrawal Differential Revision: https://reviews.llvm.org/D28873 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@293315 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12kmp_affinity: Fix check if specific bit is setJonas Hahnfeld
Clang 4.0 trunk warns: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses] This points to a potential bug if the code really wants to check if the single bit is not set: If for example (buf.edx >> 9) = 2 (has any bit set except the least significant one), 'logical not' will return 0 which stays 0 after the 'bitwise and'. To do this correctly we first need to evaluate the 'bitwise and'. In that case it returns 2 & 1 = 0 which after the 'logical not' evaluates to 1. Differential Revision: https://reviews.llvm.org/D28599 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@291764 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-14Introduce dynamic affinity dispatch capabilitiesJonathan Peyton
This set of changes enables the affinity interface (Either the preexisting native operating system or HWLOC) to be dynamically set at runtime initialization. The point of this change is that we were seeing performance degradations when using HWLOC. This allows the user to use the old affinity mechanisms which on large machines (>64 cores) makes a large difference in initialization time. These changes mostly move affinity code under a small class hierarchy: KMPAffinity class Mask {} KMPNativeAffinity : public KMPAffinity class Mask : public KMPAffinity::Mask KMPHwlocAffinity class Mask : public KMPAffinity::Mask Since all interface functions (for both affinity and the mask implementation) are virtual, the implementation can be chosen at runtime initialization. Differential Revision: https://reviews.llvm.org/D26356 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@286890 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-12Fix bitmask upper bounds checkJonathan Peyton
Rather than checking KMP_CPU_SETSIZE, which doesn't exist when using Hwloc, we use the get_max_proc() function which can vary based on the operating system. For example on Windows with multiple processor groups, it might be the case that the highest bit possible in the bitmask is not equal to the number of hardware threads on the machine but something higher than that. Differential Revision: https://reviews.llvm.org/D24206 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@281245 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-02Move function into cpp file under KMP_AFFINITY_SUPPORTED guard.Jonathan Peyton
When affinity isn't supported, __kmp_affinity_compact doesn't exist. The problem is that in kmp_affinity.h there is a function which uses it without the proper KMP_AFFINITY_SUPPORTED guard around it. The compiler was smart enough to ignore it and the function __kmp_affinity_cmp_Address_child_num which relies on it, but I think it is cleaner to have it under the proper guard. Since the function is only used in the kmp_affinity.cpp file and there aren't any plans to have it elsewhere. I have moved it there. git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@280542 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-02Replace a bad instance of __kmp_free() with KMP_CPU_FREE_ARRAY() macro.Jonathan Peyton
git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@280530 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-05Fixed x2APIC discovery for 256-processor architectures.Andrey Churbanov
Mask for value read from ebx register returned by CPUID expanded to 0xFFFF. Differential Revision: https://reviews.llvm.org/D23203 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@277825 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-29Make balanced affinity work on AArch64.Paul Osmialowski
This patch enables balanced affinity on machines that do not have hardware threads and have cores clustered into packages. In facts, balacing algorithm could be generalized for any arrangement with at least two levels of hierarchy (depth > 1). Differential Revision: https://reviews.llvm.org/D22365 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@277212 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08D22136: Memory leaks fixed by adding missed __kmp_free() callsAndrey Churbanov
git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@274850 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21Improvements to process affinity mask settingJonathan Peyton
A couple improvements: 1) Add ability to limit fullMask size when KMP_HW_SUBSET limits resources. 2) Make KMP_HW_SUBSET work for affinity_none, and only limit fullMask in this case. Patch by Andrey Churbanov. Differential Revision: http://reviews.llvm.org/D21528 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@273278 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16Change hwloc discovery algorithm to print topology only for accessible resourcesJonathan Peyton
Change hwloc discovery algorithm to print topology for only accessible resources, and report uniformity correspondingly, similar to what other topology discovery algorithms do. Fixes minor inconsistency in total topology reported and resources used for threads binding in case hwloc used. Patch by Andrey Churbanov. Differential Revision: http://reviews.llvm.org/D21389 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@272952 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16Fixed missing memory cleanup in __kmp_affinity_create_hwloc_map()Jonathan Peyton
Cleanup: fixed missing memory cleanup in couple of corner cases. Fixes possible memory leak in some corner cases Patch by Andrey Churbanov Differential Revision: http://reviews.llvm.org/D21355 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@272946 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16Deprecate KMP_PLACE_THREADS and rename as KMP_HW_SUBSETJonathan Peyton
Deprecate KMP_PLACE_THREADS and rename it to KMP_HW_SUBSET due to confusion about its purpose and function among users. KMP_HW_SUBSET is an environment variable which allows users to easily pick a subset of the hardware topology to use. e.g., KMP_HW_SUBSET=30c,2t means use 30 cores, 2 threads per core. Patch by Andrey Churbanov Differential Revision: http://reviews.llvm.org/D21340 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@272937 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-13Affinity mask processing improvementsJonathan Peyton
Remove static specifier from var fullMask and remove kmp_get_fullMask() routine. When iterating through procs in a mask, always check if proc is in fullMask (this check was missing in a few places). Patch by Brian Bliss. Differential Revision: http://reviews.llvm.org/D21300 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@272589 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-13Hwloc refactoring patchJonathan Peyton
These changes remove the hwloc_topology_ignore_type function which doesn't exist in the hwloc 2.0 API. In the existing code, the topology extracted from hwloc has the cache levels stripped out and then assumes the final stripped topology follows the typical three-level topology: packages -> cores -> HW threads. But the code is doing unclean manipulations to determine at what level those resources are located and also assumes too much about what hwloc is detecting (there could be intermediate levels in between socket and core for instance). This new way of extracting the topology doesn't strip out any hardware objects that hwloc detects. It does not assume the three level topology, and instead searches for the relevant three levels within the topology for each bit of information using hwloc interface functions. i.e., the three level topology subset that our affinity code is interested in is extracted from the hwloc topology tree directly. For example, the new __kmp_hwloc_get_nobjs_under_obj function gives the user the number of cores under a socket reliably without worrying if there are unexpected objects between the socket object and core object in the hwloc topology structure. Also, now that all topology information is kept, there are also possibilities of using the caches/numa nodes to determine more sophisticated affinity settings in the future. There is also some cleanup code added for the destruction of the __kmp_hwloc_topology object. Differential Revision: http://reviews.llvm.org/D21195 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@272565 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25Remove architecture dependent Hwloc DEBUG sectionJonathan Peyton
This debug sections's functionality can be replicated using the environment variable KMP_TOPOLOGY_METHOD with different values and KMP_AFFINITY=verbose git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@267472 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25Fix buffer problem with printing long Hwloc affinity maskJonathan Peyton
This change has the hwloc_bitmap_list_snprintf() function use the entire buffer to print the mask. There is no need to shorten the buffer length by 7. It only needs to be shortened by one byte. git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@267470 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-12New API for restoring current thread's affinity to init affinity of applicationJonathan Peyton
This new API, int kmp_set_thread_affinity_mask_initial(), is available for use by other parallel runtime libraries inside a possibly OpenMP-registered thread. This entry point restores the current thread's affinity mask to the affinity mask of the application when it first began. If -1 is returned it can be assumed that either the thread hasn't called affinity initialization or that the thread isn't registered with the OpenMP library. If 0 is returned then, then the call was successful. Any return value greater than zero indicates an error occurred when setting affinity. Differential Revision: http://reviews.llvm.org/D15867 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@257489 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-30Adding Hwloc library option for affinity mechanismJonathan Peyton
These changes allow libhwloc to be used as the topology discovery/affinity mechanism for libomp. It is supported on Unices. The code additions: * Canonicalize KMP_CPU_* interface macros so bitmask operations are implementation independent and work with both hwloc bitmaps and libomp bitmaps. So there are new KMP_CPU_ALLOC_* and KMP_CPU_ITERATE() macros and the like. These are all in kmp.h and appropriately placed. * Hwloc topology discovery code in kmp_affinity.cpp. This uses the hwloc interface to create a libomp address2os object which the rest of libomp knows how to handle already. * To build, use -DLIBOMP_USE_HWLOC=on and -DLIBOMP_HWLOC_INSTALL_DIR=/path/to/install/dir [default /usr/local]. If CMake can't find the library or hwloc.h, then it will tell you and exit. Differential Revision: http://reviews.llvm.org/D13991 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@254320 91177308-0d34-0410-b5e6-96231b3b80d8