Commit e5cf2c6964a4c6f5dd0d6000d6abc8eedf9b44b3

Authored by Ajay Mohan
Exists in master

Merge branch 'master' of https://git.ucsd.edu/ajmohan/rasperf

Showing 41 changed files Side-by-side Diff

cpu/context_switch_process.c View file @ e5cf2c6
1 1 #include <stdio.h>
2 2 #include <stdlib.h>
  3 +
3 4 int main(int argc, char **argv)
4 5 {
5   - int count, i, toSlave[2], fromSlave[2];
  6 + int count, i, tochild[2], fromchild[2];
6 7 int pid, status;
7 8 char buffer[10];
8 9 unsigned int begin ,end;
9 10  
... ... @@ -12,12 +13,12 @@
12 13 printf("regr: %x\n", regr);
13 14  
14 15 count = 1000;
15   - pipe(toSlave);
  16 + pipe(tochild);
16 17 for (i = 0; i < count; i++)
17 18 {
18 19 pid = fork();
19 20 if (pid == 0) {
20   - read(toSlave[0], buffer, 1);
  21 + read(tochild[0], buffer, 1);
21 22 //if (buffer[0] != 'a') {
22 23 // printf("Exiting\n");
23 24 // return -1;
24 25  
... ... @@ -28,8 +29,8 @@
28 29 printf("Couldn't fork slave process: error %d.\n");
29 30 return -1;
30 31 } else {
  32 + write(tochild[1], "a", 1);
31 33 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (begin));
32   - write(toSlave[1], "a", 1);
33 34 waitpid(pid, &status, 0);
34 35 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (end));
35 36 //usleep(10000);
... ... @@ -39,7 +40,6 @@
39 40  
40 41 }
41 42 timePer = timePer/(2*900*count);
42   - printf("Average time taken for context switch: %.lf seconds.\n",
43   - timePer);
  43 + printf("Average time for context switch: %.lf seconds.\n", timePer);
44 44 }
cpu/context_switch_process.o View file @ e5cf2c6

No preview for this file type

cpu/getpid.c View file @ e5cf2c6
  1 +#define _GNU_SOURCE
  2 +#include <unistd.h>
  3 +#include <sys/syscall.h>
  4 +#include <sys/types.h>
  5 +#include <signal.h>
  6 +#include <sys/time.h>
  7 +#include <stdio.h>
  8 +
  9 +int main(int argc, char *argv[])
  10 +{
  11 + pid_t tid;
  12 + int i = 0;
  13 + float avg_read_time = 0;
  14 + struct timeval tv1, tv2;
  15 + float avg_syscall_time = 0;
  16 + unsigned int dummy;
  17 +
  18 + for (i = 0; i < 1000; i++) {
  19 + gettimeofday(&tv1, NULL);
  20 + gettimeofday(&tv2, NULL);
  21 + avg_read_time += (tv2.tv_sec*1e6 + tv2.tv_usec - tv1.tv_sec*1e6 - tv1.tv_usec);
  22 + }
  23 +
  24 + printf("avg_read_time: %f\n", avg_read_time/1000.0);
  25 +
  26 + for (i = 0; i < 100; i++) {
  27 + gettimeofday(&tv1, NULL);
  28 + syscall(SYS_tgkill, getpid(), tid, SIGHUP);
  29 + gettimeofday(&tv2, NULL);
  30 + dummy += (tv2.tv_sec*1e6 + tv2.tv_usec - tv1.tv_sec*1e6 - tv1.tv_usec);
  31 + avg_syscall_time += dummy;
  32 + printf("avg_syscall_time: %u\n", dummy);
  33 + avg_syscall_time -= avg_read_time;
  34 + }
  35 + printf("avg_syscall_time: %f\n", avg_syscall_time/100.0);
  36 + return 0;
  37 +}
cpu/gettimeofday_overhead.c View file @ e5cf2c6
  1 +#include <stdio.h>
  2 +#include <sys/time.h>
  3 +
  4 +int main()
  5 +{
  6 + int time1, time2, sum=0;
  7 + int i;
  8 + float avg = 0.0;
  9 + asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i));
  10 + printf("Get Time of Day overhead: \n");
  11 + struct timeval tv;
  12 +
  13 + while(sum < 100) {
  14 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1));
  15 + gettimeofday(&tv, NULL);
  16 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2));
  17 + avg = (time2 - time1);
  18 + sum++;
  19 + }
  20 + printf("%f", avg);
  21 +}
cpu/gettimeofday_overhead.o View file @ e5cf2c6

No preview for this file type

