123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #ifndef BOOST_COMPUTE_SVM_HPP
- #define BOOST_COMPUTE_SVM_HPP
- #include <boost/compute/config.hpp>
- #include <boost/compute/context.hpp>
- #include <boost/compute/memory/svm_ptr.hpp>
- #if defined(BOOST_COMPUTE_CL_VERSION_2_0) || defined(BOOST_COMPUTE_DOXYGEN_INVOKED)
- namespace boost {
- namespace compute {
- template<class T>
- inline svm_ptr<T> svm_alloc(const context &context,
- size_t size,
- cl_svm_mem_flags flags = CL_MEM_READ_WRITE,
- unsigned int alignment = 0)
- {
- svm_ptr<T> ptr(
- clSVMAlloc(context.get(), flags, size * sizeof(T), alignment),
- context
- );
- if(!ptr.get()){
- BOOST_THROW_EXCEPTION(opencl_error(CL_MEM_OBJECT_ALLOCATION_FAILURE));
- }
- return ptr;
- }
- template<class T>
- inline void svm_free(svm_ptr<T> ptr)
- {
- clSVMFree(ptr.get_context(), ptr.get());
- }
- template<class T>
- inline void svm_free(const context &context, svm_ptr<T> ptr)
- {
- clSVMFree(context.get(), ptr.get());
- }
- }
- }
- #endif
- #endif
|