Skip to content

Commit

Permalink
Use main thread as last thread (#65)
Browse files Browse the repository at this point in the history
* Use main thread as last thread

* Move threadFlag, reuse j variable
  • Loading branch information
MasterCarl committed Jun 22, 2018
1 parent 9c77bee commit a1c8ab4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion benchmark/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,21 @@ void benchmark(size_t colSize, int colCount, int threadCount, int iterations, bo
clearCache();
}

for (int j = 0; j < threadCount; j++) {
for (int j = 0; j < threadCount - 1; j++) {
size_t endIndex = startIndex + partLength + (j < overhang ? 1 : 0);
auto threadInstance = new thread(threadFunc<T>, ref(attributeVector), colCount, startIndex,
endIndex, j);
threads.push_back(threadInstance);
startIndex = endIndex;
}


// run threadFunc on main thread
int j = threadCount - 1;
size_t endIndex = startIndex + partLength + (j < overhang ? 1 : 0);

threadFlag = true;
threadFunc<T>(ref(attributeVector), colCount, startIndex, endIndex, j);

for (thread *thread: threads) {
(*thread).join();
Expand Down

0 comments on commit a1c8ab4

Please sign in to comment.