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

Add change-counting benchmark #369

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

moazzammoriani
Copy link
Contributor

This PR adds a combinatorial benchmark that enumerates the all the possible way to distribute change to pay a given amount. The relevant config files have also been updated.

@moazzammoriani
Copy link
Contributor Author

moazzammoriani commented Jul 6, 2022

The motivation behind the hitherto latest commit stems from an observation that the scaling of the parallelism becomes more visible when the number of denominations in the coins_input data structure are close to half the number of cores on the system. This is not surprising since of the two dimensions the number of denominations is seemingly the most obvious one connected to the number of cores.

I had previously ran these benchmarks with coins input of size 1400

Looking at the results from running the multicore version, it seems like performance peaks as the number of cores and denominations are roughly equal to one another.

$ ./run_all.sh _build/default/count_change_iter_multicore.exe 400
++ exe=_build/default/count_change_iter_multicore.exe
++ arg=400
++ for i in 1 2 4 8 12
++ taskset --cpu-list 2-13 chrt -r 1 _build/default/count_change_iter_multicore.exe 1 400
possibilites = 8991689

real	0m42.768s
user	0m36.788s
sys	0m5.980s
++ for i in 1 2 4 8 12
++ taskset --cpu-list 2-13 chrt -r 1 _build/default/count_change_iter_multicore.exe 2 400
possibilites = 8991689

real	0m25.475s
user	0m42.492s
sys	0m6.029s
++ for i in 1 2 4 8 12
++ taskset --cpu-list 2-13 chrt -r 1 _build/default/count_change_iter_multicore.exe 4 400
possibilites = 8991689

real	0m16.622s
user	0m49.907s
sys	0m6.635s
++ for i in 1 2 4 8 12
++ taskset --cpu-list 2-13 chrt -r 1 _build/default/count_change_iter_multicore.exe 8 400
possibilites = 8991689

real	0m15.421s
user	0m53.906s
sys	0m7.442s
++ for i in 1 2 4 8 12
++ taskset --cpu-list 2-13 chrt -r 1 _build/default/count_change_iter_multicore.exe 12 400
possibilites = 8991689

real	0m16.102s
user	1m10.238s
sys	0m7.862s
++ for i in 16 20 24
++ taskset --cpu-list 2-13,16-27 chrt -r 1 _build/default/count_change_iter_multicore.exe 16 400
possibilites = 8991689

real	0m16.850s
user	1m19.063s
sys	0m9.277s
++ for i in 16 20 24
++ taskset --cpu-list 2-13,16-27 chrt -r 1 _build/default/count_change_iter_multicore.exe 20 400
possibilites = 8991689

real	0m16.022s
user	1m14.669s
sys	0m10.369s
++ for i in 16 20 24
++ taskset --cpu-list 2-13,16-27 chrt -r 1 _build/default/count_change_iter_multicore.exe 24 400
possibilites = 8991689

real	0m16.136s
user	1m26.540s
sys	0m10.647s

@moazzammoriani moazzammoriani changed the title Add count_change_iter and count_chnage_iter_multicore and their configs Add count_change_iter and count_change_iter_multicore and their configs Jul 6, 2022
Copy link
Contributor

@Sudha247 Sudha247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is a great addition to the set of parallel bench.

Left some comments below. Switching from tuples to records would simplify the code IMO.

| _ -> aux (L.tl c) (((amt, c, []))::stack) in
aux coins []

let coins_input : (int * int) list =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tuple here could be replaced with a record such as:

type coin = { denom : int; num : int; }

This would make it easier to read what's stored in the tuple.

benchmarks/multicore-numerical/count_change_iter.ml Outdated Show resolved Hide resolved
@moazzammoriani moazzammoriani changed the title Add count_change_iter and count_change_iter_multicore and their configs Add new change counting benchmark Aug 11, 2022
@moazzammoriani moazzammoriani changed the title Add new change counting benchmark Add new change-counting benchmark Aug 11, 2022
@moazzammoriani moazzammoriani changed the title Add new change-counting benchmark Add change-counting benchmark Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants