Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:05

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_USER_EVENT_HPP
0012 #define BOOST_COMPUTE_USER_EVENT_HPP
0013 
0014 #include <boost/compute/event.hpp>
0015 #include <boost/compute/context.hpp>
0016 
0017 namespace boost {
0018 namespace compute {
0019 
0020 #if defined(BOOST_COMPUTE_CL_VERSION_1_1) || defined(BOOST_COMPUTE_DOXYGEN_INVOKED)
0021 /// \class user_event
0022 /// \brief An user-created event.
0023 ///
0024 /// \opencl_version_warning{1,1}
0025 ///
0026 /// \see event
0027 class user_event : public event
0028 {
0029 public:
0030     /// Creates a new user-event object.
0031     ///
0032     /// \see_opencl_ref{clCreateUserEvent}
0033     explicit user_event(const context &context)
0034     {
0035         cl_int error;
0036         m_event = clCreateUserEvent(context.get(), &error);
0037         if(!m_event){
0038             BOOST_THROW_EXCEPTION(opencl_error(error));
0039         }
0040     }
0041 
0042     /// Creates a new user-event from \p other.
0043     user_event(const user_event &other)
0044         : event(other)
0045     {
0046     }
0047 
0048     /// Copies the user-event from \p other to \c *this.
0049     user_event& operator=(const user_event &other)
0050     {
0051         event::operator=(other);
0052 
0053         return *this;
0054     }
0055 
0056     #ifndef BOOST_COMPUTE_NO_RVALUE_REFERENCES
0057     /// Move-constructs a new user event object from \p other.
0058     user_event(user_event&& other) BOOST_NOEXCEPT
0059         : event(std::move(other))
0060     {
0061     }
0062 
0063     /// Move-assigns the user event from \p other to \c *this.
0064     user_event& operator=(user_event&& other) BOOST_NOEXCEPT
0065     {
0066         event::operator=(std::move(other));
0067 
0068         return *this;
0069     }
0070     #endif // BOOST_COMPUTE_NO_RVALUE_REFERENCES
0071 
0072     /// Sets the execution status for the user-event.
0073     ///
0074     /// \see_opencl_ref{clSetUserEventStatus}
0075     void set_status(cl_int execution_status)
0076     {
0077         cl_int ret = clSetUserEventStatus(m_event, execution_status);
0078         if(ret != CL_SUCCESS){
0079             BOOST_THROW_EXCEPTION(opencl_error(ret));
0080         }
0081     }
0082 };
0083 #endif // BOOST_COMPUTE_CL_VERSION_1_1
0084 
0085 } // end compute namespace
0086 } // end boost namespace
0087 
0088 #endif // BOOST_COMPUTE_EVENT_HPP