42 #include <pvsutil/Assert.h>
47 #include "SkelCL/detail/Program.h"
55 detail::MapHelper<void(Index)>(createAndBuildProgram(source, funcName))
60 Map<void(Index)>::createAndBuildProgram(
const std::string& source,
61 const std::string& funcName)
const
63 ASSERT_MESSAGE(!source.empty(),
64 "Tried to create program with empty user source.");
68 std::string s(detail::CommonDefinitions::getSource());
78 __kernel void SCL_MAP(const unsigned int SCL_ELEMENTS,
79 const unsigned int SCL_OFFSET)
81 if (get_global_id(0) < SCL_ELEMENTS) {
82 SCL_FUNC(get_global_id(0)+SCL_OFFSET);
86 auto program = detail::Program(s, detail::util::hash(s));
89 if (!program.loadBinary()) {
91 program.transferParameters(funcName, 1,
"SCL_MAP");
92 program.transferArguments(funcName, 1,
"SCL_FUNC");
94 program.renameFunction(funcName,
"SCL_FUNC");
106 detail::MapHelper<void(IndexPoint)>(createAndBuildProgram(source, funcName))
110 detail::Program Map<void(IndexPoint)>::createAndBuildProgram(
111 const std::string& source,
const std::string& funcName)
const
113 ASSERT_MESSAGE(!source.empty(),
114 "Tried to create program with empty user source.");
118 std::string s(detail::CommonDefinitions::getSource());
131 __kernel void SCL_MAP(const unsigned int SCL_COL_COUNT,
132 const unsigned int SCL_ROW_COUNT,
133 const unsigned int SCL_ROW_OFFSET)
135 if ( get_global_id(1) < SCL_COL_COUNT && get_global_id(0) < SCL_ROW_COUNT ) {
136 // dim 1 is the columns, dim 0 the rows
138 p.x = get_global_id(1);
139 p.y = get_global_id(0) + SCL_ROW_OFFSET;
144 auto program = detail::Program(s, detail::util::hash(s));
147 if (!program.loadBinary()) {
149 program.transferParameters(funcName, 1,
"SCL_MAP");
150 program.transferArguments(funcName, 1,
"SCL_FUNC");
152 program.renameFunction(funcName,
"SCL_FUNC");
This class is a unified wrapper for defining source code in SkelCL.
Map(const Source &source, const std::string &funcName=std::string("func"))
Constructor taking the source code used of the user-defined function as argument. ...
Map(const Source &source, const std::string &funcName=std::string("func"))
Constructor taking the source code used of the user-defined function as argument. ...