summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src/z_Linux_util.c
Commit message (Collapse)AuthorAgeFilesLines
* Change source files from .c to .cppJonathan Peyton2016-12-141-2612/+0
| | | | | | | | Patch by Hansang Bae Differential Revision: https://reviews.llvm.org/D26688 llvm-svn: 289732
* Cleanup: memory leaks on warnings printing fixed; some memory freeing ↵Andrey Churbanov2016-11-281-15/+47
| | | | | | | | | | cleaned; poor indents and one typo fixed. Patch by Victor Campos. Differential Revision: https://reviews.llvm.org/D26786 llvm-svn: 288054
* Update stats-gathering codeJonathan Peyton2016-11-141-11/+9
| | | | | | | | | | | | | Have developer timers use partitioning scheme which also required that some redundant developer timers be removed in favor of the already existing normal timers. Move per thread stats initialization to just after global thread id assignment which is as early as possible. Also put all global stats initialization code in __kmp_stats_init() and all global stats destruction code in __kmp_stats_fini(). Differential Revision: https://reviews.llvm.org/D26361 llvm-svn: 286892
* Introduce dynamic affinity dispatch capabilitiesJonathan Peyton2016-11-141-112/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 286890
* [OpenMP] Enable ThreadSanitizer to check OpenMP programsJonas Hahnfeld2016-11-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | This patch allows ThreadSanitizer (Tsan) to verify OpenMP programs. It means that no false positive will be reported by Tsan when verifying an OpenMP programs. This patch introduces annotations within the OpenMP runtime module to provide information about thread synchronization to the Tsan runtime. In order to enable the Tsan support when building the runtime, you must enable the TSAN_SUPPORT option with the following environment variable: -DLIBOMP_TSAN_SUPPORT=TRUE The annotations will be enabled in the main shared library (same mechanism of OMPT). Patch by Simone Atzeni and Joachim Protze! Differential Revision: https://reviews.llvm.org/D13072 llvm-svn: 286115
* Disable monitor thread creation by default.Jonathan Peyton2016-09-271-1/+31
| | | | | | | | | | | | | This change set disables creation of the monitor thread by default. The global counter maintained by the monitor thread was replaced by logic that uses system time directly, and cyclic yielding on Linux target was also removed since there was no clear benefit of using it. Turning on KMP_USE_MONITOR variable (=1) enables creation of monitor thread again if it is really necessary for some reasons. Differential Revision: https://reviews.llvm.org/D24739 llvm-svn: 282507
* Decouple the kmp_affin_mask_t type from determining if affinity is capableJonathan Peyton2016-09-021-2/+2
| | | | | | | the __kmp_affinity_determine_capable() functions are highly operating system specific. This change has the functions use the type they expect explicitly. llvm-svn: 280538
* Apply the KMP_USE_FUTEX feature macro everywhereJonathan Peyton2016-06-221-2/+2
| | | | llvm-svn: 273438
* Fix crash when libomp loaded/unloaded multiple timesJonathan Peyton2016-06-131-38/+23
| | | | | | | | | | | | | | | | | The problem scenario is the following: A dynamic library, libfoo.so, depends on libomp.so (it creates parallel region and calls some omp functions). An application has a loop where it dynamically loads libfoo.so, calls the function from it, unloads libfoo.so. After several loop iterations application crashes with the message about lack of resources OMP: Error #34: System unable to allocate necessary resources for OMP thread: The problem is that pthread_kill() was not followed by pthread_join() in case of terminated thread. This patch fixes this problem for both worker and monitor threads. Differential Revision: http://reviews.llvm.org/D21200 llvm-svn: 272567
* Add an assembly __kmp_invoke_microtask for ppc64[le]Hal Finkel2016-05-261-1/+1
| | | | | | | | | Clang no longer restricts itself to generating microtasks with a small number of arguments, and so an assembly implementation is required to prevent hitting the parameter limit present in the C implementation. This adds an implementation for ppc64[le]. llvm-svn: 270821
* Remove trailing whitespace in src/ directoryJonathan Peyton2016-05-201-4/+4
| | | | | | This patch doesn't affect D19878's context. So D19878 still cleanly applies. llvm-svn: 270252
* Clean all the mess around KMP_USE_FUTEX and kmp_lock.hPaul Osmialowski2016-05-161-3/+4
| | | | | | | | | | | | | | | | | | KMP_USE_FUTEX preprocessor definition defined in kmp_lock.h is used inconsequently throughout LLVM libomp code. * some .c files that use this define do not include kmp_lock.h file, in effect guarded part of code are never compiled * some places in code use architecture-depending preprocessor logic expressions which effectively disable use of Futex for AArch64 architecture, all these places should use '#if KMP_USE_FUTEX' instead to avoid any further confusions * some places use KMP_HAS_FUTEX which is nowhere defined, KMP_USE_FUTEX should be used instead Differential Revision: http://reviews.llvm.org/D19629 llvm-svn: 269642
* Solve 'Too many args to microtask' problemPaul Osmialowski2016-05-131-3/+3
| | | | | | | | | | | | | This patch solves 'Too many args to microtask' problem which occurs while executing lulesh2.0.3 benchmark on AArch64. To solve this I had to wrtite AArch64 assembly version of __kmp_invoke_microtask() function, similar to x86 and x86_64 implementations. Differential Revision: http://reviews.llvm.org/D19879 llvm-svn: 269399
* [STATS] Use partitioned timer schemeJonathan Peyton2016-05-051-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | This change removes the current timers with ones that partition time properly. The current timers are nested, so that if a new timer, B, starts when the current timer, A, is already timing, A's time will include B's. To eliminate this problem, the partitioned timers are designed to stop the current timer (A), let the new timer run (B), and when the new timer is finished, restart the previously running timer (A). With this partitioning of time, a threads' timers all sum up to the OMP_worker_thread_life time and can now easily show the percentage of time a thread is spending in different parts of the runtime or user code. There is also a new state variable associated with each thread which tells where it is executing a task. This corresponds with the timers: OMP_task_*, e.g., if time is spent in OMP_task_taskwait, then that thread executed tasks inside a #pragma omp taskwait construct. The changes are mostly changing the MACROs to use the new PARITIONED_* macros, the new partitionedTimers class and its methods, and new state logic. Differential Revision: http://reviews.llvm.org/D19229 llvm-svn: 268640
* Fix for pthread_setspecific (TLS and shutdown) problemJonathan Peyton2016-04-181-6/+9
| | | | | | | | | | | | | | | Some codes that use TLS fail intermittently because one thread tries to write TLS values after the TLS key has been destroyed by another thread. This happens when one thread executes library shutdown (and destroys TLS keys), while another thread starts to execute the TLS key destructor routine. Before this change, the kmp_init_runtime flag was checked before calling pthread_* TLS functions, but this flag is set to FALSE later than the destruction of the TLS keys, which leads to failure. The fix is to check kmp_init_gtid instead, as this flag is unset *before* the destruction of TLS keys. Differential Revision: http://reviews.llvm.org/D19022 llvm-svn: 266674
* Exponential back off logic for test-and-set lockJonathan Peyton2016-04-141-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | This change adds back off logic in the test and set lock for better contended lock performance. It uses a simple truncated binary exponential back off function. The default back off parameters are tuned for x86. The main back off logic has a two loop structure where each is controlled by a user-level parameter: max_backoff - limits the outer loop number of iterations. This parameter should be a power of 2. min_ticks - the inner spin wait loop number of "ticks" which is system dependent and should be tuned for your system if you so choose. The "ticks" on x86 correspond to the time stamp counter, but on other architectures ticks is a timestamp derived from gettimeofday(). The user can modify these via the environment variable: KMP_SPIN_BACKOFF_PARAMS=max_backoff[,min_ticks] Currently, since the default user lock is a queuing lock, one would have to also specify KMP_LOCK_KIND=tas to use the test-and-set locks. Differential Revision: http://reviews.llvm.org/D19020 llvm-svn: 266329
* Formatting fixesJonathan Peyton2016-01-271-124/+73
| | | | | | | Removing extraneous { } bracket sections. Unindenting blocks of code as a result. Also removing empty #ifdef KMP_STUB llvm-svn: 258986
* Removing extra empty linesJonathan Peyton2016-01-271-7/+0
| | | | llvm-svn: 258984
* Prevent monitor thread creation when KMP_BLOCKTIME="infinite"Jonathan Peyton2015-12-181-0/+8
| | | | | | | | | | | When users sets envirable KMP_BLOCKTIME to "infinite" (the time one busy-waits at barrieres, etc.), the monitor thread is not useful and can be ignored. This change prevents the creation of the monitor thread when the users sets KMP_BLOCKTIME to "infinite". Differential Revision: http://reviews.llvm.org/D15628 llvm-svn: 256061
* Adding Hwloc library option for affinity mechanismJonathan Peyton2015-11-301-2/+11
| | | | | | | | | | | | | | | | | | | 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 llvm-svn: 254320
* Fixes to wait-loop codeJonathan Peyton2015-11-091-2/+3
| | | | | | | | | | | | | 1) Add get_ptr_type() method to all wait flag types. 2) Flag in sleep_loc may change type by the time the resume is called from __kmp_null_resume_wrapper. We use get_ptr_type to obtain the real type and compare it to the casted object received. If they don't match, we know the flag has changed (already resumed and replaced by another flag). If they match, it doesn't hurt to go ahead and resume it. Differential Revision: http://reviews.llvm.org/D14458 llvm-svn: 252487
* Remove some empty lines.Jonathan Peyton2015-11-041-2/+0
| | | | llvm-svn: 252084
* Formatting/Whitespace/Comment changes associated with wait/release improvements.Jonathan Peyton2015-10-081-3/+2
| | | | llvm-svn: 249725
* Debug trace and assert statement changes for wait/release improvements.Jonathan Peyton2015-10-081-2/+2
| | | | | | | These changes improve/update the trace messages and debug asserts related to the previous wait/release checkin. llvm-svn: 249717
* Use sysconf for the number of cores on FreeBSD too.Joerg Sonnenberger2015-09-211-13/+2
| | | | llvm-svn: 248209
* Add basic NetBSD support.Joerg Sonnenberger2015-09-211-9/+9
| | | | llvm-svn: 248204
* Remove unused caller_gtid variable in both z_Linux_util.c and ↵Jonathan Peyton2015-08-261-3/+0
| | | | | | z_Windows_NT_util.c llvm-svn: 246059
* Tidy statistics collectionJonathan Peyton2015-08-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes some statistics counters and timers which were not used, adds new counters and timers for some language features that were not monitored previously and separates the counters and timers into those which are of interest for investigating user code and those which are only of interest to the developer of the runtime itself. The runtime developer statistics are now ony collected if the additional #define KMP_DEVELOPER_STATS is set. Additional user statistics which are now collected include: * Count of nested parallelism (omp parallel inside a parallel region) * Count of omp distribute occurrences * Count of omp teams occurrences * Counts of task related statistics (taskyield, task execution, task cancellation, task steal) * Values passed to omp_set_numtheads * Time spent in omp single and omp master None of this affects code compiled without stats gathering enabled, which is the normal library build mode. This also fixes the CMake build by linking to the standard c++ library when building the stats library as it is a requirement. The normal library does not have this requirement and its link phase is left alone. Differential Revision: http://reviews.llvm.org/D11759 llvm-svn: 244677
* D11301: Remove the __kmp_invoke_microtask() that relies on libffiAndrey Churbanov2015-08-051-55/+1
| | | | llvm-svn: 244031
* D11159: Fixing the stack offset functionalityAndrey Churbanov2015-08-051-3/+8
| | | | llvm-svn: 244030
* Fix some bugs in OMPT supportJonathan Peyton2015-07-131-2/+26
| | | | | | | | | | | | | | | | | | | | | | | 1.) in kmp_csupport.c, move computation of parameters only needed for OMPT tracing inside a conditional to reduce overhead if not receiving ompt_event_master_begin callbacks. 2.) in kmp_gsupport.c, remove spurious reset of OMPT reenter_runtime_frame (which is set in its caller, GOMP_parallel_start correct placement of #if OMP_TRACE so that state is maintained even if tracing support not included. 3.) in z_Linux_util.c, add architecture independent support for OMPT by setting and resetting OMPT's exit_frame_ptr before and after invoking a microtask. 4.) On the Intel MIC, the loader refuses to retain static symbols in the libomp.so shared library, even though tools need them. The loader could not be bullied into doing so. To accommodate this, I changed the visibility of OMPT placeholder functions to public. This required additions in exports.so.txt, adding extern "C" scoping in ompt-general.c so that the public placeholder symbols won't be mangled. Patch by John Mellor-Crummey Differential Revision: http://reviews.llvm.org/D11062 llvm-svn: 242052
* Remove unused variable warnings by deletion.Jonathan Peyton2015-06-081-3/+1
| | | | | | | | | | As an ongoing effort to sanitize the openmp code, these changes delete variables that aren't used at all. http://lists.cs.uiuc.edu/pipermail/openmp-dev/2015-June/000701.html Patch by Jack Howarth llvm-svn: 239334
* Remove unused variable warnings by adding proper macro guards.Jonathan Peyton2015-06-081-0/+2
| | | | | | | | | As an ongoing effort to sanitize the openmp code, these changes remove unused variables by adding proper macros around both variables and functions. Patch by Jack Howarth llvm-svn: 239330
* Remove unused variable warnings by fooling compiler.Jonathan Peyton2015-06-081-1/+3
| | | | | | | | | | Some variables are convenient to keep around even if they aren't really used in a release build. This is often seen in DEBUG guarded code where the variable is only used in a DEBUG build. Patch by Jack Howarth llvm-svn: 239326
* Fix some sign compare warnings.Jonathan Peyton2015-06-041-5/+5
| | | | | | | | | This change changes kmp_bstate.old_tid to sign integer instead of unsigned integer. It also defines two new macros KMP_NSEC_PER_SEC and KMP_USEC_PER_SEC which lets us take control of the sign (we want them to be longs). Also, in kmp_wait_release.h, the byteref() function's return type is changed from char to unsigned char. llvm-svn: 239057
* Replace some unsafe API calls with safe alternatives on Windows, prepare ↵Andrey Churbanov2015-04-021-6/+6
| | | | | | code for similar actions on other platforms - wrap unsafe API calls into macros. llvm-svn: 233915
* fix for broken commit 231774Andrey Churbanov2015-03-101-143/+45
| | | | llvm-svn: 231781
* cleanup: removed unused function __kmp_change_thread_affinity_maskAndrey Churbanov2015-03-101-0/+49
| | | | llvm-svn: 231778
* cleanup: usages of mask size wrapped into macrosAndrey Churbanov2015-03-101-7/+7
| | | | llvm-svn: 231775
* Adding some 8-bit atomic operations for future useAndrey Churbanov2015-03-101-0/+51
| | | | llvm-svn: 231774
* Added new user-guided lock api, currently disabled. Use ↵Andrey Churbanov2015-02-201-0/+2
| | | | | | KMP_USE_DYNAMIC_LOCK=1 to enable it. llvm-svn: 230030
* Comments only: removing the Revision and Date svn variables from the top of ↵Andrey Churbanov2015-01-271-2/+0
| | | | | | all the source files. llvm-svn: 227207
* aarch64 port sent by C. BergstromAndrey Churbanov2015-01-131-6/+18
| | | | llvm-svn: 225792
* I apologise in advance for the size of this check-in. At Intel we doJim Cownie2014-10-071-85/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | understand that this is not friendly, and are working to change our internal code-development to make it easier to make development features available more frequently and in finer (more functional) chunks. Unfortunately we haven't got that in place yet, and unpicking this into multiple separate check-ins would be non-trivial, so please bear with me on this one. We should be better in the future. Apologies over, what do we have here? GGC 4.9 compatibility -------------------- * We have implemented the new entrypoints used by code compiled by GCC 4.9 to implement the same functionality in gcc 4.8. Therefore code compiled with gcc 4.9 that used to work will continue to do so. However, there are some other new entrypoints (associated with task cancellation) which are not implemented. Therefore user code compiled by gcc 4.9 that uses these new features will not link against the LLVM runtime. (It remains unclear how to handle those entrypoints, since the GCC interface has potentially unpleasant performance implications for join barriers even when cancellation is not used) --- new parallel entry points --- new entry points that aren't OpenMP 4.0 related These are implemented fully :- GOMP_parallel_loop_dynamic() GOMP_parallel_loop_guided() GOMP_parallel_loop_runtime() GOMP_parallel_loop_static() GOMP_parallel_sections() GOMP_parallel() --- cancellation entry points --- Currently, these only give a runtime error if OMP_CANCELLATION is true because our plain barriers don't check for cancellation while waiting GOMP_barrier_cancel() GOMP_cancel() GOMP_cancellation_point() GOMP_loop_end_cancel() GOMP_sections_end_cancel() --- taskgroup entry points --- These are implemented fully. GOMP_taskgroup_start() GOMP_taskgroup_end() --- target entry points --- These are empty (as they are in libgomp) GOMP_target() GOMP_target_data() GOMP_target_end_data() GOMP_target_update() GOMP_teams() Improvements in Barriers and Fork/Join -------------------------------------- * Barrier and fork/join code is now in its own file (which makes it easier to understand and modify). * Wait/release code is now templated and in its own file; suspend/resume code is also templated * There's a new, hierarchical, barrier, which exploits the cache-hierarchy of the Intel(r) Xeon Phi(tm) coprocessor to improve fork/join and barrier performance. ***BEWARE*** the new source files have *not* been added to the legacy Cmake build system. If you want to use that fixes wil be required. Statistics Collection Code -------------------------- * New code has been added to collect application statistics (if this is enabled at library compile time; by default it is not). The statistics code itself is generally useful, the lightweight timing code uses the X86 rdtsc instruction, so will require changes for other architectures. The intent of this code is not for users to tune their codes but rather 1) For timing code-paths inside the runtime 2) For gathering general properties of OpenMP codes to focus attention on which OpenMP features are most used. Nested Hot Teams ---------------- * The runtime now maintains more state to reduce the overhead of creating and destroying inner parallel teams. This improves the performance of code that repeatedly uses nested parallelism with the same resource allocation. Set the new KMP_HOT_TEAMS_MAX_LEVEL envirable to a depth to enable this (and, of course, OMP_NESTED=true to enable nested parallelism at all). Improved Intel(r) VTune(Tm) Amplifier support --------------------------------------------- * The runtime provides additional information to Vtune via the itt_notify interface to allow it to display better OpenMP specific analyses of load-imbalance. Support for OpenMP Composite Statements --------------------------------------- * Implement new entrypoints required by some of the OpenMP 4.1 composite statements. Improved ifdefs --------------- * More separation of concepts ("Does this platform do X?") from platforms ("Are we compiling for platform Y?"), which should simplify future porting. ScaleMP* contribution --------------------- Stack padding to improve the performance in their environment where cross-node coherency is managed at the page level. Redesign of wait and release code --------------------------------- The code is simplified and performance improved. Bug Fixes --------- *Fixes for Windows multiple processor groups. *Fix Fortran module build on Linux: offload attribute added. *Fix entry names for distribute-parallel-loop construct to be consistent with the compiler codegen. *Fix an inconsistent error message for KMP_PLACE_THREADS environment variable. llvm-svn: 219214
* Fix a bug where the library slept for up to KMP_BLOCKTIME before exitingJim Cownie2014-09-031-7/+37
| | | | llvm-svn: 217026
* Commit PowerPC64 support from Carlo Bertolli at IBM.Jim Cownie2014-08-071-13/+108
| | | | llvm-svn: 215093
* Make affinity support conditional on KMP_AFFINITY_SUPPORTEDAlp Toker2014-03-021-2/+2
| | | | | | | | | The feature was previously guarded with KMP_OS_LINUX || KMP_OS_WINDOWS but can now be enabled/disabled independently to simplify porting. Completes the work started in r202478. llvm-svn: 202613
* Add support for FreeBSDAlp Toker2014-02-281-22/+37
| | | | | | | | | | | | | | | Port the OpenMP runtime to FreeBSD along with associated build system changes. Also begin to generalize affinity capabilities so they aren't tied explicitly to Windows and Linux. The port builds with stock clang and gmake and has no additional runtime dependencies. All but a handful of the validation suite tests are now passing on FreeBSD 10 x86_64. llvm-svn: 202478
* Fix typosAlp Toker2014-02-241-2/+2
| | | | llvm-svn: 202018
* For your Christmas hacking pleasure.Jim Cownie2013-12-231-49/+61
| | | | | | | | | | | | | | | | | This release use aligns with Intel(r) Composer XE 2013 SP1 Product Update 2 New features * The library can now be built with clang (though wiht some limitations since clang does not support 128 bit floats) * Support for Vtune analysis of load imbalance * Code contribution from Steven Noonan to build the runtime for ARM* architecture processors * First implementation of runtime API for OpenMP cancellation Bug Fixes * Fixed hang on Windows (only) when using KMP_BLOCKTIME=0 llvm-svn: 197914
OpenPOWER on IntegriCloud