QMCPACK
ScopedProfiler.h
Go to the documentation of this file.
1 #ifndef QMCPLUSPLUS_SCOPEDPROFILER_H
2 #define QMCPLUSPLUS_SCOPEDPROFILER_H
3 
4 #include "config.h"
5 #if defined(ENABLE_CUDA) && !defined(QMC_CUDA2HIP)
6 #include "CUDA/CUDAruntime.hpp"
7 #include <cuda_profiler_api.h>
8 #endif
9 #ifdef USE_VTUNE_API
10 #include <ittnotify.h>
11 #endif
12 
13 namespace qmcplusplus
14 {
15 
16 //non-nested
18 {
19 public:
20  ScopedProfiler(bool active) : active_(active)
21  {
22  if (active_)
23  {
24 #if defined(ENABLE_CUDA) && !defined(QMC_CUDA2HIP)
25  cudaErrorCheck(cudaProfilerStart(), "cudaProfilerStart failed!");
26 #endif
27 #ifdef USE_VTUNE_API
28  __itt_resume();
29 #endif
30  }
31  }
32 
34  {
35  if (active_)
36  {
37 #if defined(ENABLE_CUDA) && !defined(QMC_CUDA2HIP)
38  cudaErrorCheck(cudaProfilerStop(), "cudaProfilerStop failed!");
39 #endif
40 #ifdef USE_VTUNE_API
41  __itt_pause();
42 #endif
43  }
44  }
45 
46  bool isActive() const { return active_; }
47 private:
48  const bool active_;
49 };
50 }
51 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
handle CUDA/HIP runtime selection.
cudaErrorCheck(cudaMemcpyAsync(dev_lu.data(), lu.data(), sizeof(decltype(lu)::value_type) *lu.size(), cudaMemcpyHostToDevice, hstream), "cudaMemcpyAsync failed copying log_values to device")