diff --git a/.gitignore b/.gitignore index 9a8c88e..2fe683d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ __pycache__ scramble cdi4dc tools/ttf_outline -k_means/k_means_vq +k_means_vq *.blend1 *.scramble *.FCStd1 \ No newline at end of file diff --git a/gen/k_means/Makefile b/gen/k_means/Makefile new file mode 100644 index 0000000..fb4fd55 --- /dev/null +++ b/gen/k_means/Makefile @@ -0,0 +1,9 @@ +CFLAGS += -O3 +CFLAGS += -std=c++23 +CFLAGS += -Wl,-z,stack-size=314572800 +CFLAGS += -Wall -Wno-deprecated -Werror -Wfatal-errors +CFLAGS += -g -gdwarf-4 +CFLAGS += -I../.. + +k_means_vq: k_means_vq.cpp ppm.c + g++ $(CFLAGS) $^ -o $@ diff --git a/gen/k_means/k_means_vq.cpp b/gen/k_means/k_means_vq.cpp index fc73ede..499e88d 100644 --- a/gen/k_means/k_means_vq.cpp +++ b/gen/k_means/k_means_vq.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "k_means_cluster.cpp" #include "ppm.h" @@ -144,6 +145,22 @@ uint64_t color_convert(double vector[12]) int main(int argc, char * argv[]) { + // set 300MB stack size limit + const rlim_t stack_size = 300 * 1024 * 1024; + struct rlimit rl; + int res; + res = getrlimit(RLIMIT_STACK, &rl); + if (res < 0) { + perror("getrlimit RLIMIT_STACK"); + return -1; + } + rl.rlim_cur = stack_size; + res = setrlimit(RLIMIT_STACK, &rl); + if (res < 0) { + perror("setrlimit RLIMIT_STACK"); + return -1; + } + if (argc < 3) { printf("argc < 3\n"); return -1;