DPC++ Runtime
Runtime libraries for oneAPI DPC++
common_win_pi_trace.hpp
Go to the documentation of this file.
1 //==------------ common_win_pi_trace.hpp - SYCL standard header file -------==//
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 // this .hpp is injected. Be sure to define __SYCL_PLUGIN_DLL_NAME before
10 // including
11 #ifdef _WIN32
12 #include <windows.h>
13 BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module
14  DWORD fdwReason, // reason for calling function
15  LPVOID lpReserved) { // reserved
16 
17  bool PrintPiTrace = false;
18  static const char *PiTrace = std::getenv("SYCL_PI_TRACE");
19  static const int PiTraceValue = PiTrace ? std::stoi(PiTrace) : 0;
20  if (PiTraceValue == -1 || PiTraceValue == 2) { // Means print all PI traces
21  PrintPiTrace = true;
22  }
23 
24  // Perform actions based on the reason for calling.
25  switch (fdwReason) {
26  case DLL_PROCESS_DETACH:
27  if (PrintPiTrace)
28  std::cout << "---> DLL_PROCESS_DETACH " << __SYCL_PLUGIN_DLL_NAME << "\n"
29  << std::endl;
30 
31  break;
32  case DLL_PROCESS_ATTACH:
33  if (PrintPiTrace)
34  std::cout << "---> DLL_PROCESS_ATTACH " << __SYCL_PLUGIN_DLL_NAME << "\n"
35  << std::endl;
36  break;
37  case DLL_THREAD_ATTACH:
38  break;
39  case DLL_THREAD_DETACH:
40  break;
41  }
42  return TRUE;
43 }
44 #endif // WIN32
__SYCL_EXTERN_STREAM_ATTRS ostream cout
Linked to standard output.