MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / calc

Function calc

test/threading.cpp:40–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38enum ArithOp { ADD, SUB, DIV, MUL };
39
40void calc(ArithOp opcode, array op1, array op2, float outValue,
41 int iteration_count) {
42 setDevice(0);
43 array res;
44 for (int i = 0; i < iteration_count; ++i) {
45 switch (opcode) {
46 case ADD: res = op1 + op2; break;
47 case SUB: res = op1 - op2; break;
48 case DIV: res = op1 / op2; break;
49 case MUL: res = op1 * op2; break;
50 }
51 }
52
53 vector<float> out(res.elements());
54 res.host((void*)out.data());
55
56 for (unsigned i = 0; i < out.size(); ++i) ASSERT_FLOAT_EQ(out[i], outValue);
57 af::sync();
58}
59
60TEST(Threading, SimultaneousRead) {
61 setDevice(0);

Callers

nothing calls this directly

Calls 4

hostMethod · 0.80
setDeviceFunction · 0.50
syncFunction · 0.50
elementsMethod · 0.45

Tested by

no test coverage detected