cpu/loop_overhead_time.c View file @ e5cf2c6
... ... @@ -12,10 +12,9 @@
12 12 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1));
13 13 for (i = 0; i < 1000; i++);
14 14 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2));
15   - avg = (time2 - time1 - 5);
  15 + avg = (time2 - time1 - 5)/1000; //5 is measurement overhead for mrc
16 16 sum++;
17   - printf("%f,", avg/1000);
18 17 }
19   - printf("%f", avg);
  18 + printf("%f", avg/100);
20 19 }
cpu/loop_overhead_time.o View file @ e5cf2c6

No preview for this file type

cpu/process_creation.c View file @ e5cf2c6
... ... @@ -16,10 +16,10 @@
16 16 int pid = fork();
17 17 if (pid) {
18 18 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b));
  19 + // Measure time for creation, kill the child
19 20 kill(pid, SIGKILL);
20 21 wait(NULL);
21   - if ((b - a) < 400000)
22   - printf("%u,", b - a);
  22 + printf("%u,", b - a);
23 23 }
24 24 }
25 25  
cpu/rasperf.h View file @ e5cf2c6
  1 +
  2 +#ifndef __RASPERF_H__
  3 +#define NULL '\0'
  4 +#define __RASPERF_H__
  5 +#define RTT 35 //in MicroSec
  6 +#define PI 0
  7 +#define x86 1
  8 +#define CPU_CYCLES 900
  9 +#define MHz 1e6
  10 +#if defined(PI) && PI
  11 +#define time unsigned int
  12 +#define getTime(var) \
  13 + asm volatile (\
  14 + "mrc p15, 0, %0, c9, c13, 0":\
  15 + "=r" (var));
  16 +#define readCCNTStatus(var) \
  17 + asm volatile (\
  18 + "mrc p15, 0, %0, c9, c14, 0":\
  19 + "=r" (var));
  20 +#define diff(end, begin) \
  21 + (end - begin)/ CPU_CYCLES};
  22 +#endif
  23 +#if defined(x86) && x86
  24 +#define time struct timeval
  25 +#define getTime(var) gettimeofday(&var, NULL)
  26 +#define diff(end, begin) \
  27 + ((end.tv_sec*1e6+end.tv_usec) - (begin.tv_sec*1e6+ begin.tv_usec))
  28 +#endif
  29 +#endif
cpu/reading_time.c View file @ e5cf2c6
... ... @@ -9,13 +9,13 @@
9 9 asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (time));
10 10  
11 11 time = 0;
12   - for (i = 0; i < 1000; i++) {
  12 + for (i = 0; i < 10000; i++) {
13 13 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a));
14 14 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b));
15 15 time += b - a;
16   - printf("%d,", b-a);
  16 + //printf("%d,", b-a);
17 17 }
18   - avg = time / 1000;
  18 + avg = time / 10000;
19 19 printf("Measurement overhead: %f\n", avg);
20 20 return 0;
21 21 }
cpu/reading_time.o View file @ e5cf2c6

No preview for this file type

cpu/syscall.c View file @ e5cf2c6
1 1 #include <stdio.h>
  2 +#include <sys/syscall.h>
  3 +#include <sys/types.h>
  4 +#include <unistd.h>
  5 +#include <stdio.h>
  6 +#include <assert.h>
2 7  
3 8 int main()
4 9 {
5 10 unsigned int regr;
6   - unsigned int i;
7   - unsigned int a, b;
  11 + unsigned int i, i2;
  12 + unsigned int a, b, c;
8 13  
9 14 asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (regr));
10 15 // printf("regr: %x\n", regr);
11 16  
12 17 regr = 0;
  18 + i2 = getpid();
13 19 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a));
14   - i = getpid();
  20 + //syscall(getpid());
  21 + i = syscall(SYS_getpid);
15 22 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b));
16   - printf("PID: %u, Time for getpid: %u\n", i, b - a);
17   - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a));
18   - time();
19   - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b));
20   - printf("PID2: Time for time(): %u\n", b - a);
  23 + //getpid();
  24 + i = syscall(SYS_getpid);
  25 + //syscall(getpid());
  26 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (c));
  27 + printf("PID: %u %u, Time for getpid: %u, %u\n", i, i2, b - a, c - b);
21 28 return 0;
22 29 }
cpu/syscall.o View file @ e5cf2c6

No preview for this file type

cpu/thd_ctxsw.c View file @ e5cf2c6
... ... @@ -6,27 +6,30 @@
6 6 #include<stdlib.h>
7 7 #include<signal.h>
8 8 #define STACK_SIZE 4096
  9 +
