thesis version
This commit is contained in:
23
plot/executor/firstlevelequi.cpp
Normal file
23
plot/executor/firstlevelequi.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "firstlevelequi.h"
|
||||
|
||||
Split firstLevelEqui(std::size_t n, CoresList const& coresList) {
|
||||
Split split;
|
||||
|
||||
auto firstLevelPar = n;
|
||||
|
||||
split.insert(0);
|
||||
for(auto const& k: coresList) {
|
||||
std::size_t start{};
|
||||
std::size_t const step = firstLevelPar/k;
|
||||
std::size_t remain = firstLevelPar - step*k;
|
||||
|
||||
for(unsigned int i = 0; i < k-1; ++i) {
|
||||
std::size_t offset = !!remain;
|
||||
remain -= offset;
|
||||
start += step+offset;
|
||||
split.insert(start * (n/firstLevelPar));
|
||||
}
|
||||
}
|
||||
|
||||
return split;
|
||||
}
|
8
plot/executor/firstlevelequi.h
Normal file
8
plot/executor/firstlevelequi.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef ALSK_PLOT_EXECUTOR_FIRSTLEVELEQUI_H
|
||||
#define ALSK_PLOT_EXECUTOR_FIRSTLEVELEQUI_H
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
Split firstLevelEqui(std::size_t n, CoresList const& coresList);
|
||||
|
||||
#endif
|
19
plot/executor/firstlevelgreedy.cpp
Normal file
19
plot/executor/firstlevelgreedy.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "firstlevelgreedy.h"
|
||||
|
||||
Split firstLevelGreedy(std::size_t n, CoresList const& coresList) {
|
||||
Split split;
|
||||
|
||||
auto firstLevelPar = n;
|
||||
|
||||
split.insert(0);
|
||||
for(auto const& k: coresList) {
|
||||
std::size_t start{};
|
||||
std::size_t const step = (firstLevelPar + k-1)/k;
|
||||
std::size_t const rk = (firstLevelPar + step-1)/step;
|
||||
|
||||
for(unsigned int i = 0; i < rk; ++i, start += step)
|
||||
split.insert(start * (n/firstLevelPar));
|
||||
}
|
||||
|
||||
return split;
|
||||
}
|
8
plot/executor/firstlevelgreedy.h
Normal file
8
plot/executor/firstlevelgreedy.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef ALSK_PLOT_EXECUTOR_FIRSTLEVELGREEDY_H
|
||||
#define ALSK_PLOT_EXECUTOR_FIRSTLEVELGREEDY_H
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
Split firstLevelGreedy(std::size_t n, CoresList const& coresList);
|
||||
|
||||
#endif
|
67
plot/executor/opti.cpp
Normal file
67
plot/executor/opti.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
#include "opti.h"
|
||||
|
||||
Split fictiveOpti(std::size_t tasks, CoresList const& coresList) {
|
||||
Split split;
|
||||
|
||||
auto equi = [&](unsigned k) {
|
||||
std::vector<unsigned> ntasks;
|
||||
unsigned const step = tasks/k;
|
||||
unsigned remain = tasks - k*step;
|
||||
|
||||
for(unsigned int i = 0; i < k; ++i) {
|
||||
unsigned q = step;
|
||||
if(remain) {
|
||||
++q;
|
||||
--remain;
|
||||
}
|
||||
ntasks.push_back(q);
|
||||
}
|
||||
|
||||
return ntasks;
|
||||
};
|
||||
|
||||
auto greedy = [&](unsigned k) {
|
||||
std::vector<unsigned> ntasks;
|
||||
unsigned step = (tasks+k-1)/k;
|
||||
unsigned n = tasks;
|
||||
|
||||
while(n) {
|
||||
if(n < step) step = n;
|
||||
n -= step;
|
||||
ntasks.push_back(step);
|
||||
}
|
||||
|
||||
return ntasks;
|
||||
};
|
||||
|
||||
static_cast<void>(equi);
|
||||
static_cast<void>(greedy);
|
||||
|
||||
for(auto k: coresList) {
|
||||
// for(unsigned int k = cores; k > 1; --k) {
|
||||
// for(unsigned int k = 2; k <= cores; ++k) {
|
||||
auto ntasks = equi(k);
|
||||
|
||||
{
|
||||
unsigned start{};
|
||||
while(ntasks.size() > 1) {
|
||||
auto v = std::end(ntasks);
|
||||
for(auto it = std::begin(ntasks);
|
||||
v == std::end(ntasks) && it != std::end(ntasks);
|
||||
++it)
|
||||
{
|
||||
if(split.count(start+*it))
|
||||
v = it;
|
||||
}
|
||||
|
||||
if(v == std::end(ntasks)) v = std::begin(ntasks);
|
||||
|
||||
start += *v;
|
||||
split.insert(start);
|
||||
ntasks.erase(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return split;
|
||||
}
|
8
plot/executor/opti.h
Normal file
8
plot/executor/opti.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef ALSK_PLOT_EXECUTOR_OPTI_H
|
||||
#define ALSK_PLOT_EXECUTOR_OPTI_H
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
Split fictiveOpti(std::size_t n, CoresList const& coresList);
|
||||
|
||||
#endif
|
0
plot/executor/staticpool.cpp
Normal file
0
plot/executor/staticpool.cpp
Normal file
8
plot/executor/staticpool.h
Normal file
8
plot/executor/staticpool.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef ALSK_PLOT_EXECUTOR_STATICPOOL_H
|
||||
#define ALSK_PLOT_EXECUTOR_STATICPOOL_H
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
Split staticPool(std::size_t n, CoresList const& coresList);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user