summaryrefslogtreecommitdiffstats
path: root/openmp/libomptarget/src/omptarget.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [LIBOMPTARGET] Do not increment/decrement the refcount for "declare target" ↵George Rokos2020-01-141-3/+3
| | | | | | | | 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
* [OpenMP][libomptarget] Add support for close map modifierGheorghe-Teodor Bercea2019-08-091-5/+13
| | | | | | | | | | | | | | | | | | | 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-091-5/+5
| | | | | | | | | | | | | | | 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-071-30/+52
| | | | | | | | | | | | | | | | | | | 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] 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]Rename loopTripCnt member data to LoopTripCnt, NFC.Alexey Bataev2019-07-081-2/+2
| | | | | | Rename variable to follow LLVM coding standard. llvm-svn: 365368
* [OPENMP]Make __kmpc_push_tripcount thread safe.Alexey Bataev2019-07-081-2/+6
| | | | | | | | | | | | | | | | | | | | | | 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
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | 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
* [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-061-1/+0
| | | | | | Follow-up to r340542 and r340767. llvm-svn: 341563
* [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-271-17/+0
| | | | | | | | | | | | | | | | 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-231-57/+85
| | | | | | | | | | | | | | | | | | 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-191-26/+92
| | | | | | | | | | | | | | | 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
* [libomptarget] Split implementation of interface functionsJonas Hahnfeld2017-12-061-484/+7
| | | | | | | | | | | | 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-061-297/+0
| | | | | | | | | | 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-061-321/+0
| | | | | | | | | | 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-061-629/+11
| | | | | | | | | | | 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
* [Clang][OpenMP] New clang/libomptarget map interface: new function ↵George Rokos2017-11-211-36/+36
| | | | | | | | | | | 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-101-31/+43
| | | | | | | | | | | 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-221-14/+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
* [libomptarget] Fix compilation with libc++Jonas Hahnfeld2017-01-271-1/+1
| | | | | | | | iterator is only guaranteed to be default-constructible, without any argument. Differential Revision: https://reviews.llvm.org/D29171 llvm-svn: 293277
* [OpenMP] Initial implementation of OpenMP offloading library - libomptarget.George Rokos2017-01-251-0/+2323
This is the patch upstreaming the device-agnostic part of libomptarget. Differential Revision: https://reviews.llvm.org/D14031 llvm-svn: 293094
OpenPOWER on IntegriCloud