9 10 int pipe_fd[2], tid1, tid2;
10 11 char buffer[10];
11 12 int reader(void* arg);
12 13 int writer(void* arg);
13   -int controller(void *arg)
  14 +int primary(void *arg)
14 15 {
15   - void *tid1_stack = malloc(STACK_SIZE);
16   - void *tid2_stack = malloc(STACK_SIZE);
17   - tid1 = clone(&writer, tid1_stack+STACK_SIZE, SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL);
18   - tid2 = clone(&reader, tid2_stack+STACK_SIZE, SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL);
19   - return 0;
  16 + void *tid1_stack = malloc(STACK_SIZE);
  17 + void *tid2_stack = malloc(STACK_SIZE);
  18 + tid1 = clone(&writer, tid1_stack+STACK_SIZE,
  19 + SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL);
  20 + tid2 = clone(&reader, tid2_stack+STACK_SIZE,
  21 + SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL);
  22 + return 0;
20 23 }
21 24 int reader(void* arg)
22 25 {
23   - read(pipe_fd[0], buffer, 1);
24   - return 0;
  26 + read(pipe_fd[0], buffer, 1);
  27 + return 0;
25 28 }
26 29 int writer(void* arg)
27 30 {
28   - write(pipe_fd[1], "a", 1);
29   - return 0;
  31 + write(pipe_fd[1], "a", 1);
  32 + return 0;
30 33 }
31 34 int main(){
32 35  
33 36  
34 37  
... ... @@ -39,16 +42,17 @@
39 42  
40 43 //asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (regr));
41 44 //printf("regr: %x\n", regr);
42   -
  45 +
43 46 //initialize communication pipe
44 47 for (i = 0; i < 1000; i++)
45 48 {
46 49 getTime(start);
47   - thread_pid = clone(&controller, child_stack+STACK_SIZE, SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL);
  50 + thread_pid = clone(&primary, child_stack+STACK_SIZE,
  51 + SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL);
48 52 waitpid(thread_pid, 0, 0);
49 53 getTime(end);
50 54 printf("\nTime Taken %d", diff(end,start));
51 55 }
52 56 return 0;
53   -}
  57 +}
cpu/thd_ctxsw.o View file @ e5cf2c6

No preview for this file type

cpu/thread_creation.c View file @ e5cf2c6
... ... @@ -21,14 +21,12 @@
21 21 asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (regr));
22 22 printf("regr: %x\n", regr);
23 23  
24   -// for (i = 0; i < 1000; i++)
25   -// {
26   - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a));
27   - thread_pid = clone(&func, child_stack+STACK_SIZE, SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL);
28   - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b));
29   -// waitpid(thread_pid,0,0);
30   - printf("%u,", b - a);
31   -// }
  24 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a));
  25 + thread_pid = clone(&func, child_stack+STACK_SIZE,
  26 + SIGCHLD|CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES|CLONE_THREAD, NULL);
  27 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b));
  28 + // waitpid(thread_pid,0,0);
  29 + printf("%u,", b - a);
32 30 return 0;
33 31 }
filesystem/file_cache.c View file @ e5cf2c6
  1 +#include <stdio.h>
  2 +#include <fcntl.h>
  3 +#include <string.h>
  4 +#include <stdlib.h>
  5 +#include <sys/time.h>
  6 +#define BLOCK_SIZE 1024
  7 +void main()
  8 +{
  9 + char *fnames[] = {"file_1", "file_2", "file_3", "file_4", "file_5", "file_6", "file_7"};
  10 + char buffer[BLOCK_SIZE];
  11 + struct timeval start, end;
  12 + int fd=0;
  13 + int i, j;
  14 + unsigned long long time;
  15 + int status;
  16 + for (i = 0; i < 7; i++) {
  17 + fd = open(fnames[i], O_RDONLY);
  18 + printf("File %d: %s\n", i, fnames[i]);
  19 + fflush(NULL);
  20 + if (!fd) {
  21 + printf("unable to open\n");
  22 + exit(0);
  23 + }
  24 + while(read(fd, buffer, BLOCK_SIZE));
  25 + lseek(fd, 0, SEEK_SET);
  26 + gettimeofday(&start, NULL);
  27 + for (j = 0; j < 10; j++) {
  28 + while(read(fd, buffer, BLOCK_SIZE));
  29 + lseek(fd, 0, SEEK_SET);
  30 + }
  31 + gettimeofday(&end, NULL);
  32 + time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec);
  33 + //printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec);
  34 + printf("time taken to read file # %d - %llu\n", i, time);
  35 + sync();
  36 + status = system("sudo /sbin/sysctl vm.drop_caches=3");
  37 + sync();
  38 + }
  39 +}
