-
Notifications
You must be signed in to change notification settings - Fork 87
Add Multi-threading to Maximize Memory Bandwidth Test #18
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
base: master
Are you sure you want to change the base?
Conversation
raas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thank you very much! It's great to see that there's still life in this old project.
|
|
||
| `mbw` is a simple command-line utility to measure memory bandwidth on a system. It performs memory copy operations and reports the throughput in MiB/s. | ||
|
|
||
| ## Recent Updates: Multi-threading Support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I'd move this to a CHANGELOG.md.
|
|
||
|
|
||
|
|
||
| MBW determines the "copy" memory bandwidth available to userspace programs. Its simplistic approach models that of real applications. It is not tuned to extremes and it is not aware of hardware architecture, just like your average software package. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: Fold into the intro line at the top?
| http://github.com/raas/mbw | ||
| https://github.com/Willian-Zhang/mbw | ||
|
|
||
| 'mbw 1000' to run copy memory test on all methods with 1 GiB memory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: This and the next line are now redundant, let's remove.
|
|
||
| This update allows `mbw` to more effectively test the limits of your system's memory subsystem by leveraging multiple CPU cores. | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: Please remove the extra empty lines.
| 'mbw 1000' to run copy memory test on all methods with 1 GiB memory. | ||
| 'mbw -h' for help | ||
|
|
||
| watch out for swap usage (or turn off swap) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still interesting but people won't find it at the bottom. Move to the "Usage" section?
| *.out | ||
| *.app | ||
| *.app | ||
| mbw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: thanks, not sure why this wasn't included yet. 😬
| * | ||
| * compile with: | ||
| * gcc -O -o mbw mbw.c | ||
| * gcc -O -o mbw mbw.c -lpthread |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: does the Makefile need updating (especially that the README.md says to use make to compile?)
| unsigned long long block_size; | ||
| } thread_param_t; | ||
|
|
||
| void *thread_routine(void *p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: why not thread_param_t instead of void, and avoid a cast?
|
|
||
| pthread_t *threads = malloc(num_workers * sizeof(pthread_t)); | ||
| thread_param_t *params = malloc(num_workers * sizeof(thread_param_t)); | ||
| unsigned long long chunk_asize = asize / num_workers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: it would be more intuitive to keep asize (and thereby use a total of num_workers*asize memory), just need to document this. It would also sidestep the rounding math.
|
|
||
| if(!quiet) { | ||
| printf("Long uses %d bytes. ", long_size); | ||
| printf("Allocating 2*%lld elements = %lld bytes of memory.\n", asize, 2*asize*long_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: Adjust this for the number of threads (if taking the per-thread-asize allocation suggestion above).
This pull request introduces multi-threading to the mbw memory benchmark to better saturate modern memory controllers and provide a more accurate measurement of a system's peak memory bandwidth.