Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

likwid-bench: Add base 2 stream size parameter units, Add 64bit numbers for stream size parameter, Fix testcase parameter segfault #657

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bench/likwid-bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ extern void* getIterSingle(void* arg);
printf("-t/--test <TEST>\t type of test \n"); \
printf("-w/--workgroup\t\t <thread_domain>:<size>[:<num_threads>[:<chunk size>:<stride>]-<streamId>:<domain_id>[:<offset>]\n"); \
printf("-W/--Workgroup\t\t <thread_domain>:<size>[:<num_threads>[:<chunk size>:<stride>]]\n"); \
printf("\t\t\t\t <size> in kB, MB or GB (mandatory)\n"); \
printf("\t\t\t\t <size> in B, kB, MB, GB, kiB, MiB or GiB (mandatory)\n"); \
printf("For dynamically loaded benchmarks\n"); \
printf("-f/--tempdir <PATH>\t Specify a folder for the temporary files. default: /tmp\n"); \
printf("-o/--asmout <FILE>\t Save generated assembly to file\n"); \
Expand Down Expand Up @@ -355,6 +355,7 @@ int main(int argc, char** argv)
}
}
bdestroy(testcase);
testcase = bfromcstr("none");
if (!builtin)
{
dynbench_close(test, NULL);
Expand Down Expand Up @@ -410,6 +411,7 @@ int main(int argc, char** argv)
return EXIT_FAILURE;
}
bdestroy(testcase);
testcase = bfromcstr("none");
break;
case 'o':
case 'f':
Expand Down
66 changes: 56 additions & 10 deletions bench/src/strUtil.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,38 @@ str2int(const char* str)
return (int) val;
}

static int
str2uint64_t(const char* str, uint64_t* result)
{
char* endptr;
errno = 0;
unsigned long long val;
val = strtoull(str, &endptr, 10);

if ((errno == ERANGE && val == ULLONG_MAX)
|| (errno != 0 && val == 0))
{
fprintf(stderr, "Value in string %s out of range\n", str);
return -EINVAL;
}

if (endptr == str)
{
fprintf(stderr, "No digits were found in %s\n", str);
return -EINVAL;
}

// long long could be larger than 64 bits
if (val > 0xFFFFFFFFFFFFFFFF)
{
fprintf(stderr, "Value in string %s out of range for uint64_t\n", str);
return -EINVAL;
}

*result = val;
return 1;
}

/* ##### FUNCTION DEFINITIONS - EXPORTED FUNCTIONS ################## */

uint64_t
Expand All @@ -69,31 +101,31 @@ bstr_to_doubleSize(const_bstring str, DataType type)
int ret;
bstring unit = bmidstr(str, blength(str)-2, 2);
bstring single_unit = bmidstr(str, blength(str)-1, 1);
bstring triple_unit = bmidstr(str, blength(str)-3, 3);
bstring sizeStr = bmidstr(str, 0, blength(str)-2);
bstring single_sizeStr = bmidstr(str, 0, blength(str)-1);
bstring triple_sizeStr = bmidstr(str, 0, blength(str)-3);
uint64_t sizeU = 0;
uint64_t single_sizeU = 0;
uint64_t triple_sizeU = 0;
uint64_t junk = 0;
uint64_t bytesize = 0;
if (blength(sizeStr) == 0)
{
return 0;
}
ret = str2int(bdata(sizeStr));
if (ret >= 0)
{
sizeU = str2int(bdata(sizeStr));
}
else
ret = str2uint64_t(bdata(sizeStr), &sizeU);
if (ret < 0)
{
return 0;
}
ret = str2int(bdata(single_sizeStr));
if (ret >= 0)
ret = str2uint64_t(bdata(single_sizeStr), &single_sizeU);
if (ret < 0)
{
single_sizeU = str2int(bdata(single_sizeStr));
return 0;
}
else
ret = str2uint64_t(bdata(triple_sizeStr), &triple_sizeU);
if (ret < 0)
{
return 0;
}
Expand All @@ -112,14 +144,28 @@ bstr_to_doubleSize(const_bstring str, DataType type)
{
junk = (sizeU *1000000000)/bytesize;
}
else if ((biseqcstr(triple_unit, "kiB"))||(biseqcstr(triple_unit, "KiB")))
{
junk = (triple_sizeU *1024)/bytesize;
}
else if (biseqcstr(triple_unit, "MiB"))
{
junk = (triple_sizeU *1024*1024)/bytesize;
}
else if (biseqcstr(triple_unit, "GiB"))
{
junk = (triple_sizeU *1024*1024*1024)/bytesize;
}
else if (biseqcstr(single_unit, "B"))
{
junk = (single_sizeU)/bytesize;
}
bdestroy(unit);
bdestroy(single_unit);
bdestroy(triple_unit);
bdestroy(sizeStr);
bdestroy(single_sizeStr);
bdestroy(triple_sizeStr);
return junk;
}

Expand Down
2 changes: 1 addition & 1 deletion doc/likwid-bench.1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Filepath for the dynamic generation of benchmarks. Default /tmp/. <PID> is alway
.SH WORKGROUP SYNTAX

.B <thread_domain>:<size> [:<num_threads>[:<chunk_size>:<stride>]] [-<streamId>:<domain_id>]
with size in kB, MB or GB. The
with size in B, kB, MB, GB, kiB, MiB or GiB. The
.B <thread_domain>
defines where the threads are placed.
.B <size>
Expand Down