filesystem/file_cache.o View file @ e5cf2c6

No preview for this file type

filesystem/file_contention.c View file @ e5cf2c6
  1 +#define _GNU_SOURCE
  2 +#include <stdio.h>
  3 +#include <fcntl.h>
  4 +#include <string.h>
  5 +#include <stdlib.h>
  6 +#include <sys/time.h>
  7 +#define BLOCK_SIZE 4096
  8 +
  9 +void main()
  10 +{
  11 + char buffer[BLOCK_SIZE] __attribute__ ((__aligned__ (512)));
  12 + struct timeval start, end;
  13 + int fd=0;
  14 + int i = 0;
  15 + unsigned long long time;
  16 + int child_status;
  17 + char *fnames[] = {"file_1", "file_2", "file_3", "file_4", "file_5", "file_6",
  18 + "file_7", "file_8", "file_9"};
  19 + int numProcesses = 0;
  20 +
  21 +label:
  22 + numProcesses++;
  23 + i = 0;
  24 + printf("numProcesses: %d\n", numProcesses);
  25 + while (i < numProcesses) {
  26 + int pid = fork();
  27 + if (pid == 0) {
  28 + //printf("Opening %d %s\n", i, fnames[i]);
  29 + fd = open(fnames[i], O_RDONLY|O_DIRECT);
  30 + fflush(stdout);
  31 + if (!fd) {
  32 + printf("unable to open\n");
  33 + exit(1);
  34 + }
  35 + gettimeofday(&start, NULL);
  36 + while(1) {
  37 + int rc = read(fd, buffer, BLOCK_SIZE);
  38 + if (rc < 0) {
  39 + perror("Read Error");
  40 + exit(1);
  41 + } else if(rc == 0)
  42 + break;
  43 + }
  44 + gettimeofday(&end, NULL);
  45 + lseek(fd, 0, SEEK_SET);
  46 + time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec);
  47 + printf("time taken to read file # %d - %llu\n", i, time);
  48 + sync();
  49 + child_status = system("sudo /sbin/sysctl vm.drop_caches=3");
  50 + sync();
  51 + exit(0);
  52 + }
  53 + i++;
  54 + }
  55 + sleep(10);
  56 + wait(&child_status);
  57 + if (numProcesses < 9)
  58 + goto label;
  59 +}
filesystem/file_contention.o View file @ e5cf2c6

No preview for this file type

filesystem/file_contention_results.txt View file @ e5cf2c6
  1 +numProcesses: 1
  2 +time taken to read file # 0 - 5062940
  3 +
  4 +numProcesses: 2
  5 +time taken to read file # 0 - 8706092
  6 +time taken to read file # 1 - 8709610
  7 +
  8 +numProcesses: 3
  9 +time taken to read file # 1 - 17564676
  10 +time taken to read file # 0 - 17567700
  11 +time taken to read file # 2 - 17794753
  12 +
  13 +numProcesses: 4
  14 +time taken to read file # 3 - 62828764
  15 +time taken to read file # 1 - 62836532
  16 +time taken to read file # 2 - 63971524
  17 +time taken to read file # 0 - 64093304
  18 +
  19 +numProcesses: 5
  20 +time taken to read file # 2 - 94672605
  21 +time taken to read file # 3 - 94657470
  22 +time taken to read file # 4 - 94672584
  23 +time taken to read file # 1 - 94695710
  24 +time taken to read file # 0 - 94734890
  25 +
  26 +numProcesses: 6
  27 +time taken to read file # 3 - 123586511
  28 +time taken to read file # 4 - 123592028
  29 +time taken to read file # 5 - 123610529
  30 +time taken to read file # 2 - 123634637
  31 +time taken to read file # 1 - 123650067
  32 +time taken to read file # 0 - 123719117
  33 +
  34 +numProcesses: 7
  35 +time taken to read file # 3 - 130979653
  36 +time taken to read file # 5 - 130988397
  37 +time taken to read file # 4 - 131018646
  38 +time taken to read file # 6 - 131076657
  39 +time taken to read file # 2 - 131087578
  40 +time taken to read file # 1 - 131148520
  41 +time taken to read file # 0 - 131252054
  42 +
  43 +numProcesses: 8
  44 +time taken to read file # 5 - 122998315
  45 +time taken to read file # 4 - 123460164
  46 +time taken to read file # 6 - 123472083
  47 +time taken to read file # 3 - 123631158
  48 +time taken to read file # 2 - 123662180
  49 +time taken to read file # 7 - 123588402
  50 +time taken to read file # 1 - 123757340
  51 +time taken to read file # 0 - 123876541
  52 +
  53 +numProcesses: 9
  54 +time taken to read file # 5 - 119113816
  55 +time taken to read file # 6 - 119135478
  56 +time taken to read file # 4 - 119137892
  57 +time taken to read file # 7 - 119153935
  58 +time taken to read file # 8 - 119179846
  59 +time taken to read file # 3 - 119180982
  60 +time taken to read file # 2 - 119194995
  61 +time taken to read file # 1 - 119213404
  62 +time taken to read file # 0 - 119239878
