Skip to content

Commit 5dd3949

Browse files
Yangzheng BaiYangzheng Bai
authored andcommitted
Add error handling case for lockhammer -o option
We can clearly observe 10% difference in lock access latency for 2 different pinning order (default vs optimized) like the following: ./build/lh_osq_lock -t 5 -a 1000000 5000000 lock loops 20784292691 ns scheduled 4156990971 ns elapsed (~4.999841 cores) 4156.858538 ns per access (scheduled) 4156.836709 ns per access (real) 831.398194 ns access rate 1.000000 average depth 5, 4.999841, 4156.858538, 4156.836709, 831.398194, 1.000000 ./build/lh_osq_lock -t 5 -a 1000000 -o 0,32,4,36,8 5000000 lock loops 18483098623 ns scheduled 3696729985 ns elapsed (~4.999850 cores) 3696.619725 ns per access (scheduled) 3696.614593 ns per access (real) 739.345997 ns access rate 1.000000 average depth 5, 4.999850, 3696.619725, 3696.614593, 739.345997, 1.000000
1 parent 53599a0 commit 5dd3949

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

benchmarks/lockhammer/src/lockhammer.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,11 @@ int main(int argc, char** argv)
179179
return 1;
180180
}
181181
csv = strtok(optarg, ",");
182-
for (int i = 0; i < num_cores && csv != NULL; csv = strtok(NULL, ","), ++i)
183-
*(args.pinorder + i) = strtol(csv, (char **) NULL, 10);
182+
for (int i = 0; i < num_cores && csv != NULL; csv = strtok(NULL, ","), ++i) {
183+
optval = strtol(csv, (char **) NULL, 10);
184+
if (optval >= 0 && optval < num_cores) *(args.pinorder + i) = optval;
185+
else fprintf(stderr, "WARNING: core number %ld is out of range.\n", optval);
186+
}
184187
break;
185188
case 's':
186189
args.safemode = 1;

0 commit comments

Comments
 (0)