This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define VEXCL_SHOW_KERNELS | |
#define USE_PERMUTATION | |
#include <vexcl/vexcl.hpp> | |
int main() { | |
vex::Context ctx(vex::Filter::Count(1)); | |
const size_t n = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: cpp-bindings vexcl vexcl-custom-kernel | |
cpp-bindings: cpp-bindings.cpp | |
g++ -o $@ $^ -std=c++11 -lOpenCL | |
vexcl: vexcl.cpp | |
g++ -o $@ $^ -std=c++11 -I/home/demidov/work/vexcl -lOpenCL -lboost_system | |
vexcl-custom-kernel: vexcl-custom-kernel.cpp | |
g++ -o $@ $^ -std=c++11 -I/home/demidov/work/vexcl -lOpenCL -lboost_system |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Вариант с использованием Kronos C++ bindings. | |
* Если файл CL/cl.hpp не входит в OpenCL SDK, его можно взять тут: | |
* http://www.khronos.org/registry/cl/api/1.1/cl.hpp | |
* | |
* Преимущество перед C-API: | |
* не нужно вручную отслеживать время жизни объектов OpenCL. | |
*/ | |
#include <iostream> | |
#include <vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cube: cube.cpp | |
g++ -o $@ $^ -std=c++11 -O3 \ | |
-I$(HOME)/work/vexcl -I$(HOME)/work/amgcl \ | |
-lOpenCL -lboost_system |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lorenz: lorenz.cpp | |
g++ -o $@ $^ -std=c++11 -O3 \ | |
-I${HOME}/work/odeint-v2 \ | |
-I${HOME}/work/opencl/compute/include/ \ | |
-lOpenCL -lboost_system -lboost_timer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vexcl/vexcl.hpp> | |
vex::vector<cl_float2> | |
hilbert(vex::vector<float> &in, std::size_t rows, std::size_t cols) { | |
// No need to pass context in: | |
const auto &ctx = in.queue_list(); | |
// Use function instead of vector. Should save global memory IO. | |
VEX_FUNCTION(h, float(size_t/*prm1 = idx*/, size_t/*prm2 = rows*/), | |
VEX_STRINGIZE_SOURCE( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <stdexcept> | |
#define __CL_ENABLE_EXCEPTIONS | |
#include <CL/cl.hpp> | |
//--------------------------------------------------------------------------- | |
void precondition(bool cond, const std::string &msg) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vexcl/vexcl.hpp> | |
vex::vector<cl_float2> | |
hilbert(vex::vector<float> &in, std::size_t rows, std::size_t cols) { | |
// No need to pass context in: | |
const auto &ctx = in.queue_list(); | |
// Use function instead of vector. Should save global memory IO. | |
VEX_FUNCTION(h, float(size_t/*prm1 = idx*/, size_t/*prm2 = rows*/), | |
VEX_STRINGIZE_SOURCE( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <algorithm> | |
#include <cstdlib> | |
#include <vexcl/vexcl.hpp> | |
typedef cl_uint val_type; | |
int main() { | |
const size_t n = 1024; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vexcl/vexcl.hpp> | |
typedef int val_type; | |
typedef vex::cl_vector_of<val_type, 2>::type Tuple; | |
struct less { | |
typedef bool result_type; | |
VEX_FUNCTION(device, bool(Tuple, Tuple), | |
"return (prm1.x == prm2.x) ? (prm1.y < prm2.y) : (prm1.x < prm2.x);" |