filesystem/file_read_time.c View file @ e5cf2c6
  1 +#define _GNU_SOURCE
  2 +#include <stdio.h>
  3 +
  4 +#include <sys/types.h>
  5 +#include <sys/stat.h>
  6 +#include <fcntl.h>
  7 +#include <string.h>
  8 +#include <stdlib.h>
  9 +#include <sys/time.h>
  10 +#define BLOCK_SIZE 512
  11 +
  12 +void main()
  13 +{
  14 + char *fnames[] = {"file1", "file2", "file3", "file4", "file5", "file6", "file7"};
  15 + char buffer[BLOCK_SIZE] __attribute__ ((__aligned__ (512)));
  16 + struct timeval start, end;
  17 + int fd=0, count = 0;
  18 + int i, j;
  19 + unsigned long long time;
  20 + int status;
  21 + for (i = 0; i < 7; i++) {
  22 + count = 0; //count number of blocks
  23 + printf("File %d: %s\n", i, fnames[i]);
  24 + fflush(NULL);
  25 + fd = open(fnames[i], O_RDONLY | O_DIRECT);
  26 + if (!fd) {
  27 + printf("unable to open\n");
  28 + exit(0);
  29 + }
  30 + posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM);
  31 + printf("You are here\n");
  32 + gettimeofday(&start, NULL);
  33 + for (j = 0; j < 10; j++) {
  34 + count = 0;
  35 + while(BLOCK_SIZE == read(fd, buffer, BLOCK_SIZE)) {
  36 + count++;
  37 + }
  38 + lseek(fd, 0, SEEK_SET);
  39 + }
  40 + gettimeofday(&end, NULL);
  41 + printf("You are here2\n");
  42 + time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec);
  43 + printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec);
  44 + printf("time taken to read file # %d - %f\n", i, time/((float)count*10));
  45 +
  46 + sync();
  47 + status = system("sudo /sbin/sysctl vm.drop_caches=3");
  48 + sync();
  49 +
  50 + gettimeofday(&start, NULL);
  51 + for (j = 0; j < 1000; j++) {
  52 + pread(fd, buffer, BLOCK_SIZE, BLOCK_SIZE*(rand()%count));
  53 + }
  54 + gettimeofday(&end, NULL);
  55 + time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec);
  56 + printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec);
  57 + printf("time taken to read file # %d - %f\n", i, time/1000.0);
  58 +
  59 + sync();
  60 + status = system("sudo /sbin/sysctl vm.drop_caches=3");
  61 + sync();
  62 + }
  63 +}
filesystem/file_read_time.o View file @ e5cf2c6

No preview for this file type

filesystem/file_read_time_remote.c View file @ e5cf2c6
  1 +#define _GNU_SOURCE
  2 +#include <stdio.h>
  3 +
  4 +#include <sys/types.h>
  5 +#include <sys/stat.h>
  6 +#include <fcntl.h>
  7 +#include <string.h>
  8 +#include <stdlib.h>
  9 +#include <sys/time.h>
  10 +#define BLOCK_SIZE 512
  11 +
  12 +void main()
  13 +{
  14 + char *fnames[] = {"/mnt/file1", "/mnt/file2", "/mnt/file3", "/mnt/file4", "/mnt/file5", "/mnt/file6", "/mnt/file7"};
  15 + char buffer[BLOCK_SIZE] __attribute__ ((__aligned__ (512)));
  16 + struct timeval start, end;
  17 + int fd=0, count = 0;
  18 + int i, j;
  19 + unsigned long long time;
  20 + int status;
  21 + for (i = 0; i < 7; i++) {
  22 + count = 0; //count number of blocks
  23 + printf("File %d: %s\n", i, fnames[i]);
  24 + fflush(NULL);
  25 + fd = open(fnames[i], O_RDONLY | O_DIRECT);
  26 + if (!fd) {
  27 + printf("unable to open\n");
  28 + exit(0);
  29 + }
  30 + posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM);
  31 + printf("You are here\n");
  32 + gettimeofday(&start, NULL);
  33 + for (j = 0; j < 10; j++) {
  34 + count = 0;
  35 + while(BLOCK_SIZE == read(fd, buffer, BLOCK_SIZE)) {
  36 + count++;
  37 + }
  38 + lseek(fd, 0, SEEK_SET);
  39 + }
  40 + gettimeofday(&end, NULL);
  41 + printf("You are here2\n");
  42 + time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec);
  43 + printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec);
  44 + printf("time taken to read file # %d - %f\n", i, time/((float)count*10));
  45 +
  46 + sync();
  47 + status = system("sudo /sbin/sysctl vm.drop_caches=3");
  48 + sync();
  49 +
  50 + gettimeofday(&start, NULL);
  51 + for (j = 0; j < 1000; j++) {
  52 + pread(fd, buffer, BLOCK_SIZE, BLOCK_SIZE*(rand()%count));
  53 + }
  54 + gettimeofday(&end, NULL);
  55 + time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec);
  56 + printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec);
  57 + printf("time taken to read file # %d - %f\n", i, time/1000.0);
  58 +
  59 + sync();
  60 + status = system("sudo /sbin/sysctl vm.drop_caches=3");
  61 + sync();
  62 + }
  63 +}
