Commit 5d73e140efe98d0362bf49cf7caafe3ad1858f9c

Authored by Aravind Kumar
1 parent c12e3e15c4
Exists in master

filesystem and memory latest

Showing 19 changed files with 267 additions and 9 deletions Side-by-side Diff

filesystem/file_cache.c View file @ 5d73e14
  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 fname[10]="file";
  10 + char *fno[] = {"1", "2", "3", "4", "5", "6", "7"};
  11 + char *file;
  12 + char buffer[BLOCK_SIZE];
  13 + struct timeval start, end;
  14 + int fd=0;
  15 + int i, j;
  16 + unsigned long long time;
  17 + int status;
  18 + for (i = 0; i < 7; i++) {
  19 + file = strcat(fname, fno[i]);
  20 + printf("File %d: %s\n", i, file);
  21 + fflush(NULL);
  22 + fd = open(file, O_RDONLY);
  23 + if (!fd) {
  24 + printf("unable to open\n");
  25 + exit(0);
  26 + }
  27 + while(read(fd, buffer, BLOCK_SIZE));
  28 + lseek(fd, 0, SEEK_SET);
  29 + gettimeofday(&start, NULL);
  30 + for (j = 0; j < 10; j++) {
  31 + while(read(fd, buffer, BLOCK_SIZE));
  32 + lseek(fd, 0, SEEK_SET);
  33 + }
  34 + gettimeofday(&end, NULL);
  35 + time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec);
  36 + printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec);
  37 + printf("time taken to read file # %d - %llu\n", i, time);
  38 + sync();
  39 + status = system("sudo /sbin/sysctl vm.drop_caches=3");
  40 + sync();
  41 + strcpy(fname, "file");
  42 + }
  43 +
  44 +
  45 +}
filesystem/file_cache.o View file @ 5d73e14

No preview for this file type

filesystem/file_contention.c View file @ 5d73e14
  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 1024
  8 +void main()
  9 +{
  10 + char fname[10]="file_";
  11 + char buffer[BLOCK_SIZE] __attribute__ ((__aligned__ (512)));
  12 + struct timeval start, end;
  13 + int fd=0;
  14 + char *file;
  15 + int i = 0;
  16 + unsigned long long time;
  17 + int status;
  18 + char *names[] = {"1", "2", "3", "4", "5", "6", "7"};
  19 + while (i < 7) {
  20 + int pid = fork();
  21 + if (pid == 0) {
  22 + file = strcat(fname, names[i]);
  23 + fd = open(fname, O_RDONLY | O_DIRECT);
  24 + if (!fd) {
  25 + printf("unable to open\n");
  26 + exit(0);
  27 + }
  28 + printf("accessing %n", file);
  29 + sleep(2);
  30 + gettimeofday(&start, NULL);
  31 + while(read(fd, buffer, BLOCK_SIZE));
  32 + gettimeofday(&end, NULL);
  33 + lseek(fd, 0, SEEK_SET);
  34 + time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec);
  35 + // printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec);
  36 + printf("time taken to read file # %d - %llu\n", i, time);
  37 + sync();
  38 + status = system("sudo /sbin/sysctl vm.drop_caches=3");
  39 + sync();
  40 + exit(0);
  41 + }
  42 + i++;
  43 + }
  44 + sleep(10);
  45 + wait(&status);
  46 +}
filesystem/file_contention.o View file @ 5d73e14

No preview for this file type

filesystem/file_read_time.c View file @ 5d73e14
  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 +void main()
  12 +{
  13 + char fname[20]="/mnt/file_";
  14 + char *fno[] = {"1", "2", "3", "4", "5", "6", "7"};
  15 + char *file;
  16 + char buffer[BLOCK_SIZE] __attribute__ ((__aligned__ (512)));
  17 + struct timeval start, end;
  18 + int fd=0, count = 0;
  19 + int i, j;
  20 + unsigned long long time;
  21 + int status;
  22 + for (i = 0; i < 7; i++) {
  23 + count = 0;
  24 + file = strcat(fname, fno[i]);
  25 + printf("File %d: %s\n", i, file);
  26 + fflush(NULL);
  27 + //fd = open(file, O_RDONLY);
  28 + fd = open(file, O_RDONLY | O_DIRECT | O_SYNC);
  29 + if (!fd) {
  30 + printf("unable to open\n");
  31 + exit(0);
  32 + }
  33 + posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM);
  34 + // while(read(fd, buffer, BLOCK_SIZE)){
  35 + // count++;
  36 + // }
  37 +// lseek(fd, 0, SEEK_SET);
  38 + printf("You are here\n");
  39 + gettimeofday(&start, NULL);
  40 + for (j = 0; j < 10; j++) {
  41 + count = 0;
  42 + while(BLOCK_SIZE == read(fd, buffer, BLOCK_SIZE)) {
  43 + count++;
  44 + }
  45 + lseek(fd, 0, SEEK_SET);
  46 + }
  47 + gettimeofday(&end, NULL);
  48 + printf("You are here2\n");
  49 + time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec);
  50 + printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec);
  51 + printf("time taken to read file # %d - %f\n", i, time/((float)count*10));
  52 +
  53 +
  54 + sync();
  55 + status = system("sudo /sbin/sysctl vm.drop_caches=3");
  56 + sync();
  57 +
  58 + gettimeofday(&start, NULL);
  59 + for (j = 0; j < 1000; j++) {
  60 + pread(fd, buffer, BLOCK_SIZE, BLOCK_SIZE*(rand()%count));
  61 + }
  62 + gettimeofday(&end, NULL);
  63 + time = (end.tv_sec*1e6+end.tv_usec) - (start.tv_sec*1e6+start.tv_usec);
  64 + printf("timestamp %llu - %llu\n", end.tv_sec*1e6+end.tv_usec, start.tv_sec*1e6+start.tv_usec);
  65 + printf("time taken to read file # %d - %f\n", i, time/1000.0);
  66 +
  67 + sync();
  68 + status = system("sudo /sbin/sysctl vm.drop_caches=3");
  69 + sync();
  70 + strcpy(fname, "/mnt/file_");
  71 + }
  72 +
  73 +
  74 +}
filesystem/file_read_time.o View file @ 5d73e14

No preview for this file type

memory/pagefault.c View file @ 5d73e14
... ... @@ -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 @ 5d73e14

No preview for this file type

memory/ram_bandwidth.c View file @ 5d73e14
... ... @@ -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 @ 5d73e14

No preview for this file type

memory/ram_bandwidth_overhead.c View file @ 5d73e14
... ... @@ -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 @ 5d73e14

No preview for this file type

memory/sathya_mem_bw.c View file @ 5d73e14
  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 @ 5d73e14

No preview for this file type

memory/sathya_mem_bw_wr.o View file @ 5d73e14

No preview for this file type

memory/sathya_mem_overhead.c View file @ 5d73e14
  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 @ 5d73e14

No preview for this file type

memory/thd_ctx_mtx.o View file @ 5d73e14

No preview for this file type

memory/thd_ctxsw.o View file @ 5d73e14

No preview for this file type