aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2015-07-24 14:33:31 +1200
committerDavid Phillips <dbphillipsnz@gmail.com>2015-07-24 14:33:31 +1200
commitc7a880b18c7880daa461e655cf5c7085a49451b4 (patch)
treea74d4b02ad4a60d7164870b48704e80526a06bc8
parent1ff1618017994332da265be161e8cc548e8b8495 (diff)
downloadfractal-gen-c7a880b18c7880daa461e655cf5c7085a49451b4.tar.xz
Fixed the goddamned thing
-rw-r--r--fractal-gen.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fractal-gen.c b/fractal-gen.c
index b2025a9..e8ff501 100644
--- a/fractal-gen.c
+++ b/fractal-gen.c
@@ -62,10 +62,10 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- if (argc != 4 && argc != 5 && argc != 6)
+ if (argc != 4 && argc != 5 && argc != 7)
{
fprintf(stderr, "%s size iterat power [threads]\n"
- "%s size iterat power [cluster id] [cluster total]\n", argv[0], argv[0]);
+ "%s size iterat power threads cluster-id] cluster-total\n", argv[0], argv[0]);
return EXIT_FAILURE;
}
@@ -78,9 +78,9 @@ int main(int argc, char **argv)
* - our ID in cluster
* - total members in cluster
*/
- cores = argc == 5? atoi(argv[4]) : sysconf(_SC_NPROCESSORS_ONLN); // Screw maintainability ;)
- clust_id = argc == 6? atoi(argv[4]) : 0;
- clust_total = argc == 6? atoi(argv[5]) : 1;
+ cores = (argc == 5 || argc == 7)? atoi(argv[4]) : sysconf(_SC_NPROCESSORS_ONLN); // Screw maintainability ;)
+ clust_id = argc == 7? atoi(argv[5]) : 0;
+ clust_total = argc == 7? atoi(argv[6]) : 1;
// Interlacing is column-based, can't have more workers than columns
if (cores > size)
@@ -146,8 +146,12 @@ int main(int argc, char **argv)
// Vomit the data segments back onto the screen, deinterlacing
// TO DO: look at fwrite performance benefits over putchar
for (y = 0; y < size; y++)
- for (x = 0; x < size; x++)
- putchar(sections[y%cores].data[(y/cores)*size + x]);
+ {
+ for (x = 0; x < size/clust_total; x++)
+ {
+ putchar(sections[y%cores].data[(y/cores)*(size/clust_total) + x]);
+ }
+ }
fprintf(stderr, "\nDone\n");