| 58 | } |
| 59 | |
| 60 | TEST(Threading, SimultaneousRead) { |
| 61 | setDevice(0); |
| 62 | |
| 63 | array A = constant(1.0, 100, 100); |
| 64 | array B = constant(1.0, 100, 100); |
| 65 | |
| 66 | vector<std::thread> tests; |
| 67 | |
| 68 | int thread_count = 8; |
| 69 | int iteration_count = 30; |
| 70 | for (int t = 0; t < thread_count; ++t) { |
| 71 | ArithOp op; |
| 72 | float outValue; |
| 73 | |
| 74 | switch (t % 4) { |
| 75 | case 0: |
| 76 | op = ADD; |
| 77 | outValue = 2.0f; |
| 78 | break; |
| 79 | case 1: |
| 80 | op = SUB; |
| 81 | outValue = 0.0f; |
| 82 | break; |
| 83 | case 2: |
| 84 | op = DIV; |
| 85 | outValue = 1.0f; |
| 86 | break; |
| 87 | case 3: |
| 88 | op = MUL; |
| 89 | outValue = 1.0f; |
| 90 | break; |
| 91 | } |
| 92 | |
| 93 | tests.emplace_back(calc, op, A, B, outValue, iteration_count); |
| 94 | } |
| 95 | |
| 96 | for (int t = 0; t < thread_count; ++t) |
| 97 | if (tests[t].joinable()) tests[t].join(); |
| 98 | } |
| 99 | |
| 100 | std::condition_variable cv; |
| 101 | std::mutex cvMutex; |
no test coverage detected