filesystem/file_read_time_remote.o View file @ e5cf2c6

No preview for this file type

memory/memory_access_time.c View file @ e5cf2c6
... ... @@ -4,11 +4,11 @@
4 4  
5 5 #define KB 1024
6 6 #define MB 1024 * KB
7   -#define MAX_ARRAY_SIZE 32*MB
  7 +#define MAX_ITERATIONS 1000000
8 8 #define STRIDE_SIZE 16
9 9 #define CPU_FREQ 900
10 10  
11   -unsigned long long access_time_1(int size, int stride_size){
  11 +unsigned long long func(int size, int stride_size){
12 12 struct timeval start, end;
13 13 struct timezone tz;
14 14 unsigned long long time1, time2;
15 15  
16 16  
17 17  
18 18  
19 19  
20 20  
... ... @@ -16,35 +16,35 @@
16 16 int *array = (int *)malloc(size);
17 17 int len = (size)/sizeof(int);
18 18 unsigned int i;
19   - for(i=0; i < MAX_ARRAY_SIZE; i++) {
  19 + for(i=0; i < MAX_ITERATIONS; i++) {
20 20 array[( i * stride_size) % len] = array[( i * stride_size) % len]+i;
21 21 }
22 22  
23   - gettimeofday(&start, NULL);
24   - //asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1));
25   - for(i=0; i < MAX_ARRAY_SIZE; i++) {
  23 + //gettimeofday(&start, NULL);
  24 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1));
  25 + for(i=0; i < MAX_ITERATIONS; i++) {
26 26 j = array[( i * stride_size) % len];
27 27 }
28   - gettimeofday(&end, NULL);
29   - //asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2));
  28 + //gettimeofday(&end, NULL);
  29 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2));
30 30  
31 31 free(array);
32   - //return time2-time1;
33   - return (-start.tv_sec*1e6-start.tv_usec+end.tv_sec*1e6+end.tv_usec);
  32 + return time2 - time1;
  33 + //return (-start.tv_sec*1e6-start.tv_usec+end.tv_sec*1e6+end.tv_usec);
