Double the number of tasks given to ThreadPool
Previous implementation only enqueued "ThreadCount" tasks to ThreadPool. For more efficiency, this has been changed to "ThreadCount * 2" tasks.
This commit is contained in:
parent
388d48056f
commit
79748d58f1
1 changed files with 43 additions and 40 deletions
|
@ -731,13 +731,13 @@ namespace EC
|
|||
}
|
||||
else
|
||||
{
|
||||
std::array<TPFnDataStructZero, ThreadCount> fnDataAr;
|
||||
std::array<TPFnDataStructZero, ThreadCount * 2> fnDataAr;
|
||||
|
||||
std::size_t s = currentSize / ThreadCount;
|
||||
for(std::size_t i = 0; i < ThreadCount; ++i) {
|
||||
std::size_t s = currentSize / (ThreadCount * 2);
|
||||
for(std::size_t i = 0; i < ThreadCount * 2; ++i) {
|
||||
std::size_t begin = s * i;
|
||||
std::size_t end;
|
||||
if(i == ThreadCount - 1) {
|
||||
if(i == ThreadCount * 2 - 1) {
|
||||
end = currentSize;
|
||||
} else {
|
||||
end = s * (i + 1);
|
||||
|
@ -852,13 +852,13 @@ namespace EC
|
|||
}
|
||||
else
|
||||
{
|
||||
std::array<TPFnDataStructOne<Function>, ThreadCount> fnDataAr;
|
||||
std::array<TPFnDataStructOne<Function>, ThreadCount * 2> fnDataAr;
|
||||
|
||||
std::size_t s = currentSize / ThreadCount;
|
||||
for(std::size_t i = 0; i < ThreadCount; ++i) {
|
||||
std::size_t s = currentSize / (ThreadCount * 2);
|
||||
for(std::size_t i = 0; i < ThreadCount * 2; ++i) {
|
||||
std::size_t begin = s * i;
|
||||
std::size_t end;
|
||||
if(i == ThreadCount - 1) {
|
||||
if(i == ThreadCount * 2 - 1) {
|
||||
end = currentSize;
|
||||
} else {
|
||||
end = s * (i + 1);
|
||||
|
@ -1002,13 +1002,13 @@ namespace EC
|
|||
}
|
||||
else
|
||||
{
|
||||
std::array<TPFnDataStructTwo, ThreadCount> fnDataAr;
|
||||
std::array<TPFnDataStructTwo, ThreadCount * 2> fnDataAr;
|
||||
|
||||
std::size_t s = matching.size() / ThreadCount;
|
||||
for(std::size_t i = 0; i < ThreadCount; ++i) {
|
||||
std::size_t s = matching.size() / (ThreadCount * 2);
|
||||
for(std::size_t i = 0; i < ThreadCount * 2; ++i) {
|
||||
std::size_t begin = s * i;
|
||||
std::size_t end;
|
||||
if(i == ThreadCount - 1) {
|
||||
if(i == ThreadCount * 2 - 1) {
|
||||
end = matching.size();
|
||||
} else {
|
||||
end = s * (i + 1);
|
||||
|
@ -1075,14 +1075,14 @@ namespace EC
|
|||
}
|
||||
else
|
||||
{
|
||||
std::array<TPFnDataStructThree, ThreadCount> fnDataAr;
|
||||
std::array<TPFnDataStructThree, ThreadCount * 2> fnDataAr;
|
||||
|
||||
std::size_t s = currentSize / ThreadCount;
|
||||
std::size_t s = currentSize / (ThreadCount * 2);
|
||||
std::mutex mutex;
|
||||
for(std::size_t i = 0; i < ThreadCount; ++i) {
|
||||
for(std::size_t i = 0; i < ThreadCount * 2; ++i) {
|
||||
std::size_t begin = s * i;
|
||||
std::size_t end;
|
||||
if(i == ThreadCount - 1) {
|
||||
if(i == ThreadCount * 2 - 1) {
|
||||
end = currentSize;
|
||||
} else {
|
||||
end = s * (i + 1);
|
||||
|
@ -1452,14 +1452,14 @@ namespace EC
|
|||
}
|
||||
else
|
||||
{
|
||||
std::array<TPFnDataStructFour, ThreadCount> fnDataAr;
|
||||
std::array<TPFnDataStructFour, ThreadCount * 2> fnDataAr;
|
||||
|
||||
std::mutex mutex;
|
||||
std::size_t s = currentSize / ThreadCount;
|
||||
for(std::size_t i = 0; i < ThreadCount; ++i) {
|
||||
std::size_t s = currentSize / (ThreadCount * 2);
|
||||
for(std::size_t i = 0; i < ThreadCount * 2; ++i) {
|
||||
std::size_t begin = s * i;
|
||||
std::size_t end;
|
||||
if(i == ThreadCount - 1) {
|
||||
if(i == ThreadCount * 2 - 1) {
|
||||
end = currentSize;
|
||||
} else {
|
||||
end = s * (i + 1);
|
||||
|
@ -1522,13 +1522,14 @@ namespace EC
|
|||
}
|
||||
}
|
||||
} else {
|
||||
std::array<TPFnDataStructFive, ThreadCount> fnDataAr;
|
||||
std::array<TPFnDataStructFive, ThreadCount * 2>
|
||||
fnDataAr;
|
||||
std::size_t s = multiMatchingEntities[index].size()
|
||||
/ ThreadCount;
|
||||
for(unsigned int i = 0; i < ThreadCount; ++i) {
|
||||
/ (ThreadCount * 2);
|
||||
for(unsigned int i = 0; i < ThreadCount * 2; ++i) {
|
||||
std::size_t begin = s * i;
|
||||
std::size_t end;
|
||||
if(i == ThreadCount - 1) {
|
||||
if(i == ThreadCount * 2 - 1) {
|
||||
end = multiMatchingEntities[index].size();
|
||||
} else {
|
||||
end = s * (i + 1);
|
||||
|
@ -1660,14 +1661,14 @@ namespace EC
|
|||
}
|
||||
else
|
||||
{
|
||||
std::array<TPFnDataStructSix, ThreadCount> fnDataAr;
|
||||
std::array<TPFnDataStructSix, ThreadCount * 2> fnDataAr;
|
||||
|
||||
std::mutex mutex;
|
||||
std::size_t s = currentSize / ThreadCount;
|
||||
for(std::size_t i = 0; i < ThreadCount; ++i) {
|
||||
std::size_t s = currentSize / (ThreadCount * 2);
|
||||
for(std::size_t i = 0; i < ThreadCount * 2; ++i) {
|
||||
std::size_t begin = s * i;
|
||||
std::size_t end;
|
||||
if(i == ThreadCount - 1) {
|
||||
if(i == ThreadCount * 2 - 1) {
|
||||
end = currentSize;
|
||||
} else {
|
||||
end = s * (i + 1);
|
||||
|
@ -1735,13 +1736,14 @@ namespace EC
|
|||
}
|
||||
else
|
||||
{
|
||||
std::array<TPFnDataStructFive, ThreadCount> fnDataAr;
|
||||
std::array<TPFnDataStructFive, ThreadCount * 2>
|
||||
fnDataAr;
|
||||
std::size_t s = multiMatchingEntities[index].size()
|
||||
/ ThreadCount;
|
||||
for(unsigned int i = 0; i < ThreadCount; ++i) {
|
||||
/ (ThreadCount * 2);
|
||||
for(unsigned int i = 0; i < ThreadCount * 2; ++i) {
|
||||
std::size_t begin = s * i;
|
||||
std::size_t end;
|
||||
if(i == ThreadCount - 1) {
|
||||
if(i == ThreadCount * 2 - 1) {
|
||||
end = multiMatchingEntities[index].size();
|
||||
} else {
|
||||
end = s * (i + 1);
|
||||
|
@ -1821,13 +1823,13 @@ namespace EC
|
|||
}
|
||||
}
|
||||
} else {
|
||||
std::array<TPFnDataStructZero, ThreadCount> fnDataAr;
|
||||
std::array<TPFnDataStructZero, ThreadCount * 2> fnDataAr;
|
||||
|
||||
std::size_t s = currentSize / ThreadCount;
|
||||
for(std::size_t i = 0; i < ThreadCount; ++i) {
|
||||
std::size_t s = currentSize / (ThreadCount * 2);
|
||||
for(std::size_t i = 0; i < ThreadCount * 2; ++i) {
|
||||
std::size_t begin = s * i;
|
||||
std::size_t end;
|
||||
if(i == ThreadCount - 1) {
|
||||
if(i == ThreadCount * 2 - 1) {
|
||||
end = currentSize;
|
||||
} else {
|
||||
end = s * (i + 1);
|
||||
|
@ -1906,13 +1908,14 @@ namespace EC
|
|||
fn(i, this, userData);
|
||||
}
|
||||
} else {
|
||||
std::array<TPFnDataStructSeven<Iterable>, ThreadCount> fnDataAr;
|
||||
std::array<TPFnDataStructSeven<Iterable>, ThreadCount * 2>
|
||||
fnDataAr;
|
||||
|
||||
std::size_t s = currentSize / ThreadCount;
|
||||
for(std::size_t i = 0; i < ThreadCount; ++i) {
|
||||
std::size_t s = currentSize / (ThreadCount * 2);
|
||||
for(std::size_t i = 0; i < ThreadCount * 2; ++i) {
|
||||
std::size_t begin = s * i;
|
||||
std::size_t end;
|
||||
if(i == ThreadCount - 1) {
|
||||
if(i == ThreadCount * 2 - 1) {
|
||||
end = currentSize;
|
||||
} else {
|
||||
end = s * (i + 1);
|
||||
|
|
Loading…
Reference in a new issue