Blame c++/contourgl/cudacontext.h

383633
/*
383633
    ......... 2018 Ivan Mahonin
383633
383633
    This program is free software: you can redistribute it and/or modify
383633
    it under the terms of the GNU General Public License as published by
383633
    the Free Software Foundation, either version 3 of the License, or
383633
    (at your option) any later version.
383633
383633
    This program is distributed in the hope that it will be useful,
383633
    but WITHOUT ANY WARRANTY; without even the implied warranty of
383633
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
383633
    GNU General Public License for more details.
383633
383633
    You should have received a copy of the GNU General Public License
383633
    along with this program.  If not, see <http: licenses="" www.gnu.org="">.</http:>
383633
*/
383633
383633
#ifndef _CUDACONTEXT_H_
383633
#define _CUDACONTEXT_H_
383633
383633
#include <vector></vector>
383633
383633
#include <cuda.h></cuda.h>
383633
383633
383633
class CudaParams {
383633
private:
383633
	std::vector<char> params_buffer;</char>
383633
	std::vector<int> params_offsets;</int>
383633
	std::vector<void*> params_pointers;</void*>
383633
	std::vector<void*> params_extra;</void*>
383633
	size_t params_buffer_size;
383633
383633
public:
383633
	CudaParams();
383633
383633
	void reset();
383633
383633
	CudaParams& add(const void* data, int size, int align);
383633
383633
	template<typename t=""></typename>
383633
	CudaParams& add(const T &data, int align)
383633
		{ return add(&data, sizeof(data), align); }
383633
383633
	template<typename t=""></typename>
383633
	CudaParams& add(const T &data)
383633
		{ return add(data, __alignof(T)); }
383633
383633
	void** get_params() const
383633
		{ return params_pointers.empty() ? NULL : &(const_cast<cudaparams*>(this)->params_pointers.front()); }</cudaparams*>
383633
	void** get_extra() const
383633
		{ return params_extra.empty() ? NULL : &(const_cast<cudaparams*>(this)->params_extra.front()); }</cudaparams*>
383633
};
383633
383633
383633
class CudaContext {
383633
public:
383633
	CUdevice device;
383633
	CUcontext context;
383633
	CUresult err;
383633
383633
	CudaContext();
383633
	~CudaContext();
383633
383633
	void hello();
383633
};
383633
383633
#endif