commtechs bench: BUGFIX in options parsing

* nb_prod was tested with nb_cache_lines
* buf_size is unused => removed
* nb_cache_line => nb_bufs_sent
This commit is contained in:
Thomas Preud'homme 2009-06-18 22:10:15 +02:00 committed by Thomas Preud'homme
parent e3b01f9357
commit dc6cd83ac1
1 changed files with 20 additions and 27 deletions

View File

@ -15,9 +15,13 @@
#include <commtech.h>
#include <specific_comm.h>
static long nb_cache_lines = 0;
#define toString(x) doStringification(x)
#define doStringification(x) #x
static long nb_bufs_sent = 0;
long nb_prod = 0;
static long size_buf = 1;
static char *calculation_lib = NULL;
static int shared = 0;
pthread_cond_t cond_cons_has_finished = PTHREAD_COND_INITIALIZER;
@ -29,7 +33,8 @@ void usage(char *argv[])
{
char format[] = "-n [options]";
char options[] = "Required options :\n"
"-n nb_cache_lines\tNumber of cache lines to send to another core\n"
"-n nb_buffer_sent\tNumber of buffer to send to another core\n"
"\t\t\tBuffer size is " toString(BUF_SIZE) " bytes\n"
"-p nb_producers\tNumber of producers which send data to another core\n"
"Facultative options :\n"
"-h\t\t\tPrint this help\n"
@ -46,26 +51,10 @@ int analyse_options(int argc, char *argv[])
int opt;
opterr = 0;
while ((opt = getopt(argc, argv, ":hsc:n:p:b:")) != -1)
while ((opt = getopt(argc, argv, ":hsc:n:p:")) != -1)
{
switch (opt)
{
case 'b' :
{
char *inval;
size_buf = strtol(optarg, &inval, 10);
if ((*optarg == '\0') || (*inval != '\0'))
{
fprintf(stderr, "Option '-b' needs an integer argument\n");
return -1;
}
if ((nb_cache_lines <= 0) || ((nb_cache_lines == LONG_MAX) && errno == ERANGE))
{
fprintf(stderr, "Number of cache lines for each buffer must be between 1 and %ld, both inclusive\n", LONG_MAX);
return -1;
}
}
break;
case 'c' :
calculation_lib = optarg;
{
@ -83,13 +72,13 @@ int analyse_options(int argc, char *argv[])
case 'n' :
{
char *inval;
nb_cache_lines = strtol(optarg, &inval, 10);
nb_bufs_sent = strtol(optarg, &inval, 10);
if ((*optarg == '\0') || (*inval != '\0'))
{
fprintf(stderr, "Option '-n' needs an integer argument\n");
return -1;
}
if ((nb_cache_lines <= 0) || ((nb_cache_lines == LONG_MAX) && errno == ERANGE))
if ((nb_bufs_sent <= 0) || ((nb_bufs_sent == LONG_MAX) && errno == ERANGE))
{
fprintf(stderr, "Number of cache lines to be sent must be between 1 and %ld, both inclusive\n", LONG_MAX);
return -1;
@ -105,7 +94,7 @@ int analyse_options(int argc, char *argv[])
fprintf(stderr, "Option '-p' needs an integer argument\n");
return -1;
}
if ((nb_cache_lines <= 0) || ((nb_cache_lines == LONG_MAX) && errno == ERANGE))
if ((nb_prod <= 0) || ((nb_prod == LONG_MAX) && errno == ERANGE))
{
fprintf(stderr, "Number of producers must be between 1 and %ld, both inclusive\n", LONG_MAX);
return -1;
@ -114,7 +103,7 @@ int analyse_options(int argc, char *argv[])
break;
case 's' :
shared = 1;
/* TODO: shared L2 cache */
/* TODO: shared Ln cache */
break;
case '?' :
fprintf(stderr, "Option inconnue\n");
@ -127,7 +116,7 @@ int analyse_options(int argc, char *argv[])
return -1;
}
}
if (!nb_cache_lines)
if (!nb_bufs_sent)
{
fprintf(stderr, "You must give the number of cache lines to be sent\n");
return -1;
@ -182,12 +171,16 @@ void *producer(void *unused)
k = (void *) 0x6384923;
if (initialize_papi() != -1)
{
for(i = 0; i < nb_cache_lines; i++) {
for(i = 0; i < nb_bufs_sent; i++) {
//printf("[%p] Send %d new CACHE_LINE\n", (void *) pthread_self(), BUF_SIZE / CACHE_LINE_SIZE);
for(j = 0; j < (BUF_SIZE / sizeof(uintptr_t)); j++)
{
send(&k);
if (unlikely(calculation_lib != NULL))
usleep(1000);
}
}
print_results(BUF_SIZE / sizeof(uintptr_t), nb_cache_lines);
print_results(BUF_SIZE / sizeof(uintptr_t), nb_bufs_sent);
}
printf("[%p] Producer finished !\n", (void*) pthread_self());
/*