summaryrefslogtreecommitdiffstats
path: root/openmp/libomptarget/src
Commit message (Collapse)AuthorAgeFilesLines
* [LIBOMPTARGET] Do not increment/decrement the refcount for "declare target" ↵George Rokos2020-01-143-43/+63
| | | | | | | | objects The reference counter for global objects marked with declare target is INF. This patch prevents the runtime from incrementing /decrementing INF refcounts. Without it, the map(delete: global_object) directive actually deallocates the global on the device. With this patch, such a directive becomes a no-op. Differential Revision: https://reviews.llvm.org/D72525
* [LIBOMPTARGET]Ignore empty target descriptors.Alexey Bataev2020-01-101-0/+4
| | | | | | | | | | | | | | | | | | Summary: If the dynamically loaded module has been compiled with -fopenmp-targets and has no target regions, it has empty target descriptor. It leads to a crash at the runtime if another module has at least one target region and at least one entry in its descriptor. The runtime library is unable to load the empty binary descriptor and terminates the execution. Caused by a clang-offload-wrapper. Reviewers: grokos, jdoerfert Subscribers: caomhin, kkwli0, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D72472
* [OpenMP] NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-071-1/+1
| | | | | | | | | | | | Reviewers: jdoerfert, Jim Reviewed By: Jim Subscribers: Jim, mgorny, guansong, jfb, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D72285
* [OpenMP][libomptarget] Add support for close map modifierGheorghe-Teodor Bercea2019-08-093-15/+26
| | | | | | | | | | | | | | | | | | | Summary: This patch adds support for the close map modifier. The close map modifier will overwrite the unified shared memory requirement and create a device copy of the data. Reviewers: ABataev, Hahnfeld, caomhin, grokos, jdoerfert, AlexEichenberger Reviewed By: Hahnfeld, AlexEichenberger Subscribers: guansong, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D65340 llvm-svn: 368488
* [libomptarget] Remove duplicate RTLRequiresFlags per deviceJonas Hahnfeld2019-08-095-21/+14
| | | | | | | | | | | | | | | We have one global RTLs.RequiresFlags, I don't see a need to make a copy per device that the runtime manages. This was problematic anyway because the copy happened during the first __tgt_register_lib(). This made it impossible to call __tgt_register_requires() from normal user funtions for testing. Hence, this change also fixes unified_shared_memory/shared_update.c for older versions of Clang that don't call __tgt_register_requires() before __tgt_register_lib(). Differential Revision: https://reviews.llvm.org/D66019 llvm-svn: 368465
* [OpenMP][libomptarget] Add support for unified memory for regular mapsGheorghe-Teodor Bercea2019-08-074-46/+104
| | | | | | | | | | | | | | | | | | | Summary: This patch adds support for using unified memory in the case of regular maps that happen when a target region is offloaded to the device. For cases where only a single version of the data is required then the host address can be used. When variables need to be privatized in any way or globalized, then the copy to the device is still required for correctness. Reviewers: ABataev, jdoerfert, Hahnfeld, AlexEichenberger, caomhin, grokos Reviewed By: Hahnfeld Subscribers: mgorny, guansong, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D65001 llvm-svn: 368192
* [OpenMP 5.0] libomptarget interface for declare mapper functions.Michael Kruse2019-08-043-0/+42
| | | | | | | | | | | | | | | | | | This patch implements the libomptarget runtime interface for OpenMP 5.0 declare mapper functions. The declare mapper functions generated by Clang will call them to complete the mapping of members. kmpc_mapper_num_components gets the current number of components for a user-defined mapper; kmpc_push_mapper_component pushes back one component for a user-defined mapper. The design slides can be found at https://github.com/lingda-li/public-sharing/blob/master/mapper_runtime_design.pptx Patch by Lingda Li <lildmh@gmail.com> Differential Revision: https://reviews.llvm.org/D60972 llvm-svn: 367772
* [libomptarget] Handle offload policy in push_tripcountJonas Hahnfeld2019-07-231-0/+3
| | | | | | | | | | | | | | | If the first target region in a program calls the push_tripcount function, libomptarget didn't handle the offload policy correctly. This could lead to unexpected error messages as seen in http://lists.llvm.org/pipermail/openmp-dev/2019-June/002561.html To solve this, add a check calling IsOffloadDisabled() as all other entry points already do. If this method returns false, libomptarget is effectively disabled. Differential Revision: https://reviews.llvm.org/D64626 llvm-svn: 366810
* [OPENMP] Resolve lost LoopTripCnt for subsequent loops in same thread.Ron Lieberman2019-07-171-2/+5
| | | | | | | | | | Remove loopTripCnt from threaded device stack after consuming it. Added a libomptarget DP message to aid in future debugging and to validate the added testcase, which only runs in Debug build. Differential Revision: https://reviews.llvm.org/D64808 llvm-svn: 366349
* [OPENMP]Fix threadid in __kmpc_omp_taskwait call for dependent target calls.Alexey Bataev2019-07-161-5/+5
| | | | | | | | | | | | | | | | | Summary: We used to call __kmpc_omp_taskwait function with global threadid set to 0. It may crash the application at the runtime if the thread executing target region is not a master thread. Reviewers: grokos, kkwli0 Subscribers: guansong, jdoerfert, caomhin, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D64571 llvm-svn: 366220
* [libomptarget] Fix typos and grammar in error messages, NFC.Jonas Hahnfeld2019-07-121-4/+4
| | | | llvm-svn: 365890
* [OPENMP]Rename loopTripCnt member data to LoopTripCnt, NFC.Alexey Bataev2019-07-083-6/+6
| | | | | | Rename variable to follow LLVM coding standard. llvm-svn: 365368
* [OPENMP]Make __kmpc_push_tripcount thread safe.Alexey Bataev2019-07-084-7/+15
| | | | | | | | | | | | | | | | | | | | | | Summary: __kmpc_push_tripcount function is not thread safe and may lead to data race when the target regions are executed in parallel threads. The patch makes loopTripCnt counter thread aware and stores the tripcount value per thread in the map. Access to map is guarded by mutex to prevent data race in the map itself. Test is for NVPTX target because it does not work correctly on the host. Seems to me, there is a problem in libomp with target regions in the parallel threads. Reviewers: grokos Subscribers: guansong, jfb, jdoerfert, openmp-commits, kkwli0, caomhin Tags: #openmp Differential Revision: https://reviews.llvm.org/D64080 llvm-svn: 365332
* [OpenMP][libomptarget] Enable usage of unified memory for declare target ↵Gheorghe-Teodor Bercea2019-06-043-2/+12
| | | | | | | | | | | | | | | | | | link variables Summary: This patch enables the usage of a host variable on the device for declare target link variables when unified memory is available. Reviewers: ABataev, caomhin, grokos Reviewed By: grokos Subscribers: Hahnfeld, guansong, jdoerfert, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D60884 llvm-svn: 362505
* [OpenMP][libomptarget] Enable requires flags for target libraries.Gheorghe-Teodor Bercea2019-05-216-4/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Target link variables are currently implemented by creating a copy of the variables on the device side and unified memory never gets exploited. When the prgram uses the: ``` #pragma omp requires unified_shared_memory ``` directive in conjunction with a declare target link, the linked variable is no longer allocated on the device and the host version is used instead. This behavior is overridden by performing an explicit mapping. A Clang side patch is required. Reviewers: ABataev, AlexEichenberger, grokos, Hahnfeld Reviewed By: AlexEichenberger, grokos, Hahnfeld Subscribers: Hahnfeld, jfb, guansong, jdoerfert, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D60223 llvm-svn: 361294
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-199-36/+27
| | | | | | | | | | | | | | | | | | 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. llvm-svn: 351648
* [libomptarget] Added install component for libomptargetVyacheslav Zakharin2019-01-021-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D56108 llvm-svn: 350254
* [OPENMP]Make lambda mapping follow reqs for PTR_AND_OBJ mapping.Alexey Bataev2018-11-081-5/+6
| | | | | | | | | | | | | | | Summary: The base pointer for the lambda mapping must point to the lambda capture placement and pointer must point to the captured variable itself. Patch fixes this problem. Reviewers: gtbercea Subscribers: guansong, openmp-commits, kkwli0, caomhin Differential Revision: https://reviews.llvm.org/D54260 llvm-svn: 346407
* [OPENMP][OFFLOADING]Change the lambda capturing flags.Alexey Bataev2018-11-021-1/+1
| | | | | | | | | | | | | | | Summary: The previously used combination `PTR_AND_OBJ | PRIVATE` could be used for mapping of some data in Fortran. Changed it to `PTR_AND_OBJ | LITERAL`. Reviewers: gtbercea Subscribers: guansong, caomhin, openmp-commits Differential Revision: https://reviews.llvm.org/D54035 llvm-svn: 345981
* [LIBOMPTARGET] Add support for mapping of lambda captures.Alexey Bataev2018-10-301-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Added support for correct mapping of variables captured by reference in lambdas. That kind of mapping may appear only in target-executable regions and must follow the original lambda or another lambda capture for the same lambda. The expected data: base address - the address of the lambda, begin pointer - pointer to the address of the lambda capture, size - size of the captured variable. When OMP_TGT_MAPTYPE_PTR_AND_OBJ mapping type is seen in target-executable region, the target address of the last processed item is taken as the address of the original lambda `tgt_lambda_ptr`. Then, the pointer to capture on the device is calculated like `tgt_lambda_ptr + (host_begin_pointer - host_begin_base)` and the target-based address of the original variable (which host address is `*(void**)begin_pointer`) is written to that pointer. Reviewers: kkwli0, gtbercea, grokos Subscribers: openmp-commits Differential Revision: https://reviews.llvm.org/D51107 llvm-svn: 345608
* [OPENMP]Increment iterator when the loop is continued.Alexey Bataev2018-09-111-1/+3
| | | | | | | | | | | | | | Summary: Missed operation of the incrementing iterator when required just to continue execution. Reviewers: kkwli0, gtbercea, grokos Subscribers: guansong, openmp-commits Differential Revision: https://reviews.llvm.org/D51937 llvm-svn: 341964
* [libomptarget] Remove two unneeded includes, NFCI.Jonas Hahnfeld2018-09-062-2/+0
| | | | | | Follow-up to r340542 and r340767. llvm-svn: 341563
* [libomptarget] Remove `Devices` from `RTLInfoTy`Sergey Dmitriev2018-09-042-6/+1
| | | | | | | | This patch removes unused field `Devices` from `RTLInfoTy`. Differential Revision: https://reviews.llvm.org/D51653 llvm-svn: 341399
* [libomptarget] PR38704: Fix erase of ShadowPtrMapJonas Hahnfeld2018-09-041-2/+4
| | | | | | | | | | | | | erase() invalidates the iterator and returns a new one pointing to the following element. The code now follows the example at https://en.cppreference.com/w/cpp/container/map/erase. (The added testcase crashes without this patch.) Reported by David Binderman (https://llvm.org/PR38704)! Differential Revision: https://reviews.llvm.org/D51623 llvm-svn: 341371
* [OpenMP][libomptarget] rework of fatal error reportingAlexandre Eichenberger2018-08-273-23/+21
| | | | | | | | | | | | | | | | Summary: Removed the function that used a lock and varargs Used the same mechanism as for debug messages Reviewers: ABataev, gtbercea, grokos, Hahnfeld Reviewed By: gtbercea, Hahnfeld Subscribers: mikerice, ABataev, RaviNarayanaswamy, guansong, openmp-commits Differential Revision: https://reviews.llvm.org/D51226 llvm-svn: 340767
* [OpenMP][libomptarget] Bringing up to spec with respect to ↵Alexandre Eichenberger2018-08-234-66/+174
| | | | | | | | | | | | | | | | | | OMP_TARGET_OFFLOAD env var Summary: Right now, only the OMP_TARGET_OFFLOAD=DISABLED was implemented. Added support for the other MANDATORY and DEFAULT values. Reviewers: gtbercea, ABataev, grokos, caomhin, Hahnfeld Reviewed By: Hahnfeld Subscribers: protze.joachim, gtbercea, AlexEichenberger, RaviNarayanaswamy, Hahnfeld, guansong, openmp-commits Differential Revision: https://reviews.llvm.org/D50522 llvm-svn: 340542
* [OpenMP][libomptarget] New map interface: remove translation code and ensure ↵George Rokos2018-07-192-329/+144
| | | | | | | | | | | | | | | proper alignment of struct members This patch removes the translation code since this functionality is now implemented in the compiler. target_data_begin and target_data_end are also patched to handle some special cases that used to be handled by the obsolete translation function, namely ensure proper alignment of struct members when we have partially mapped structs. Mapping a struct from a higher address (i.e. not from its beginning) can result in distortion of the alignment for some of its member fields. Padding restores the original (proper) alignment. Differential revision: https://reviews.llvm.org/D44186 llvm-svn: 337455
* [CMake] Unify install path for librariesJonas Hahnfeld2018-05-251-1/+1
| | | | | | | | | | Introduce OPENMP_INSTALL_LIBDIR and use in all install() commands. This also fixes installation of libomptarget-nvptx that previously didn't honor {OPENMP,LLVM}_LIBDIR_SUFFIX. Differential Revision: https://reviews.llvm.org/D47130 llvm-svn: 333284
* Bugfix, extern declarations for libomp functions are `extern "C"` declarationsGeorge Rokos2018-03-171-0/+6
| | | | llvm-svn: 327763
* Moved extern declarations to private header file, they are only used from ↵George Rokos2018-03-161-0/+4
| | | | | | within libomptarget, they don't need to be in omptarget.h. llvm-svn: 327740
* Sprinkle a few <cstdlib> includes, for libomptarget sources usingDimitry Andric2018-01-183-0/+3
| | | | | | malloc, free, alloca and getenv. NFCI. llvm-svn: 322869
* Add missing headers for Debug buildsJonas Hahnfeld2018-01-182-0/+2
| | | | llvm-svn: 322830
* [libomptarget] Split implementation of interface functionsJonas Hahnfeld2017-12-064-484/+520
| | | | | | | | | | | | This last of four patches adds a new file for the interface functions that Clang uses during code generation. The only change except simply moving the current code is renaming the function CheckDeviceAndCtors() and using the correct type for 64bit device ids. Differential Revision: https://reviews.llvm.org/D40801 llvm-svn: 319972
* [libomptarget] Split implementation of API functionsJonas Hahnfeld2017-12-065-297/+316
| | | | | | | | | | This third patch moves the implementation of the user-facing OpenMP API functions into its own file. For now, the code is only moved, no cleanups applied yet. Differential Revision: https://reviews.llvm.org/D40800 llvm-svn: 319971
* [libomptarget] Split device functionalityJonas Hahnfeld2017-12-064-321/+339
| | | | | | | | | | This is the second patch to split the current monolithic implementation into separate files. Note that this change doesn't cleanup the code yet. Differential Revision: https://reviews.llvm.org/D40799 llvm-svn: 319970
* [libomptarget] Split RTL plugin functionalityJonas Hahnfeld2017-12-066-629/+742
| | | | | | | | | | | This is the first of four patches to split the target agnostic library into multiple (smaller) files. It only moves the code to separate implementation files and does no cleanup (yet) except removing unneeded headers. Differential Revision: https://reviews.llvm.org/D40798 llvm-svn: 319969
* [libomptarget] Move header files and CMake library definitionJonas Hahnfeld2017-12-064-329/+55
| | | | | | | | | | | | | | Future patches will add (private) header files in src/ that should not be visible to plugins, so move the "public" ones to a new include/ directory. This is still internal in a sense that the contained files won't be installed for the user. Similarly, the target agnostic offloading library should be built directly in src/. The parent directory is responsible for finding dependencies and including all subdirectories. Differential Revision: https://reviews.llvm.org/D40797 llvm-svn: 319968
* [Clang][OpenMP] New clang/libomptarget map interface: new function ↵George Rokos2017-11-212-57/+57
| | | | | | | | | | | signatures, libomptarget-side This is the libomptarget-side patch which changes the __tgt_* API function signatures in preparation for the new map interface. Changes are: Device IDs 32bits --> 64bits, Flags 32bits --> 64bits Differential revision: https://reviews.llvm.org/D40313 llvm-svn: 318790
* Revert "Rename fields of ompt_frame_t"Jonas Hahnfeld2017-11-031-3/+0
| | | | | | This reverts commit r317338 which discarded some recent commits. llvm-svn: 317347
* Rename fields of ompt_frame_tJoachim Protze2017-11-031-0/+3
| | | | | | | | | | This is part of the renaming of data types from OpenMP TR4 to TR6 Patch by Simon Convent Differential Revision: https://reviews.llvm.org/D39326 llvm-svn: 317338
* [libomptarget] Remove stale omp handleJonas Hahnfeld2017-11-021-3/+0
| | | | | | | | | This was never used in the upstream compiler and was responsible for some problems with reductions in the clang-ykt fork. Differential Revision: https://reviews.llvm.org/D39553 llvm-svn: 317214
* [OpenMP] libomptarget: move debugging dumps under control of env var ↵Sergey Dmitriev2017-08-141-1/+19
| | | | | | | | | | | | | | | LIBOMPTARGET_DEBUG Disable default debugging dumps for libomptarget and plugins and move dumps under control of environment variable LIBOMPTARGET_DEBUG=<integer>. Dumps are enabled when LIBOMPTARGET_DEBUG is set to a positive integer value. Debugging dumps are available only in debug build; release build does not support it. Differential Revision: https://reviews.llvm.org/D33227 llvm-svn: 310841
* [OpenMP] Prevent unused-variable warning in libomptarget when compiling in ↵Samuel Antao2017-06-091-0/+4
| | | | | | Release mode. llvm-svn: 305090
* [OpenMP] libomptarget: eliminate compiler warnings at buildGeorge Rokos2017-06-021-10/+10
| | | | | | | | Thanks to Sergey Dmitriev for submitting the patch. Differential Revision: https://reviews.llvm.org/D33851 llvm-svn: 304601
* [OpenMP] Changes in the plugin interfaceGeorge Rokos2017-05-103-31/+136
| | | | | | | | | | | This patch chagnes the plugin interface so that: 1) future plugins can take advantage of systems with shared CPU/device storage 2) instead of using base addresses, target regions are launched by providing target addresseds and base offsets explicitly. Differential revision: https://reviews.llvm.org/D33028 llvm-svn: 302663
* [OpenMP] libomptarget: Set ref count for global objects to positive infinityGeorge Rokos2017-04-221-5/+15
| | | | | | Differential Revision: https://reviews.llvm.org/D32326 llvm-svn: 301076
* [OpenMP] libomptarget: Remove obsolete negative device IDs -2/-3George Rokos2017-04-222-16/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D32325 llvm-svn: 301075
* [OpenMP] Allow multiple weak symbols to be loaded from the fat binaryGeorge Rokos2017-03-221-10/+9
| | | | | | | | For compatibility with Fortran. Differential Revision: https://reviews.llvm.org/D31205 llvm-svn: 298516
* Add AArch64 support.Paul Osmialowski2017-03-061-1/+2
| | | | | | | | This adds AArch64 support to recently added part of the runtime responsible for offloading to target. This piece of code allows offloading-to-self on AArch64 machines. Differential Revision: https://reviews.llvm.org/D30644 llvm-svn: 297070
* [OpenMP] libomptarget: Protect parent struct from being deallocatedGeorge Rokos2017-02-151-8/+19
| | | | | | | | Fixed bug due to which a parent struct was deallocated when one of the struct's pointers was being unmapped. Differential Revision: https://reviews.llvm.org/D29914 llvm-svn: 295231
OpenPOWER on IntegriCloud