ddemidov / vexcl
1
#define BOOST_TEST_MODULE Eval
2
#include <boost/test/unit_test.hpp>
3
#include <vexcl/vector.hpp>
4
#include <vexcl/element_index.hpp>
5
#include <vexcl/function.hpp>
6
#include <vexcl/vector_view.hpp>
7
#include <vexcl/eval.hpp>
8
#include "context_setup.hpp"
9

10 6
BOOST_AUTO_TEST_CASE(eval_atomic) {
11 6
    const size_t M = 16;
12
    const size_t C = 64;
13
    const size_t N = M * C;
14

15 6
    std::vector<vex::command_queue> q(1, ctx.queue(0));
16

17 6
    vex::vector<int> x(q, N);
18 6
    vex::vector<int> y(q, M);
19

20 6
    y = 0;
21 6
    x = vex::element_index() % M;
22

23 6
    vex::eval(atomic_add(&vex::permutation(x)(y), 1));
24 6
    check_sample(y, [=](size_t, int v) { BOOST_CHECK_EQUAL(v, C); });
25

26 6
    vex::eval(atomic_sub(&vex::permutation(x)(y), 1));
27 6
    check_sample(y, [=](size_t, int v) { BOOST_CHECK_EQUAL(v, 0); });
28
}
29

30 6
BOOST_AUTO_TEST_SUITE_END()

Read our documentation on viewing source code .

Loading