Skip to content

Conversation

@Purestreams
Copy link

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.

Copy link
Owner

@raas raas left a 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
Copy link
Owner

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.
Copy link
Owner

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.
Copy link
Owner

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.


Copy link
Owner

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)
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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)
Copy link
Owner

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;
Copy link
Owner

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);
Copy link
Owner

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).

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