summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/bohrium/cxxadd.cpp
blob: 94c9287807d02432948a8c273a8cbbcda6de6d0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bhxx/bhxx.hpp>

int main() {
    const size_t dim = 3;
    bhxx::BhArray<double> a({dim});
    bhxx::BhArray<double> b({dim});
    bhxx::BhArray<double> c({dim});

    bhxx::identity(a, 1);
    bhxx::identity(b, 2);
    bhxx::add(c, a, b);

    bhxx::Runtime::instance().sync(c.base);
    bhxx::Runtime::instance().flush();

    for (auto it = c.data(); it < c.data() + dim; ++it) {
        if (*it != 3) {
            std::cout << "Failure, values not as expected." << std::endl;
            return 1;
        }
    }
    std::cout << "Success!" << std::endl;
    return 0;
}