HCC
HCC is a single-source, C/C++ compiler for heterogeneous computing. It's optimized with HSA (http://www.hsafoundation.com/).
kalmar_cpu_launch.h
1 //===----------------------------------------------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 
8 #pragma once
9 
10 #include "hc_defines.h"
11 #include "kalmar_runtime.h"
12 #include "kalmar_serialize.h"
13 
14 namespace Kalmar {
15 template <int D0, int D1=0, int D2=0> class tiled_extent;
16 
17 #if __KALMAR_ACCELERATOR__ == 2 || __KALMAR_CPU__ == 2
18 static const unsigned int NTHREAD = std::thread::hardware_concurrency();
19 
20 template <typename Kernel>
21 class CPUKernelRAII
22 {
23  const std::shared_ptr<Kalmar::KalmarQueue> pQueue;
24  const Kernel& f;
25  std::vector<std::thread> th;
26 public:
27  CPUKernelRAII(const std::shared_ptr<Kalmar::KalmarQueue> pQueue, const Kernel& f)
28  : pQueue(pQueue), f(f), th(NTHREAD) {
29  CPUVisitor vis(pQueue);
30  Serialize s(&vis);
31  f.__cxxamp_serialize(s);
32  CLAMP::enter_kernel();
33  }
34  std::thread& operator[](int i) { return th[i]; }
35  ~CPUKernelRAII() {
36  for (auto& t : th)
37  if (t.joinable())
38  t.join();
39  CPUVisitor vis(pQueue);
40  Serialize ss(&vis);
41  f.__cxxamp_serialize(ss);
42  CLAMP::leave_kernel();
43  }
44 };
45 
46 #endif
47 
48 }
namespace for internal classes of Kalmar compiler / runtime
Definition: hc.hpp:42
Definition: kalmar_cpu_launch.h:15