mbw-1.2.2/0000755000175000017500000000000011727100634010764 5ustar numanumambw-1.2.2/Makefile0000644000175000017500000000024311727100634012423 0ustar numanuma#CFLAGS=-O2 -Wall -g NAME=mbw mbw: mbw.c clean: rm -f mbw rm -f ${NAME}.tar.gz rpm: clean tar cCzf .. ${NAME}.tar.gz ${NAME} rpmbuild -ta ${NAME}.tar.gz mbw-1.2.2/README0000644000175000017500000000060411727100634011644 0ustar numanumaMBW 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. 2006, 2012 Andras.Horvath atnospam gmail.com http://github.com/raas/mbw 'mbw -h' for help watch out for swap usage (or turn off swap) mbw-1.2.2/mbw.10000644000175000017500000000234711727100634011641 0ustar numanuma.TH mbw 1 "Apr 26, 2006" "memory bandwidth benchmark" .SH NAME mbw \- Memory BandWidth benchmark .SH SYNOPSIS .B mbw .RI [options]\ arraysize_in_MiB .br .SH DESCRIPTION .B mbw determines available memory bandwidth by copying large arrays of data in memory. .SH OPTIONS .B .IP -q Quiet; suppress informational messages. .B .IP -a Suppress printing the average of each test. .B .IP "\-n " Select number of loops per test .B .IP "\-t " Select tests to be run. If no -t parameters are given the default is to run all tests. -t0: memcpy() test, -t1: dumb (b[i]=a[i] style) test, -t2: memcpy() with arbitrary block size .B .IP "\-b " Block size in bytes for -t2. .B .IP -h Show quick help. .SH USAGE .B mbw will allocate two .B arraysize arrays in memory and copy one to the other. Reported 'bandwidth' is the amount of data copied over the time this operation took. Obviously .B mbw needs twice .B arraysize MiBytes (1024*1024 bytes) of physical memory \- you'd better switch off swap or otherwise make sure no paging occurs. Needless to say that it should not be run on a busy system. .SH TODO Multiple thread support. Better configurability, including using getopt() for parsing arguments. .SH AUTHOR andras.horvath@gmail.com mbw-1.2.2/mbw.c0000644000175000017500000001730511727100634011723 0ustar numanuma/* * vim: ai ts=4 sts=4 sw=4 cinoptions=>4 expandtab */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include /* how many runs to average by default */ #define DEFAULT_NR_LOOPS 10 /* we have 3 tests at the moment */ #define MAX_TESTS 3 /* default block size for test 2, in bytes */ #define DEFAULT_BLOCK_SIZE 262144 /* * MBW memory bandwidth benchmark * * 2006, 2012 Andras.Horvath@gmail.com * * http://github.com/raas/mbw * * compile with: * gcc -O -o mbw mbw.c * * run with eg.: * * ./mbw 300 * * or './mbw -h' for help * * watch out for swap usage (or turn off swap) */ void usage() { printf("Usage: mbw [options] array_size_in_MiB\n"); printf("Options:\n"); printf(" -n: number of runs per test\n"); printf(" -a: Don't display average\n"); printf(" -t0: memcpy test\n"); printf(" -t1: dumb (b[i]=a[i] style) test\n"); printf(" -t2 : memcpy test with fixed block size\n"); printf(" -b : block size in bytes for -t2 (default: %d)\n", DEFAULT_BLOCK_SIZE); printf(" -q: quiet (print statistics only)\n"); printf("(will then use two arrays, watch out for swapping)\n"); printf("'Bandwidth' is amount of data copied over the time this operation took.\n"); printf("\nThe default is to run all tests available.\n"); } /* ------------------------------------------------------ */ /* allocate a test array and fill it with data * so as to force Linux to _really_ allocate it */ long *make_array(unsigned long long asize) { unsigned long long t; unsigned int long_size=sizeof(long); long *a; a=calloc(asize, long_size); if(NULL==a) { perror("Error allocating memory"); exit(1); } /* make sure both arrays are allocated, fill with pattern */ for(t=0; tarray_bytes) { b=mempcpy(b, a, t-array_bytes); } gettimeofday(&endtime, NULL); } else { /* dumb test */ gettimeofday(&starttime, NULL); for(t=0; ttestno) { printf("Error: test number must be between 0 and %d\n", MAX_TESTS); exit(1); } tests[testno]=1; break; case 'b': /* block size in bytes*/ block_size=strtoull(optarg, (char **)NULL, 10); if(0>=block_size) { printf("Error: what block size do you mean?\n"); exit(1); } break; case 'q': /* quiet */ quiet=1; break; default: break; } } /* default is to run all tests if no specific tests were requested */ if( (tests[0]+tests[1]+tests[2]) == 0) { tests[0]=1; tests[1]=1; tests[2]=1; } if(optind=mt) { printf("Error: array size wrong!\n"); exit(1); } /* ------------------------------------------------------ */ long_size=sizeof(long); /* the size of long on this platform */ asize=1024*1024/long_size*mt; /* how many longs then in one array? */ if(asize*long_size < block_size) { printf("Error: array size larger than block size (%llu bytes)!\n", block_size); exit(1); } if(!quiet) { printf("Long uses %d bytes. ", long_size); printf("Allocating 2*%lld elements = %lld bytes of memory.\n", asize, 2*asize*long_size); if(tests[2]) { printf("Using %lld bytes as blocks for memcpy block copy test.\n", block_size); } } a=make_array(asize); b=make_array(asize); /* ------------------------------------------------------ */ if(!quiet) { printf("Getting down to business... Doing %d runs per test.\n", nr_loops); } /* run all tests requested, the proper number of times */ for(testno=0; testno 1.2-1 - Fix MCBLOCK test: actually copy to the full buffer, not just its first $blocksize. * Tue Jul 07 2006 Andras Horvath 1.1-1 - separate array initialization from work -> faster execution - getopt() options parsing: suppress average, specific tests only, no. runs - added quiet mode - added a new test: memcpy() with given block size * Thu Apr 26 2006 Andras Horvath 1.0-1 - initial release