Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libseff to latest version, and minor updates #61

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
DOCKERHUB=effecthandlers/effect-handlers
DOCKERBUILDARGS =

all: bench_eff bench_hia bench_koka bench_links bench_ocaml

system_base:
docker build -t $(DOCKERHUB):base systems
docker build $(DOCKERBUILDARGS) -t $(DOCKERHUB):base systems

# Eff in ocaml
system_eff: system_base
docker build -t $(DOCKERHUB):eff systems/eff
docker build $(DOCKERBUILDARGS) -t $(DOCKERHUB):eff systems/eff

bench_eff: system_eff
docker run -it --init -v $(shell pwd):/source $(DOCKERHUB):eff \
Expand All @@ -19,7 +20,7 @@ test_eff: system_eff

# Effekt
system_effekt: system_base
docker build -t $(DOCKERHUB):effekt systems/effekt
docker build $(DOCKERBUILDARGS) -t $(DOCKERHUB):effekt systems/effekt

bench_effekt: system_effekt
docker run -it --init -v $(shell pwd):/source $(DOCKERHUB):effekt \
Expand All @@ -31,7 +32,7 @@ test_effekt: system_effekt

# Handlers in Action
system_hia: system_base
docker build -t $(DOCKERHUB):hia systems/hia
docker build $(DOCKERBUILDARGS) -t $(DOCKERHUB):hia systems/hia

bench_hia: system_hia
docker run -it --init -v $(shell pwd):/source $(DOCKERHUB):hia \
Expand All @@ -43,7 +44,7 @@ test_hia: system_hia

# Koka
system_koka: system_base
docker build -t effecthandlers/effect-handlers:koka systems/koka
docker build $(DOCKERBUILDARGS) -t $(DOCKERHUB):koka systems/koka

bench_koka: system_koka
docker run -it --init -v $(shell pwd):/source $(DOCKERHUB):koka \
Expand All @@ -55,7 +56,7 @@ test_koka: system_koka

# libmpeff
system_libmpeff: system_base
docker build -t $(DOCKERHUB):libmpeff systems/libmpeff
docker build $(DOCKERBUILDARGS) -t $(DOCKERHUB):libmpeff systems/libmpeff

bench_libmpeff: system_libmpeff
docker run -it --init -v $(shell pwd):/source $(DOCKERHUB):libmpeff \
Expand All @@ -66,8 +67,8 @@ test_libmpeff: system_libmpeff
make -C /source/benchmarks/libmpeff test

# libseff
system_libseff:
docker build -t $(DOCKERHUB):libseff systems/libseff
system_libseff: system_base
docker build $(DOCKERBUILDARGS) -t $(DOCKERHUB):libseff -f systems/libseff/Dockerfile .

bench_libseff: system_libseff
docker run -it --init -v $(shell pwd):/source $(DOCKERHUB):libseff \
Expand All @@ -79,7 +80,7 @@ test_libseff: system_libseff

# Links
system_links: system_base
docker build -t $(DOCKERHUB):links systems/links
docker build $(DOCKERBUILDARGS) -t $(DOCKERHUB):links systems/links

bench_links: system_links
docker run -it --init -v $(shell pwd):/source $(DOCKERHUB):links \
Expand All @@ -91,7 +92,7 @@ test_links: system_links

# libhandler
system_libhandler: system_base
docker build -t $(DOCKERHUB):libhandler systems/libhandler
docker build $(DOCKERBUILDARGS) -t $(DOCKERHUB):libhandler systems/libhandler

bench_libhandler: system_libhandler
docker run -it --init -v $(shell pwd):/source $(DOCKERHUB):libhandler \
Expand All @@ -103,7 +104,7 @@ test_libhandler: system_libhandler

# Multicore OCaml
system_ocaml: system_base
docker build -t $(DOCKERHUB):ocaml systems/ocaml
docker build $(DOCKERBUILDARGS) -t $(DOCKERHUB):ocaml systems/ocaml

bench_ocaml: system_ocaml
docker run -it --init -v $(shell pwd):/source $(DOCKERHUB):ocaml \
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/eff/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bench: build
hyperfine --export-csv results.csv \
hyperfine --export-csv results.csv --export-json results.json \
'countdown/main 200000000' \
'fibonacci_recursive/main 42' \
'product_early/main 100000' \
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/effekt/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bench: build
hyperfine --export-csv results.csv \
hyperfine --export-csv results.csv --export-json results.json \
'countdown/main 200000000' \
'fibonacci_recursive/main 42' \
'product_early/main 100000' \
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/hia/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bench: build
hyperfine --export-csv results.csv \
hyperfine --export-csv results.csv --export-json results.json \
'./countdown/main 200000000' \
'./fibonacci_recursive/main 42' \
'./product_early/main 100000' \
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/koka/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bench: build
hyperfine --export-csv results.csv \
hyperfine --export-csv results.csv --export-json results.json \
'countdown/main 200000000' \
'fibonacci_recursive/main 42' \
'product_early/main 100000' \
Expand Down
20 changes: 10 additions & 10 deletions benchmarks/libmpeff/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ build_cmd = cd $(1) ; $(call compile_cmd, $(1)); $(call link_cmd, $(1))
test_cmd = cd $(1) ; ./main $(2) > actual ; echo $(3) > expected ; diff expected actual