34 34 }
35 35  
36 36 int main()
37 37 {
38 38 int i, j;
39 39  
40   - for (j = 128; j <= 1024; j*=2) {
  40 + for (j = 16; j <= 1024; j*=2) {
41 41 printf("Stride size: %u\n", j);
42 42 for (i = 1024; i <= 32 * MB; i*=2) {
43   - unsigned long long access_time = access_time_1(i, j);
  43 + unsigned long long access_time = func(i, j);
44 44 //unsigned overhead = 10;
45 45 //multiply access time by 1000 to convert to ns
46   - //double avg = (access_time * 1.111)/(MAX_ARRAY_SIZE);
47   - double avg = (access_time * 1000.0)/(MAX_ARRAY_SIZE);
  46 + //double avg = (access_time * 1.111)/(MAX_ITERATIONS);
  47 + double avg = (access_time * 1000.0)/(MAX_ITERATIONS);
48 48 printf("Size: %uKB access: %lluus, avg: %gns\n", i >> 10, access_time, avg);
49 49 }
50 50 }
memory/memory_access_time_overhead.c View file @ e5cf2c6
  1 +#include<stdio.h>
  2 +#include <sys/time.h>
  3 +#include <stdlib.h>
  4 +
  5 +#define KB 1024
  6 +#define MB 1024 * KB
  7 +#define MAX_ITERATIONS 1000000
  8 +#define STRIDE_SIZE 16
  9 +#define CPU_FREQ 900
  10 +
  11 +unsigned long long func(int size, int stride_size){
  12 + struct timeval start, end;
  13 + struct timezone tz;
  14 + unsigned long long time1, time2;
  15 + int j;
  16 + int *array = (int *)malloc(size);
  17 + int len = (size)/sizeof(int);
  18 + unsigned int i;
  19 + for(i=0; i < MAX_ITERATIONS; i++) {
  20 + array[( i * stride_size) % len] = array[( i * stride_size) % len]+i;
  21 + }
  22 +
  23 + //gettimeofday(&start, NULL);
  24 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1));
  25 + for(i=0; i < MAX_ITERATIONS; i++) {
  26 + j = ( i * stride_size) % len;
  27 + }
  28 + //gettimeofday(&end, NULL);
  29 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2));
  30 +
  31 + free(array);
  32 + return time2 - time1;
  33 + //return (-start.tv_sec*1e6-start.tv_usec+end.tv_sec*1e6+end.tv_usec);
  34 +}
  35 +
  36 +int main()
  37 +{
  38 + int i, j;
  39 +
  40 + for (j = 16; j <= 1024; j*=2) {
  41 + printf("Stride size: %u\n", j);
  42 + for (i = 1024; i <= 32 * MB; i*=2) {
  43 + unsigned long long access_time = func(i, j);
  44 + //unsigned overhead = 10;
  45 + //multiply access time by 1000 to convert to ns
  46 + //double avg = (access_time * 1.111)/(MAX_ITERATIONS);
  47 + double avg = (access_time * 1000.0)/(MAX_ITERATIONS);
  48 + printf("Size: %uKB access: %lluus, avg: %gns\n", i >> 10, access_time, avg);
  49 + }
  50 + }
  51 + return 0;
  52 +}
memory/memory_access_time_overhead_new.o View file @ e5cf2c6

No preview for this file type

memory/pagefault.c View file @ e5cf2c6
... ... @@ -61,10 +61,11 @@
61 61 printf("User enable regr: %x\n", i);
62 62  
63 63 j = 32;
64   - for(i = 0; i < 10; i=i++){
  64 + for(i = 0; i < 10; i++){
65 65 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (s_t));
66   - c+= (addr1[i + j*4*KB]); // read at multiple of page size, so every read causes a page fault
67   - j = j*2;
  66 + c+= (addr1[i*30*MB]); // read at multiple of page size, so every read causes a page fault
  67 + //c+= (addr1[i*MB]); // read at multiple of page size, so every read causes a page fault
  68 + // j = j*2;
68 69 //c = c+1;
69 70 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (e_t));
70 71 t += (e_t - s_t);
memory/pagefault.o View file @ e5cf2c6

No preview for this file type

memory/ram_bandwidth.c View file @ e5cf2c6
... ... @@ -26,6 +26,9 @@
26 26 gettimeofday(&end, NULL);
27 27 // asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2));
28 28 //printf("%u", time2-time1);
  29 + printf("adafsd\n");
  30 + printf("Start %llu.%llu\n",start.tv_sec*1e6, start.tv_usec);
  31 + printf("End %llu.%llu\n",end.tv_sec*1e6, end.tv_usec);
29 32 printf("%llu\n",(-start.tv_sec*1e6-start.tv_usec+end.tv_sec*1e6+end.tv_usec));
30 33 }
memory/ram_bandwidth.o View file @ e5cf2c6

No preview for this file type

memory/ram_bandwidth_overhead.c View file @ e5cf2c6
... ... @@ -3,17 +3,16 @@
3 3  
4 4 #define KB 1024
5 5 #define MB 1024*KB
6   -#define SIZE 8*MB
  6 +#define SIZE 10000000
  7 +
  8 +int arr[SIZE] = {1, 2, 3, 4, 56};
  9 +
7 10 void main()
8 11 {
9   - int *arr=calloc(SIZE, sizeof(int));
10 12 unsigned time1, time2, sum=0;
11 13 struct timeval start, end;
12 14 int i;
13   - register volatile int temp;
14   - register volatile int temp2;
15   - register volatile int temp3;
16   - register volatile int temp4;
  15 + int temp, temp2, temp3, temp4;
17 16 //asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i));
18 17 //asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1));
19 18 gettimeofday(&start, NULL);
... ... @@ -26,6 +25,8 @@
26 25 gettimeofday(&end, NULL);
27 26 //asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2));
28 27 //printf("%u", time2-time1);
  28 + printf("Start %llu.%llu\n",start.tv_sec*1e6, start.tv_usec);
  29 + printf("End %llu.%llu\n",end.tv_sec*1e6, end.tv_usec);
29 30 printf("%llu\n",(-start.tv_sec*1e6-start.tv_usec+end.tv_sec*1e6+end.tv_usec));
30 31 }
memory/ram_bandwidth_overhead.o View file @ e5cf2c6

