aboutsummaryrefslogtreecommitdiff
path: root/aberth
diff options
context:
space:
mode:
Diffstat (limited to 'aberth')
-rw-r--r--aberth/aberth.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/aberth/aberth.cpp b/aberth/aberth.cpp
index 13883f7..3b3c11e 100644
--- a/aberth/aberth.cpp
+++ b/aberth/aberth.cpp
@@ -243,13 +243,9 @@ static vector<Job> derbyshireJobs(int targetJobs) {
return jobs;
}
-static tuple<int, int, vector<int>> computeCounts() {
- constexpr const int W = 900;
- constexpr const int H = 900;
+static vector<int> computeCounts(int W, int H, Com bottomLeft, Com topRight) {
constexpr const int numThreads = 4;
static_assert(ispow2(numThreads));
- constexpr const Com bottomLeft = Com(-1.5, -1.5);
- constexpr const Com topRight = Com(1.5, 1.5);
vector<int> counts(W * H);
mutex countsMutex;
@@ -259,11 +255,11 @@ static tuple<int, int, vector<int>> computeCounts() {
vector<thread> threads(jobs.size());
for (int i = 0; i < (int)jobs.size(); i++) {
- threads[i] = thread([&counts, &countsMutex, job = jobs[i], bottomLeft, topRight]() {
+ threads[i] = thread([W, H, &counts, &countsMutex, job = jobs[i], bottomLeft, topRight]() {
auto calcIndex = [](double value, double left, double right, int steps) -> int {
return (value - left) / (right - left) * (steps - 1) + 0.5;
};
- auto calcPos = [bottomLeft, topRight, &calcIndex](Com z) -> pair<int, int> {
+ auto calcPos = [W, H, bottomLeft, topRight, &calcIndex](Com z) -> pair<int, int> {
return make_pair(
calcIndex(z.real(), bottomLeft.real(), topRight.real(), W),
calcIndex(z.imag(), bottomLeft.imag(), topRight.imag(), H)
@@ -291,7 +287,7 @@ static tuple<int, int, vector<int>> computeCounts() {
for (thread &th : threads) th.join();
- return make_tuple(W, H, counts);
+ return counts;
}
static void writeCounts(int W, int H, const vector<int> &counts, const char *fname) {
@@ -461,11 +457,14 @@ int main(int argc, char **argv) {
vector<int> counts;
if (argc <= 1) {
- // tie(W, H, counts) = computeCounts();
- W = H = 2000;
- Com bottomLeft = Com(0, -1.6);
- Com topRight = Com(1.6, 0);
- Kernel().run_chunked(counts, W, H, bottomLeft, topRight, 42, 1 << 14);
+ W = H = 900;
+ const Com bottomLeft = Com(-1.5, -1.5);
+ const Com topRight = Com(1.5, 1.5);
+
+ counts = computeCounts(W, H, bottomLeft, topRight);
+ // Kernel().run_chunked(counts, W, H, bottomLeft, topRight, 42, 1 << 14);
+ // Kernel().run_all(counts, W, H, bottomLeft, topRight, 42);
+
writeCounts(W, H, counts, "out.txt");
} else if (argc == 2) {
tie(W, H, counts) = readCounts(argv[1]);