commtech: Update usage help

This commit is contained in:
Thomas Preud'homme 2009-07-01 03:10:38 +02:00 committed by Thomas Preud'homme
parent 415004fb4b
commit 698341b99e
1 changed files with 34 additions and 10 deletions

View File

@ -31,7 +31,7 @@ long nb_prod = 0;
static int (*init_calc)(int) = NULL;
static void **(*do_calc)(void) = NULL;
static int (*end_calc)(void) = NULL;
static int shared = 0;
static int shared = 0; /* We are not shared by default */
pthread_cond_t cond_cons_has_finished = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mutex_cons_has_finished = PTHREAD_MUTEX_INITIALIZER;
static int consumer_has_finished = 0;
@ -42,14 +42,18 @@ void usage(char *argv[])
{
char format[] = "-n [options]";
char options[] = "Required options :\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"
"-n nb_buffer_sent\t\tNumber of buffer to send to another core\n"
"\t\t\t\tBuffer size is " toString(BUF_SIZE) " bytes\n"
"-p nb_producers\t\t\tNumber of producers which send data to another core\n"
"Facultative options :\n"
"-h\t\t\tPrint this help\n"
"-s\t\t\tShare the same L2 cache or not\n"
"-h\t\t\t\tPrint this help\n"
"-s <level>\t\t\tShare the same L<level> cache or not\n"
"\t\t\t\tIf level is:\n"
"\t\t\t\t\t> 0, then the same L<level> must be shared\n"
"\t\t\t\t\t< 0, then different L<level> must be used\n"
"\t\t\t\t\t= 0, then no constraint is given, only main memory (RAM) is guaranteed to be shared\n"
"-c calculation_libname arg\tLibrary to use for calculation with its argument\n"
"\t\t\tThis library must implement functions in calc.h\n";
"\t\t\t\tThis library must implement functions in calc.h\n";
printf("Usage : %s %s\n", argv[0], format);
printf("Options :\n");
printf("%s\n", options);
@ -77,7 +81,7 @@ int analyse_options(int argc, char *argv[])
int opt;
opterr = 0;
while ((opt = getopt(argc, argv, ":hsc:n:p:")) != -1)
while ((opt = getopt(argc, argv, ":hs::c:n:p:")) != -1)
{
switch (opt)
{
@ -164,8 +168,28 @@ int analyse_options(int argc, char *argv[])
}
break;
case 's' :
shared = 1;
/* TODO: shared Ln cache */
if ((optind != argc) && (*argv[optind] != '-'))
{
int share_level;
char *inval;
share_level = strtol(argv[optind], &inval, 10);
if ((*argv[optind] == '\0') || (*inval != '\0'))
{
fprintf(stderr, "Option '-p' needs an integer argument\n");
return -1;
}
if ((share_level == LONG_MIN) || ((share_level == LONG_MAX) && errno == ERANGE))
{
fprintf(stderr, "Shared memory level must be between %ld and %ld, both inclusive\n", LONG_MIN, LONG_MAX);
return -1;
}
/* TODO: Real management of shared memory level */
if (share_level <= 0) /* -x: We wan't level x not to be shared; 0 do as we want, only memory is guaranteed to be shared */
shared = 0;
else
shared = 1;
optind++;
}
break;
case '?' :
fprintf(stderr, "Option inconnue\n");