]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/include/boost/compute/experimental/malloc.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / experimental / malloc.hpp
CommitLineData
7c673cae
FG
1//---------------------------------------------------------------------------//
2// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3//
4// Distributed under the Boost Software License, Version 1.0
5// See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt
7//
8// See http://boostorg.github.com/compute for more information.
9//---------------------------------------------------------------------------//
10
11#ifndef BOOST_COMPUTE_EXPERIMENTAL_MALLOC_HPP
12#define BOOST_COMPUTE_EXPERIMENTAL_MALLOC_HPP
13
14#include <boost/compute/buffer.hpp>
15#include <boost/compute/system.hpp>
16#include <boost/compute/context.hpp>
17#include <boost/compute/detail/device_ptr.hpp>
18
19namespace boost {
20namespace compute {
21namespace experimental {
22
23// bring device_ptr into the experimental namespace
24using detail::device_ptr;
25
26template<class T>
27inline device_ptr<T>
28malloc(std::size_t size, const context &context = system::default_context())
29{
30 buffer buf(context, size * sizeof(T));
31 clRetainMemObject(buf.get());
32 return device_ptr<T>(buf);
33}
34
35inline device_ptr<char>
36malloc(std::size_t size, const context &context = system::default_context())
37{
38 return malloc<char>(size, context);
39}
40
41template<class T>
42inline void free(device_ptr<T> &ptr)
43{
44 clReleaseMemObject(ptr.get_buffer().get());
45}
46
47} // end experimental namespace
48} // end compute namespace
49} // end boost namespace
50
51#endif // BOOST_COMPUTE_EXPERIMENTAL_MALLOC_HPP