bench: build
hyperfine --export-csv results.csv \
'./countdown/main 200000000' \
'./fibonacci_recursive/main 42' \
'./product_early/main 100000' \
'./iterator/main 40000000' \
'./generator/main 25' \
'./parsing_dollars/main 20000' \
'./resume_nontail/main 20000' \
'./handler_sieve/main 60000'
hyperfine --export-csv results.csv --export-json results.json \
'countdown/main 200000000' \
'fibonacci_recursive/main 42' \
'product_early/main 100000' \
'iterator/main 40000000' \
'generator/main 25' \
'parsing_dollars/main 20000' \
'resume_nontail/main 20000' \
'handler_sieve/main 60000'

test: build
$(call test_cmd, countdown, 5, 0)
Expand All @@ -38,7 +38,7 @@ test: build
$(call test_cmd, resume_nontail, 5, 37)
$(call test_cmd, handler_sieve, 10, 17)

build:
build:
$(call build_cmd, countdown)
$(call build_cmd, fibonacci_recursive)
$(call build_cmd, product_early)
Expand Down
22 changes: 11 additions & 11 deletions benchmarks/libseff/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ LIBSEFF_H := $(LIBSEFF)/src
LIBSEFF_LIB := $(LIBSEFF)/output/lib

CC := clang-14
CC_COMPILE_FLAGS := -std=gnu99 -O3 -I$(LIBSEFF_H) -fsplit-stack
CC_COMPILE_FLAGS := -std=gnu99 -O3 -I$(LIBSEFF_H) -fsplit-stack
CC_WARN_FLAGS := -Wall -Wextra \
-Wformat=2 -Wno-unused-parameter -Wshadow \
-Wwrite-strings -Wstrict-prototypes -Wold-style-definition \
Expand All @@ -19,15 +19,15 @@ build_cmd = cd $(1) ; $(call compile_cmd, $(1)); $(call link_cmd, $(1))
test_cmd = cd $(1) ; ./main $(2) > actual ; echo $(3) > expected ; diff expected actual

bench: build
hyperfine --export-csv results.csv \
'./countdown/main 200000000' \
'./fibonacci_recursive/main 42' \
'./product_early/main 100000' \
'./iterator/main 40000000' \
'./generator/main 25' \
'./parsing_dollars/main 20000' \
'./resume_nontail/main 20000' \
'./handler_sieve/main 60000'
hyperfine --export-csv results.csv --export-json results.json \
'countdown/main 200000000' \
'fibonacci_recursive/main 42' \
'product_early/main 100000' \
'iterator/main 40000000' \
'generator/main 25' \
'parsing_dollars/main 20000' \
'resume_nontail/main 20000' \
'handler_sieve/main 60000'

test: build
$(call test_cmd, countdown, 5, 0)
Expand All @@ -39,7 +39,7 @@ test: build
$(call test_cmd, resume_nontail, 5, 37)
$(call test_cmd, handler_sieve, 10, 17)

build:
build:
$(call build_cmd, countdown)
$(call build_cmd, fibonacci_recursive)
$(call build_cmd, product_early)
Expand Down
18 changes: 9 additions & 9 deletions benchmarks/libseff/countdown/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ DEFINE_EFFECT(put, 1, void, { int64_t new_value; });

