1 | //===----------- rtl.cpp - Target independent OpenMP target RTL -----------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // Initialization and tear down of the offload runtime. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "OpenMP/OMPT/Callback.h" |
14 | #include "PluginManager.h" |
15 | |
16 | #include "Shared/Debug.h" |
17 | #include "Shared/Profile.h" |
18 | |
19 | #ifdef OMPT_SUPPORT |
20 | extern void llvm::omp::target::ompt::connectLibrary(); |
21 | #endif |
22 | |
23 | __attribute__((constructor(101))) void init() { |
24 | Profiler::get(); |
25 | TIMESCOPE(); |
26 | |
27 | DP("Init offload library!\n" ); |
28 | |
29 | PM = new PluginManager(); |
30 | |
31 | #ifdef OMPT_SUPPORT |
32 | // Initialize OMPT first |
33 | llvm::omp::target::ompt::connectLibrary(); |
34 | #endif |
35 | |
36 | PM->init(); |
37 | |
38 | PM->registerDelayedLibraries(); |
39 | } |
40 | |
41 | __attribute__((destructor(101))) void deinit() { |
42 | DP("Deinit offload library!\n" ); |
43 | delete PM; |
44 | } |
45 | |