SkelCL
SkelCL is a high level multi GPU skeleton library developed at the university of Münster, Germany.
 All Classes Namespaces Files Functions Variables Typedefs Groups
Event.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2011-2012 The SkelCL Team as listed in CREDITS.txt *
3  * http://skelcl.uni-muenster.de *
4  * *
5  * This file is part of SkelCL. *
6  * SkelCL is available under multiple licenses. *
7  * The different licenses are subject to terms and condition as provided *
8  * in the files specifying the license. See "LICENSE.txt" for details *
9  * *
10  *****************************************************************************
11  * *
12  * SkelCL is free software: you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation, either version 3 of the License, or *
15  * (at your option) any later version. See "LICENSE-gpl.txt" for details. *
16  * *
17  * SkelCL is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  *****************************************************************************
23  * *
24  * For non-commercial academic use see the license specified in the file *
25  * "LICENSE-academic.txt". *
26  * *
27  *****************************************************************************
28  * *
29  * If you are interested in other licensing models, including a commercial- *
30  * license, please contact the author at michel.steuwer@uni-muenster.de *
31  * *
32  *****************************************************************************/
33 
39 
40 #include <algorithm>
41 #include <functional>
42 #include <initializer_list>
43 #include <vector>
44 
45 #define __CL_ENABLE_EXCEPTIONS
46 #include <CL/cl.hpp>
47 #undef __CL_ENABLE_EXCEPTIONS
48 
49 #include <pvsutil/Logger.h>
50 
51 #include "SkelCL/detail/Event.h"
52 
53 namespace skelcl {
54 
55 namespace detail {
56 
57 
58 Event::Event()
59  : _events()
60 {
61 }
62 
63 Event::Event(const std::vector<cl::Event>& events)
64  : _events(events)
65 {
66 }
67 
68 Event::Event(std::initializer_list<cl::Event> events)
69  : _events(events.begin(), events.end())
70 {
71 }
72 
73 Event::Event(Event&& rhs)
74  : _events(std::move(rhs._events))
75 {
76 }
77 
78 Event& Event::operator=(Event&& rhs)
79 {
80  _events = std::move(rhs._events);
81  return *this;
82 }
83 
84 void Event::insert(const cl::Event& event)
85 {
86  _events.push_back(event);
87 }
88 
89 void Event::wait()
90 {
91  try {
92  // Wait for every single device, because of different context objects
93  std::for_each( _events.begin(), _events.end(),
94  std::mem_fn(&cl::Event::wait) );
95  } catch (cl::Error& err) {
96  ABORT_WITH_ERROR(err);
97  }
98 }
99 
100 } // namespace detail
101 
102 } // namespace skelcl