| 16 | const int tries = 100; |
| 17 | |
| 18 | void TestBatchReduce(int batchSize, |
| 19 | const size_t partSize = 128 * 4 * 9, |
| 20 | bool compress = false) { |
| 21 | SetDefaultProfileMode(EProfileMode::ImplicitLabelSync); |
| 22 | TSetLogging inThisScope(ELoggingLevel::Debug); |
| 23 | auto& profiler = GetProfiler(); |
| 24 | |
| 25 | for (int tr = 0; tr < tries; ++tr) { |
| 26 | { |
| 27 | auto beforeReduceMapping = TStripeMapping::RepeatOnAllDevices(partSize); |
| 28 | auto afterReduceMapping = TStripeMapping::SplitBetweenDevices(partSize); |
| 29 | |
| 30 | TVector<TStripeBuffer<float>> data; |
| 31 | TVector<TComputationStream> streams; |
| 32 | for (int i = 0; i < batchSize; ++i) { |
| 33 | data.emplace_back(TStripeBuffer<float>::Create(beforeReduceMapping)); |
| 34 | FillBuffer(data.back(), 1.0f * i); |
| 35 | if (streams.size() < 100) { |
| 36 | streams.push_back(GetCudaManager().RequestStream()); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | { |
| 41 | TString label = compress ? "ReduceCompressed" : "Reduce"; |
| 42 | auto guard = profiler.Profile(label); |
| 43 | for (int i = 0; i < batchSize; ++i) { |
| 44 | auto& toReduce = data[i]; |
| 45 | TReducer<TStripeBuffer<float>> reducer(streams[i % 100].GetId()); |
| 46 | reducer(toReduce, afterReduceMapping, compress); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | { |
| 51 | auto beforeReduceMapping = TStripeMapping::RepeatOnAllDevices(batchSize * partSize); |
| 52 | auto afterReduceMapping = TStripeMapping::SplitBetweenDevices(batchSize * partSize); |
| 53 | |
| 54 | TStripeBuffer<float> data = TStripeBuffer<float>::Create(beforeReduceMapping); |
| 55 | { |
| 56 | TString label = compress ? "ReduceAllBatchCompressed" : "ReduceBatch"; |
| 57 | auto guard = profiler.Profile(label); |
| 58 | TReducer<TStripeBuffer<float>> reducer; |
| 59 | reducer(data, afterReduceMapping, compress); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | Y_UNIT_TEST(TestBatchReduce1) { |
| 66 | auto stopCudaManagerGuard = StartCudaManager(); |
no test coverage detected