Skip to content

Commit

Permalink
locksmith.c: Added better cos swapping support
Browse files Browse the repository at this point in the history
clients/square_evictions.c: Added support for locksmith histogram
rdtscp.h: Added fast log2 for square_evictions locksmith histogram array index calculation
prep_system.c: git operations will no longer open less
  • Loading branch information
Thomas Kim committed Dec 12, 2015
1 parent da329d2 commit 55f99ed
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
14 changes: 14 additions & 0 deletions clients/square_evictions.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
#define DEFAULT_PERCENT_CONTRACTED 80
#define DEFAULT_PERCENT_EXPANDED 220

#define MAX_MEMREF_CYCLES_POW 17
#define LOWER(x) (1 << x)
#define UPPER(x) (1 << (x+1))
uint64_t histogram[MAX_MEMREF_CYCLES_POW] = {0};

#define PERF_LOG_FILE_HEADER_LINE "realtime,cputime,instructions,bandwidth\n"
static const struct perf_event_attr PERF_LOG_COUNTERS[] = {
{
Expand Down Expand Up @@ -203,6 +208,10 @@ static int square_evictions(int cache_line_size, int num_periods, int passes_per
max_time = time;
printf("Current max cycles for a memory access %lu\n", max_time);
}
// Ignore the first 2 cycles due to memory fetch behavior
if(cycle < 2) {
++histogram[logtwo(time)];
}
}
}
assert(!siz || seen_initial);
Expand Down Expand Up @@ -429,5 +438,10 @@ int main(int argc, char *argv[]) {
munmap(perfbuf, perfbuf->siz);
if(perflog)
fclose(perflog);
if(measure_all) {
for(int i = 0; i < MAX_MEMREF_CYCLES_POW; ++i) {
printf("Mem access cycles >= 2^%d: %lu\n", i, histogram[i]);
}
}
return ret;
}
35 changes: 23 additions & 12 deletions locksmith.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
#include "bench_commands.h"
#include "log.h"
#include "prep_system.h"
#define LARGE_NUMBER "3"

// Should be at least 2, on 1 it might measure memory fetches, 2+ will use definitely use cache
#define LARGE_NUMBER "2"

#define COMMON_COS 1
#define OTHER_COS 2

#define READER_CORE 0
#define SWITCHER_CORE 1

#define NUM_SWITCHES (1 << 25)
// 21 takes about 8 seconds
// 23 takes about 40 seconds
// 24 takes about 1 minute
#define NUM_SWITCHES (1 << 24)

// TODO add flag to square_evictions for timing each memory access
static test_prog_t progs[] = {
Expand Down Expand Up @@ -42,8 +47,13 @@ static const struct pqos_l3ca COS_MASKS[] = {
static const size_t NUM_COS_MASKS = sizeof COS_MASKS / sizeof *COS_MASKS;

int main(int argc, char** argv) {
(void) argc;
(void) argv;
int swappy = 0;
/* lol */
if(argc > 1) {
if(argv[1][0] == '-' && argv[1][1] == 's')
swappy = 1;
}
/* end lol */
if(prep_system(false, -1) < 0) {
log_msg(LOG_FATAL, "Failed to complete initial setup\n");
return 1;
Expand All @@ -65,16 +75,17 @@ int main(int argc, char** argv) {
sleep(2);
}
run_benchmarks(progs, 1);
for(int i = 0; i < NUM_SWITCHES; ++i) {
if(pqos_l3ca_assoc_set(SWITCHER_CORE, OTHER_COS) != PQOS_RETVAL_OK) {
log_msg(LOG_FATAL, "Failed to switch Cos on switcher process\n");
if(swappy) {
printf("Swapping CoSes\n");
for(int i = 0; i < NUM_SWITCHES; ++i) {
if(pqos_l3ca_assoc_set(SWITCHER_CORE, OTHER_COS) != PQOS_RETVAL_OK) {
log_msg(LOG_FATAL, "Failed to switch Cos on switcher process\n");
}
}
/* Keep swapping COS of our other core */
// TODO fix this
printf("Done swapping!\n");
}
/* Keep swapping COS of our other core */
// TODO fix this
printf("Done swapping!\n");
wait_benchmarks();
run_benchmarks(progs, 1);
wait_benchmarks();
cleanup_system(true);
}
2 changes: 1 addition & 1 deletion prep_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static bool rearrange_processes(bool multicore, int procs_go_where,

#define GIT_LOG_CMD "git log --online -1"
#define GIT_STATUS_CMD "git status -uno"
#define GIT_DIFF_CMD "git diff HEAD"
#define GIT_DIFF_CMD "git --no-pager diff HEAD"
#define DELIM "==="
// Purposely ignoring the usual style for pointers!
// I don't know enough about PL to argue about it though!
Expand Down
8 changes: 8 additions & 0 deletions rdtscp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ static inline uint64_t rdtscp(void) {
return ((uint64_t)cycles_high << 32 | cycles_low);
}

static inline uint64_t logtwo(const uint64_t x) {
uint64_t y;
__asm volatile( "\tbsr %1, %0\n"
: "=r"(y)
: "r" (x)
);
return y;
}
#endif

0 comments on commit 55f99ed

Please sign in to comment.