ddemidov / vexcl
1
#define BOOST_TEST_MODULE VexContext
2
#include <boost/test/unit_test.hpp>
3
#include <vexcl/devlist.hpp>
4
#include <vexcl/vector.hpp>
5

6
void local_context() {
7
#if defined(VEXCL_BACKEND_OPENCL) || defined(VEXCL_BACKEND_COMPUTE)
8 4
    vex::Context ctx( vex::Filter::Exclusive( vex::Filter::Env ) );
9
#else
10 2
    vex::Context ctx( vex::Filter::Env );
11
#endif
12 6
    std::cout << ctx << std::endl;
13

14 6
    BOOST_CHECK( !ctx.empty() );
15

16
    const size_t n = 1024;
17

18 6
    vex::vector<int> x(ctx, n);
19 6
    x = 0;
20

21 6
    BOOST_CHECK(x.size() == n);
22 6
    BOOST_CHECK(x[0] == 0);
23
}
24

25 6
BOOST_AUTO_TEST_CASE(create_destroy)
26
{
27
    // This should work on NVIDIA GPUs with exclusive compute mode.
28 6
    local_context();
29 6
    local_context();
30
}

Read our documentation on viewing source code .

Loading