Ejemplo n.º 1
0
int main()
{

  { // by sticking all the SYCL work in a {} block, we ensure
    // all SYCL tasks must complete before exiting the block

    // create a queue to work on
    cl::sycl::queue myQueue;

    // create some ‘commands’ for our ‘queue’
    myQueue.submit([&](cl::sycl::handler &cgh)
    {
      // request access to our buffer
      cl::sycl::accessor<int, 1, cl::sycl::access::write, cl::sycl::access::global_buffer>
        writeResult = { resultBuf, cgh };
cgh.single_task(FunctionObject(writeResult));
//////// End left side of the slide

//////// Start right side of the slide
cgh.single_task<class simple_test>([=] ()
                                   {
                                     writeResult [0] = 1234;
                                   }
                                   );
//////// End right side of the slide
    }); // end of our commands for this queue

  } // end scope, so we wait for the queue to complete

  printf("Result = %d\n", result);
}
Ejemplo n.º 2
0
        MenuItem(const std::string& name, const std::string& desc, MenuFlow fl = FLOW_FORWARD,
                 FunctionType f_type = FUNCTION_NONE, std::size_t* init_val = nullptr, std::size_t set_val = 0,
                 Menu* submenu = nullptr, Item* item_ptr = nullptr) {
            switch (f_type) {
            case FUNCTION_INTEGRAL:
                functionobject = FunctionObject(init_val,set_val);
                break;
            default:
                functionobject = FunctionObject(item_ptr);
            }

            repr_strings[0] = name;
            repr_strings[1] = desc;
            flow = fl;
            nextmenu = submenu;
        }
Ejemplo n.º 3
0
void test_FunctionObject(AllocType& alloc)
{
    assert(globalMemCounter.checkOutstandingNewEq(0));
    {
    // Construct function from FunctionObject.
    std::function<FuncType> f = FunctionObject();
    assert(FunctionObject::count == 1);
    assert(globalMemCounter.checkOutstandingNewEq(1));
    assert(f.template target<FunctionObject>());
    assert(f.template target<FuncType>() == 0);
    assert(f.template target<FuncType*>() == 0);
    // Copy function with allocator
    std::function<FuncType> f2(std::allocator_arg, alloc, f);
    assert(FunctionObject::count == 2);
    assert(globalMemCounter.checkOutstandingNewEq(2));
    assert(f2.template target<FunctionObject>());
    assert(f2.template target<FuncType>() == 0);
    assert(f2.template target<FuncType*>() == 0);
    }
    assert(FunctionObject::count == 0);
    assert(globalMemCounter.checkOutstandingNewEq(0));
}