MCPcopy Create free account
hub / github.com/boostorg/compute / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

test/test_program_cache.cpp:21–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19namespace compute = boost::compute;
20
21BOOST_AUTO_TEST_CASE(setup)
22{
23 // get default context
24 compute::context ctx = context;
25
26 // get program cache
27 boost::shared_ptr<compute::program_cache> cache =
28 compute::program_cache::get_global_cache(ctx);
29
30 // try to load a null string
31 BOOST_CHECK(cache->get(std::string()) == boost::none);
32
33 // try to load a non-existant program
34 BOOST_CHECK(cache->get("nonexistant") == boost::none);
35
36 // create and store a program
37 const char p1_source[] =
38 "__kernel void add(__global int *a, int x)\n"
39 "{\n"
40 " a[get_global_id(0)] += x;\n"
41 "}\n";
42 compute::program p1 =
43 compute::program::create_with_source(p1_source, ctx);
44 p1.build();
45 cache->insert("p1", p1);
46
47 // try to load the program
48 BOOST_CHECK(cache->get("p1") == p1);
49
50 // create a copy of the context
51 compute::context ctx_copy = ctx;
52
53 // check that they both have the same cl_context
54 BOOST_CHECK(ctx_copy.get() == ctx.get());
55
56 // check that the cache is the same
57 boost::shared_ptr<compute::program_cache> cache_copy =
58 compute::program_cache::get_global_cache(ctx_copy);
59 BOOST_CHECK(cache_copy == cache);
60
61 // try to load the program again
62 BOOST_CHECK(cache_copy->get("p1") == p1);
63}
64
65BOOST_AUTO_TEST_CASE(evict)
66{

Callers

nothing calls this directly

Calls 5

programClass · 0.85
buildMethod · 0.80
getMethod · 0.45
insertMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected