static void cl_test( hpx::opencl::device local_device,
                     hpx::opencl::device remote_device )
{

    hpx::opencl::buffer buffer =
        remote_device.create_buffer(CL_MEM_READ_WRITE, DATASIZE);
    hpx::opencl::buffer buffer2 =
        remote_device.create_buffer(CL_MEM_READ_WRITE, DATASIZE);

    hpx::opencl::buffer remote_buffer =
        local_device.create_buffer(CL_MEM_READ_WRITE, DATASIZE);

    // test if buffer initialization worked
    size_t buffer_size = buffer.size().get();
    HPX_TEST_EQ(buffer_size, DATASIZE);

    // test if buffer can be written to
    test_write(props01, moddata, refdata01);
    test_write(props02, moddata, refdata02);
    test_write(props03, moddata, refdata03);
    test_write(props04, moddata, refdata04);
    test_write(props05, moddata2, refdata05);


}
static void cl_test(hpx::opencl::device cldevice)
{

    hpx::opencl::buffer buffer = cldevice.create_buffer(CL_MEM_READ_WRITE,
                                                              DATASIZE,
                                                              initdata);

    // test if buffer initialization worked
    size_t buffer_size = buffer.size().get();
    HPX_TEST_EQ(buffer_size, DATASIZE);

    // read and compare
    TEST_CL_BUFFER(buffer, initdata);

    // write to buffer
    hpx::lcos::future<hpx::opencl::event> write_event = 
                        buffer.enqueue_write(3, 2, modifydata);

    // change modifydata to test wether write caches internally 
//    modifydata[1] = '.';

    // wait for write to finish
    write_event.get().await();

    // read and compare
    TEST_CL_BUFFER(buffer, refdata1);
    
    // test offsetted read
    boost::shared_ptr<std::vector<char>> out = 
                               buffer.enqueue_read(6, 5).get().get_data().get();
    HPX_TEST_EQ(std::string(refdata2), std::string(out->begin(), out->end()));

    
    
    // Create second buffer
    hpx::opencl::buffer buffer2 = cldevice.create_buffer(CL_MEM_READ_WRITE,
                                                               DATASIZE,
                                                               initdata);

    // Buffer copy test
    buffer2.enqueue_copy(buffer, 2, 8, 3).get().await();

    // read and compare
    TEST_CL_BUFFER(buffer2, refdata3);


}
Beispiel #3
0
static void cl_test(hpx::opencl::device cldevice)
{

    hpx::opencl::buffer buffer = cldevice.create_buffer(CL_MEM_READ_WRITE,
                                                              DATASIZE,
                                                              initdata);

    // test if buffer initialization worked
    size_t buffer_size = buffer.size().get();
    HPX_TEST_EQ(buffer_size, DATASIZE);

    // read and compare
    TEST_CL_BUFFER(buffer, initdata);

    // create program
    hpx::opencl::program prog = cldevice.create_program_with_source(
                                                                    square_src);

    // build program
    prog.build();

    // create kernel
    hpx::opencl::kernel square_kernel = prog.create_kernel("square");

    // set kernel arg
    square_kernel.set_arg(0, buffer);

    // create work_size
    hpx::opencl::work_size<1> dim;
    dim[0].offset = 3;
    dim[0].size = 5;

    // run kernel
    square_kernel.enqueue(dim).get().await();

    // test if kernel executed successfully
    TEST_CL_BUFFER(buffer, refdata1);

}