k_means: add getrlimit/setrlimit
This commit is contained in:
parent
c23760c93f
commit
31d684df10
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,7 +13,7 @@ __pycache__
|
||||
scramble
|
||||
cdi4dc
|
||||
tools/ttf_outline
|
||||
k_means/k_means_vq
|
||||
k_means_vq
|
||||
*.blend1
|
||||
*.scramble
|
||||
*.FCStd1
|
9
gen/k_means/Makefile
Normal file
9
gen/k_means/Makefile
Normal file
@ -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 $@
|
@ -7,6 +7,7 @@
|
||||
#include <cinttypes>
|
||||
#include <cerrno>
|
||||
#include <bit>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user