File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,28 @@ class LambdaGPUTask : public GPUTask {
2121 void doWork () {
2222 gpuCalculations (params);
2323 }
24+
25+ int calculationsCount (int localI, int groupSize, int wholeSize) {
26+ int startingIndex = localI * groupSize;
27+
28+ if (startingIndex < wholeSize - groupSize) // we are not close to an end of our data
29+ return groupSize;
30+
31+ int rest = wholeSize - startingIndex;
32+
33+ if (rest >= 0 ) // the last chunk of the data
34+ return rest;
35+
36+ return 0 ; // the data ended, nothing more to process
37+ }
2438
2539 private:
2640 T params;
2741 std::function<void (T)> gpuCalculations;
2842};
2943
44+ int calculationsCount (int localI, int groupSize, int wholeSize);
45+
3046class GPUTasksQueue {
3147 public:
3248 bool resetDeviceAfterFinish;
Original file line number Diff line number Diff line change 88
99using namespace std ;
1010
11+ int calculationsCount (int localI, int groupSize, int wholeSize) {
12+ int startingIndex = localI * groupSize;
13+
14+ if (startingIndex < wholeSize - groupSize) // we are not close to an end of our data
15+ return groupSize;
16+
17+ int rest = wholeSize - startingIndex;
18+
19+ if (rest >= 0 ) // the last chunk of the data
20+ return rest;
21+
22+ return 0 ; // the data ended, nothing more to process
23+ }
24+
1125GPUTask::~GPUTask () {
1226}
1327
You can’t perform that action at this time.
0 commit comments