Add Multi-threading to Maximize Memory Bandwidth Test#18
Add Multi-threading to Maximize Memory Bandwidth Test#18Purestreams wants to merge 7 commits intoraas:masterfrom
Conversation
raas
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
This is still interesting but people won't find it at the bottom. Move to the "Usage" section?
| *.out | ||
| *.app No newline at end of file | ||
| *.app | ||
| mbw No newline at end of file |
There was a problem hiding this comment.
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.
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.
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.
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.
| @@ -267,6 +319,7 @@ int main(int argc, char **argv) | |||
| 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.
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.