No preview for this file type

memory/sathya_mem_bw.c View file @ e5cf2c6
  1 +#include <stdio.h>
  2 +#include <sys/time.h>
  3 +#include <unistd.h>
  4 +#include <stdlib.h>
  5 +
  6 +#define KB 1024
  7 +#define MB 1024 * KB
  8 +#define CPU_FREQ 900
  9 +
  10 +// This will occupy 8 MB in memory
  11 +int array[2 * MB] = {1, 2, 3, 4, 5, 6};
  12 +
  13 +int main()
  14 +{
  15 + struct timeval start, end;
  16 + struct timezone tz;
  17 + int i, j;
  18 + double avg = 0;
  19 + register volatile temp1, temp2, temp3, temp4;
  20 + gettimeofday(&start, &tz);
  21 + for (i = 0; i < 2 * MB; i += 32) {
  22 + temp1 = array[i];
  23 + temp2 = array[i + 8];
  24 + temp3 = array[i + 16];
  25 + temp4 = array[i + 24];
  26 + /* temp2 = array[i + MB];
  27 + temp3 = array[i + 8];
  28 + temp4 = array[i + 8 + MB];
  29 + temp5 = array[i + 16];
  30 + temp6 = array[i + 16 + MB];
  31 + temp7 = array[i + 24];
  32 + temp8 = array[i + 24 + MB];
  33 + */
  34 + }
  35 + gettimeofday(&end, &tz);
  36 + double delta_time = (end.tv_sec*1e6 + end.tv_usec) - (start.tv_sec*1e6 + start.tv_usec);
  37 + double bw = 8 * MB;
  38 + double overhead = (33 * 1000)/900;
  39 + double time_taken = (delta_time * 1000);
  40 + printf("delta_time: %g, overhead: %g\n", delta_time, overhead);
  41 + printf("Bandwidth: %gMBps\n", (bw * 1.0)/time_taken);
  42 + avg += (bw * 1.0)/time_taken;
  43 + return 0;
  44 +}
memory/sathya_mem_bw.o View file @ e5cf2c6

No preview for this file type

memory/sathya_mem_bw_wr.o View file @ e5cf2c6

No preview for this file type

memory/sathya_mem_overhead.c View file @ e5cf2c6
  1 +#include <stdio.h>
  2 +#include <sys/time.h>
  3 +#include <unistd.h>
  4 +#include <stdlib.h>
  5 +
  6 +#define KB 1024
  7 +#define MB 1024 * KB
  8 +#define CPU_FREQ 900
  9 +
  10 +// This will occupy 8 MB in memory
  11 +int array[2 * MB] = {1, 2, 3, 4, 5, 6};
  12 +
  13 +int main()
  14 +{
  15 + struct timeval start, end;
  16 + struct timezone tz;
  17 + int i, j;
  18 + double avg = 0;
  19 + register volatile temp1, temp2, temp3, temp4;
  20 + gettimeofday(&start, &tz);
  21 + for (i = 0; i < 2 * MB; i += 32) {
  22 + temp1 = i;
  23 + temp2 = i + 8;
  24 + temp3 = i + 16;
  25 + temp4 = i + 24;
  26 + /* temp2 = array[i + MB];
  27 + temp3 = array[i + 8];
  28 + temp4 = array[i + 8 + MB];
  29 + temp5 = array[i + 16];
  30 + temp6 = array[i + 16 + MB];
  31 + temp7 = array[i + 24];
  32 + temp8 = array[i + 24 + MB];
  33 + */
  34 + }
  35 + gettimeofday(&end, &tz);
  36 + double delta_time = (end.tv_sec*1e6 + end.tv_usec) - (start.tv_sec*1e6 + start.tv_usec);
  37 + double bw = 8 * MB;
  38 + double overhead = (33 * 1000)/900;
  39 + double time_taken = (delta_time * 1000);
  40 + printf("delta_time: %g, overhead: %g\n", delta_time, overhead);
  41 + printf("Bandwidth: %gMBps\n", (bw * 1.0)/time_taken);
  42 + avg += (bw * 1.0)/time_taken;
  43 + return 0;
  44 +}
memory/sathya_mem_overhead.o View file @ e5cf2c6

No preview for this file type

memory/thd_ctx_mtx.o View file @ e5cf2c6

No preview for this file type

memory/thd_ctxsw.o View file @ e5cf2c6

No preview for this file type