Skip to content

Commit

Permalink
submission update and msr time check
Browse files Browse the repository at this point in the history
  • Loading branch information
hwnam831 committed Jun 29, 2021
1 parent 11762b9 commit 84536b4
Show file tree
Hide file tree
Showing 4 changed files with 433 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_args():
parser.add_argument(
"--student",
type=int,
default='10',
default='8',
help='student channel dimension')
parser.add_argument(
"--lr",
Expand Down
40 changes: 36 additions & 4 deletions lib/msr-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,14 @@ uint64_t rdmsr_on_cpu_0(uint32_t reg) {
}
}
}

#ifdef DEBUG
register uint64_t time1, time2;
unsigned cycles_high, cycles_low, cycles_high1, cycles_low1;
asm volatile ("CPUID\n\t"
"RDTSC\n\t"
"mov %%edx, %0\n\t"
"mov %%eax, %1\n\t": "=r" (cycles_high), "=r" (cycles_low):: "rax", "rbx", "rcx", "rdx");
#endif
if (pread(fd, &data, sizeof data, reg) != sizeof data) {
if (errno == EIO) {
fprintf(stderr, "rdmsr: CPU %d cannot read "
Expand All @@ -152,7 +159,15 @@ uint64_t rdmsr_on_cpu_0(uint32_t reg) {
exit(127);
}
}

#ifdef DEBUG
asm volatile ("RDTSCP\n\t"
"mov %%edx, %0\n\t"
"mov %%eax, %1\n\t"
"CPUID\n\t": "=r" (cycles_high1), "=r" (cycles_low1):: "rax", "rbx", "rcx", "rdx");
time1= (((uint64_t)cycles_high << 32) | cycles_low);
time2= (((uint64_t)cycles_high1 << 32) | cycles_low1);
printf("RDMSR took %d cycles\n",time2-time1);
#endif
//close(fd);

return data;
Expand All @@ -169,7 +184,7 @@ void wrmsr_on_cpu_0(uint32_t reg, int valcnt, uint64_t *regvals) {
int cpu = 0;

static int fd = -1;

if(fd < 0){
fd = open(msr_file_name, O_WRONLY);
if (fd < 0) {
Expand All @@ -188,6 +203,14 @@ void wrmsr_on_cpu_0(uint32_t reg, int valcnt, uint64_t *regvals) {
}

while (valcnt--) {
#ifdef DEBUG
register uint64_t time1, time2;
unsigned cycles_high, cycles_low, cycles_high1, cycles_low1;
asm volatile ("CPUID\n\t"
"RDTSC\n\t"
"mov %%edx, %0\n\t"
"mov %%eax, %1\n\t": "=r" (cycles_high), "=r" (cycles_low):: "rax", "rbx", "rcx", "rdx");
#endif
data=*regvals++;
if (pwrite(fd, &data, sizeof data, reg) != sizeof data) {
if (errno == EIO) {
Expand All @@ -201,8 +224,17 @@ void wrmsr_on_cpu_0(uint32_t reg, int valcnt, uint64_t *regvals) {
exit(127);
}
}
#ifdef DEBUG
asm volatile ("RDTSCP\n\t"
"mov %%edx, %0\n\t"
"mov %%eax, %1\n\t"
"CPUID\n\t": "=r" (cycles_high1), "=r" (cycles_low1):: "rax", "rbx", "rcx", "rdx");
time1= (((uint64_t)cycles_high << 32) | cycles_low);
time2= (((uint64_t)cycles_high1 << 32) | cycles_low1);
printf("WRMSR took %d cycles\n",time2-time1);
#endif
}

//close(fd);

return;
Expand Down
119 changes: 59 additions & 60 deletions plotter.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 84536b4

Please sign in to comment.