Files
triton/lib/driver/buffer.cpp
Philippe Tillet e7cabf65ac Tuning: Merged tune branch.
- Much cleaner and more concise source
- Better exceptions handling
- Checks local minima to see if retuning is needed.

Resolved conflicts:
	bench/blas.cpp
	include/isaac/backend/templates/mproduct.h
	include/isaac/driver/buffer.h
	lib/array.cpp
	lib/backend/templates/mproduct.cpp
	lib/driver/buffer.cpp
	python/setup.py
	tune/pysrc/autotune.py
	tune/pysrc/dataset.py
	tune/pysrc/misc_tools.py
2015-06-28 17:53:16 -07:00

53 lines
1.0 KiB
C++

#include "isaac/driver/buffer.h"
#include <iostream>
namespace isaac
{
namespace driver
{
Buffer::Buffer(cl::Buffer const & buffer) : backend_(OPENCL), context_(buffer.getInfo<CL_MEM_CONTEXT>()), h_(backend_)
{
*h_.cl = buffer;
}
Buffer::Buffer(Context const & context, std::size_t size) : backend_(context.backend_), context_(context), h_(backend_)
{
switch(backend_)
{
#ifdef ISAAC_WITH_CUDA
case CUDA:
cuda::check(cuMemAlloc(h_.cu.get(), size));
break;
#endif
case OPENCL:
cl_int err;
*h_.cl = cl::Buffer(*context.h_.cl, CL_MEM_READ_WRITE, size, NULL, &err);
ocl::check(err);
break;
default:
throw;
}
}
Context const & Buffer::context() const
{ return context_; }
bool Buffer::operator==(Buffer const & other) const
{ return h_==other.h_; }
bool Buffer::operator<(Buffer const & other) const
{ return h_<other.h_; }
HANDLE_TYPE(cl::Buffer, CUdeviceptr) & Buffer::handle()
{ return h_; }
HANDLE_TYPE(cl::Buffer, CUdeviceptr) const & Buffer::handle() const
{ return h_; }
}
}