コード例 #1
0
ファイル: cl_tests.hpp プロジェクト: hapoo/hpxcl
static void print_testdevice_info(hpx::opencl::device & cldevice,
                                  std::size_t device_id,
                                  std::size_t num_devices){

    // Test whether get_device_info works
    std::string version = cldevice.get_device_info<CL_DEVICE_VERSION>().get();

    // Test whether version is a valid OpenCL version string
    std::string versionstring = std::string("OpenCL ");
    HPX_TEST(0 == version.compare(0, versionstring.length(), versionstring));

    // Write Info Code
    hpx::cout << "Device ID:  " << device_id << " / " << num_devices
                                << hpx::endl;
    hpx::cout << "Device GID: " << cldevice.get_gid() << hpx::endl;
    hpx::cout << "Version:    " << version << hpx::endl;
    hpx::cout << "Name:       " << cldevice.get_device_info<CL_DEVICE_NAME>().get()
                                << hpx::endl;
    hpx::cout << "Vendor:     " << cldevice.get_device_info<CL_DEVICE_VENDOR>().get()
                                << hpx::endl;
    hpx::cout << "Profile:    " << cldevice.get_device_info<CL_DEVICE_PROFILE>().get()
                                << hpx::endl;

    // Test for valid device client
    HPX_TEST(cldevice.get_gid());


}
コード例 #2
0
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);


}
コード例 #3
0
ファイル: dynamic_overloads.cpp プロジェクト: hapoo/hpxcl
static void cl_test( hpx::opencl::device local_device, 
                     hpx::opencl::device cldevice ){

    hpx::opencl::lcos::event<void> event(cldevice.get_gid());
    register_event(cldevice, event.get_event_id());

    hpx::shared_future<void> sfut = event.get_future();
    std::vector<hpx::shared_future<void>> vsfut1;
    vsfut1.push_back( sfut );
    std::vector<hpx::shared_future<void>> vsfut2;
    vsfut2.push_back( sfut );
    vsfut2.push_back( sfut );

    test_client t;

    HPX_TEST_EQ( 5300, t.func(5, 3                               ).get() );
    HPX_TEST_EQ( 5301, t.func(5, 3, sfut                         ).get() );
    HPX_TEST_EQ( 5302, t.func(5, 3, sfut, sfut                   ).get() );
    HPX_TEST_EQ( 5301, t.func(5, 3, vsfut1                       ).get() );
    HPX_TEST_EQ( 5302, t.func(5, 3, vsfut2                       ).get() );
    HPX_TEST_EQ( 5302, t.func(5, 3, vsfut1, vsfut1               ).get() );
    HPX_TEST_EQ( 5303, t.func(5, 3, vsfut1, vsfut2               ).get() );
    HPX_TEST_EQ( 5303, t.func(5, 3, vsfut2, vsfut1               ).get() );
    HPX_TEST_EQ( 5304, t.func(5, 3, vsfut2, vsfut2               ).get() );
    HPX_TEST_EQ( 5304, t.func(5, 3, sfut, sfut, vsfut2           ).get() );
    HPX_TEST_EQ( 5304, t.func(5, 3, sfut, vsfut2, sfut           ).get() );
    HPX_TEST_EQ( 5304, t.func(5, 3, vsfut2, sfut, sfut           ).get() );
    HPX_TEST_EQ( 5305, t.func(5, 3, sfut, vsfut2, vsfut2         ).get() );
    HPX_TEST_EQ( 5305, t.func(5, 3, vsfut2, sfut, vsfut2         ).get() );
    HPX_TEST_EQ( 5305, t.func(5, 3, vsfut2, vsfut2, sfut         ).get() );


};
コード例 #4
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);

    // 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);


}
コード例 #5
0
ファイル: kernel.cpp プロジェクト: josephwinston/hpxcl
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);

}
コード例 #6
0
ファイル: register_event.hpp プロジェクト: hapoo/hpxcl
static void register_event(hpx::opencl::device cldevice,
                           const hpx::naming::id_type & event_id)
{

    boost::shared_ptr<hpx::opencl::server::device>
    parent_device = hpx::get_ptr<hpx::opencl::server::device>
                        (cldevice.get_gid()).get();

    // create a fake event
    cl_int err;
    cl_event event_cl = clCreateUserEvent (
            parent_device->get_context(),
            &err);
    cl_ensure(err, "clEnqueueWriteBuffer()");
    err = clSetUserEventStatus(event_cl, CL_COMPLETE);
    cl_ensure(err, "clSetUserEventStatus()");

    parent_device->register_event(event_id, event_cl);
}