static int64_t evalState(seff_coroutine_t *k, int64_t initialState) {
int64_t state = initialState;
effect_set handles_state = HANDLES(get) | HANDLES(put);
seff_request_t req = seff_handle(k, NULL, handles_state);
effect_set handles_state = HANDLES(get) | HANDLES(put);
seff_request_t req = seff_resume(k, NULL, handles_state);

int64_t result = -1;
bool done = false;
while (!done) {
while (!done) {
switch (req.effect) {
CASE_EFFECT(req, get, {
req = seff_handle(k, (void*) state, handles_state);
req = seff_resume(k, (void*) state, handles_state);
break;
})
CASE_EFFECT(req, put, {
state = payload.new_value;
req = seff_handle(k, 0, handles_state);
req = seff_resume(k, 0, handles_state);
break;
})
CASE_RETURN(req, {
Expand Down Expand Up @@ -48,13 +48,13 @@ static int64_t run(int64_t n) {
return result;
}

int main(int argc, char** argv) {
int main(int argc, char** argv) {
int64_t n = argc != 2 ? 5 : atoi(argv[1]);
int64_t result = run(n);
int64_t result = run(n);

// Increase output buffer size to increase performance
char buffer[8192];
setvbuf(stdout, buffer, _IOFBF, sizeof(buffer));
printf("%ld\n", result);
return 0;
return 0;
}
6 changes: 3 additions & 3 deletions benchmarks/libseff/countdown/main_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DEFINE_EFFECT(get, 0, int64_t, {});
DEFINE_EFFECT(put, 1, void, { int64_t new_value; });

int64_t* evalState(seff_coroutine_t *k, int64_t param, int64_t *state) {
seff_request_t req = seff_handle(k, (void*) param, HANDLES(get) | HANDLES(put));
seff_request_t req = seff_resume(k, (void*) param, HANDLES(get) | HANDLES(put));
switch (req.effect) {
CASE_EFFECT(req, get, {
return evalState(k, *state, state);
Expand Down Expand Up @@ -36,9 +36,9 @@ int64_t run(int64_t n) {
return *evalState(k, 0, &state);
}

int main(int argc, char** argv) {
int main(int argc, char** argv) {
int64_t n = argc != 2 ? 5 : atoi(argv[1]);
int64_t result = run(n);
printf("%ld\n", result);
return 0;
return 0;
}
12 changes: 6 additions & 6 deletions benchmarks/libseff/generator/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static tree_t makeTree(int n) {
tree_t node = allocNode();
tree_t t = makeTree (n - 1);

// Note: both left and right pointers point to the same memory,
// Note: both left and right pointers point to the same memory,
// to match the other languages
node->l = t;
node->r = t;
Expand All @@ -47,7 +47,7 @@ static void freeTree(tree_t tree) {

// Yield handler
static thunk_t handleYield(seff_coroutine_t *k) {
seff_request_t req = seff_handle(k, NULL, HANDLES(yield));
seff_request_t req = seff_resume(k, NULL, HANDLES(yield));
thunk_t thunk;
switch (req.effect) {
CASE_EFFECT(req, yield, {
Expand All @@ -57,7 +57,7 @@ static thunk_t handleYield(seff_coroutine_t *k) {
});
CASE_RETURN(req, {
thunk.v = (int64_t) payload.result;
thunk.k = NULL;
thunk.k = NULL;
seff_coroutine_delete(k);
return thunk;
});
Expand Down Expand Up @@ -90,7 +90,7 @@ static int64_t sum(generator_t generator) {
}

static int64_t run(int64_t n) {
tree_t tree = makeTree(n);
tree_t tree = makeTree(n);
seff_coroutine_t *k = seff_coroutine_new(iterate, (void*) tree);
generator_t generator = handleYield(k);

Expand All @@ -102,13 +102,13 @@ static int64_t run(int64_t n) {
return result;
}

int main(int argc, char** argv) {
int main(int argc, char** argv) {
int64_t n = argc != 2 ? 25 : atoi(argv[1]);
int64_t r = run(n);

// Increase size of output buffer for performance
char buffer[8192];
setvbuf(stdout, buffer, _IOFBF, sizeof(buffer));
printf("%ld\n", r);
return 0;
return 0;
}
14 changes: 7 additions & 7 deletions benchmarks/libseff/handler_sieve/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ typedef struct primes_params_t {
} primes_params_t;

static int64_t handle_toplevel(seff_coroutine_t *k) {
seff_request_t req = seff_handle(k, NULL, HANDLES(prime));
seff_request_t req = seff_resume(k, NULL, HANDLES(prime));
int64_t result = 0;
bool done = false;
while (!done) {
switch(req.effect) {
CASE_EFFECT(req, prime, {
req = seff_handle(k, (void*) true, HANDLES(prime));
req = seff_resume(k, (void*) true, HANDLES(prime));
break;
});
CASE_RETURN(req, {
Expand All @@ -31,7 +31,7 @@ static int64_t handle_toplevel(seff_coroutine_t *k) {
}

static int64_t handle_prime(seff_coroutine_t *k, int64_t i) {
seff_request_t req = seff_handle(k, NULL, HANDLES(prime));
seff_request_t req = seff_resume(k, NULL, HANDLES(prime));

int64_t result = 0;
bool done = false;
Expand All @@ -41,7 +41,7 @@ static int64_t handle_prime(seff_coroutine_t *k, int64_t i) {
bool res;
if (payload.e % i == 0) res = false;
else res = PERFORM (prime, payload.e);
req = seff_handle(k, (void*) res, HANDLES(prime));
req = seff_resume(k, (void*) res, HANDLES(prime));
break;
});
CASE_RETURN(req, {
Expand Down Expand Up @@ -83,13 +83,13 @@ static int64_t run(int64_t n) {
return result;
}

int main(int argc, char** argv) {
int main(int argc, char** argv) {
int64_t n = argc != 2 ? 10 : atoi(argv[1]);
int64_t r = run(n);

// Increase output buffer size to increase performance
char buffer[8192];
setvbuf(stdout, buffer, _IOFBF, sizeof(buffer));
printf("%ld\n", r);
return 0;
return 0;
}
Loading
Loading