Commit 5d73e140efe98d0362bf49cf7caafe3ad1858f9c
1 parent
c12e3e15c4
Exists in
master
filesystem and memory latest
Showing 19 changed files with 267 additions and 9 deletions Inline Diff
- filesystem/file_cache.c
- filesystem/file_cache.o
- filesystem/file_contention.c
- filesystem/file_contention.o
- filesystem/file_read_time.c
- filesystem/file_read_time.o
- memory/pagefault.c
- memory/pagefault.o
- memory/ram_bandwidth.c
- memory/ram_bandwidth.o
- memory/ram_bandwidth_overhead.c
- memory/ram_bandwidth_overhead.o
- memory/sathya_mem_bw.c
- memory/sathya_mem_bw.o
- memory/sathya_mem_bw_wr.o
- memory/sathya_mem_overhead.c
- memory/sathya_mem_overhead.o
- memory/thd_ctx_mtx.o
- memory/thd_ctxsw.o
filesystem/file_cache.c
View file @
5d73e14
File was created | 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 |
filesystem/file_cache.o
View file @
5d73e14
filesystem/file_contention.c
View file @
5d73e14
File was created | 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
filesystem/file_read_time.c
View file @
5d73e14
File was created | 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(); |
filesystem/file_read_time.o
View file @
5d73e14
memory/pagefault.c
View file @
5d73e14
#include <stdio.h> | 1 | 1 | #include <stdio.h> | |
#include <stdlib.h> | 2 | 2 | #include <stdlib.h> | |
#include <errno.h> | 3 | 3 | #include <errno.h> | |
#include <unistd.h> | 4 | 4 | #include <unistd.h> | |
#include <stdlib.h> | 5 | 5 | #include <stdlib.h> | |
#include <sys/mman.h> | 6 | 6 | #include <sys/mman.h> | |
#include <sys/stat.h> | 7 | 7 | #include <sys/stat.h> | |
#include <fcntl.h> | 8 | 8 | #include <fcntl.h> | |
9 | 9 | |||
#define KB 1024 | 10 | 10 | #define KB 1024 | |
#define MB 1024 * KB | 11 | 11 | #define MB 1024 * KB | |
#define GB 1024 * MB | 12 | 12 | #define GB 1024 * MB | |
#define SIZE_OF_MEMORY 839*MB // Main memory size | 13 | 13 | #define SIZE_OF_MEMORY 839*MB // Main memory size | |
#define CPU_FREQ 900000.0 | 14 | 14 | #define CPU_FREQ 900000.0 | |
#define ITERATIONS 1024.0*1024.0 | 15 | 15 | #define ITERATIONS 1024.0*1024.0 | |
#define handle_error(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) | 16 | 16 | #define handle_error(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) | |
17 | 17 | |||
18 | 18 | |||
int main(int argc, char *argv[]){ | 19 | 19 | int main(int argc, char *argv[]){ | |
20 | 20 | |||
int fd1, fd2; | 21 | 21 | int fd1, fd2; | |
char *addr1, *addr2; | 22 | 22 | char *addr1, *addr2; | |
register volatile int c=0; | 23 | 23 | register volatile int c=0; | |
int i, j; | 24 | 24 | int i, j; | |
unsigned s_t, e_t, t=0; | 25 | 25 | unsigned s_t, e_t, t=0; | |
26 | 26 | |||
if (argc != 3){ | 27 | 27 | if (argc != 3){ | |
printf("usage: a.out <file1> <file2> \n"); | 28 | 28 | printf("usage: a.out <file1> <file2> \n"); | |
exit(EXIT_FAILURE); | 29 | 29 | exit(EXIT_FAILURE); | |
} | 30 | 30 | } | |
31 | 31 | |||
if ((fd1 = open(argv[1], O_RDONLY)) == -1){ | 32 | 32 | if ((fd1 = open(argv[1], O_RDONLY)) == -1){ | |
//handle_error("open"); | 33 | 33 | //handle_error("open"); | |
printf("exit fd1\n"); | 34 | 34 | printf("exit fd1\n"); | |
exit(0); | 35 | 35 | exit(0); | |
} | 36 | 36 | } | |
37 | 37 | |||
if ((fd2 = open(argv[2], O_RDONLY)) == -1){ | 38 | 38 | if ((fd2 = open(argv[2], O_RDONLY)) == -1){ | |
//handle_error("open"); | 39 | 39 | //handle_error("open"); | |
printf("exit fd2\n"); | 40 | 40 | printf("exit fd2\n"); | |
exit(0); | 41 | 41 | exit(0); | |
} | 42 | 42 | } | |
43 | 43 | |||
posix_fadvise(fd1, 0, 0, POSIX_FADV_RANDOM); | 44 | 44 | posix_fadvise(fd1, 0, 0, POSIX_FADV_RANDOM); | |
posix_fadvise(fd2, 0, 0, POSIX_FADV_RANDOM); | 45 | 45 | posix_fadvise(fd2, 0, 0, POSIX_FADV_RANDOM); | |
46 | 46 | |||
addr1 = (char *) mmap(0, SIZE_OF_MEMORY, PROT_READ, MAP_PRIVATE | MAP_POPULATE, fd1, 0); | 47 | 47 | addr1 = (char *) mmap(0, SIZE_OF_MEMORY, PROT_READ, MAP_PRIVATE | MAP_POPULATE, fd1, 0); | |
if (addr1 == MAP_FAILED){ | 48 | 48 | if (addr1 == MAP_FAILED){ | |
printf("mmap1 %d %s", errno, strerror(errno)); | 49 | 49 | printf("mmap1 %d %s", errno, strerror(errno)); | |
exit(0); | 50 | 50 | exit(0); | |
} | 51 | 51 | } | |
addr2 = (char *) mmap(0, SIZE_OF_MEMORY, PROT_READ, MAP_PRIVATE | MAP_POPULATE, fd2, 0); | 52 | 52 | addr2 = (char *) mmap(0, SIZE_OF_MEMORY, PROT_READ, MAP_PRIVATE | MAP_POPULATE, fd2, 0); | |
if (addr2 == MAP_FAILED){ | 53 | 53 | if (addr2 == MAP_FAILED){ | |
printf("mmap2 %d %s", errno, strerror(errno)); | 54 | 54 | printf("mmap2 %d %s", errno, strerror(errno)); | |
exit(0); | 55 | 55 | exit(0); | |
} | 56 | 56 | } | |
57 | 57 | |||
madvise(addr1, 0, MADV_RANDOM); | 58 | 58 | madvise(addr1, 0, MADV_RANDOM); | |
madvise(addr2, 0, MADV_RANDOM); | 59 | 59 | madvise(addr2, 0, MADV_RANDOM); | |
asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i)); | 60 | 60 | asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i)); | |
printf("User enable regr: %x\n", i); | 61 | 61 | printf("User enable regr: %x\n", i); | |
62 | 62 | |||
j = 32; | 63 | 63 | j = 32; | |
for(i = 0; i < 10; i=i++){ | 64 | 64 | for(i = 0; i < 10; i++){ | |
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (s_t)); | 65 | 65 | asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (s_t)); | |
c+= (addr1[i + j*4*KB]); // read at multiple of page size, so every read causes a page fault | 66 | 66 | c+= (addr1[i*30*MB]); // read at multiple of page size, so every read causes a page fault | |
j = j*2; | 67 | 67 | //c+= (addr1[i*MB]); // read at multiple of page size, so every read causes a page fault | |
68 | // j = j*2; | |||
//c = c+1; | 68 | 69 | //c = c+1; | |
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (e_t)); | 69 | 70 | asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (e_t)); | |
t += (e_t - s_t); | 70 | 71 | t += (e_t - s_t); |
memory/pagefault.o
View file @
5d73e14
memory/ram_bandwidth.c
View file @
5d73e14
#include <stdio.h> | 1 | 1 | #include <stdio.h> | |
#include <stdlib.h> | 2 | 2 | #include <stdlib.h> | |
3 | 3 | |||
#define KB 1024 | 4 | 4 | #define KB 1024 | |
#define MB 1024*KB | 5 | 5 | #define MB 1024*KB | |
#define SIZE 8*MB | 6 | 6 | #define SIZE 8*MB | |
void main() | 7 | 7 | void main() | |
{ | 8 | 8 | { | |
int *arr=calloc(SIZE, sizeof(int)); | 9 | 9 | int *arr=calloc(SIZE, sizeof(int)); | |
unsigned time1, time2, sum=0; | 10 | 10 | unsigned time1, time2, sum=0; | |
struct timeval start, end; | 11 | 11 | struct timeval start, end; | |
int i; | 12 | 12 | int i; | |
register volatile int temp; | 13 | 13 | register volatile int temp; | |
register volatile int temp2; | 14 | 14 | register volatile int temp2; | |
register volatile int temp3; | 15 | 15 | register volatile int temp3; | |
register volatile int temp4; | 16 | 16 | register volatile int temp4; | |
// asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i)); | 17 | 17 | // asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i)); | |
// asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1)); | 18 | 18 | // asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1)); | |
gettimeofday(&start, NULL); | 19 | 19 | gettimeofday(&start, NULL); | |
for (i = 0; i < SIZE/4; i=i+8) { | 20 | 20 | for (i = 0; i < SIZE/4; i=i+8) { | |
temp = arr[i]; | 21 | 21 | temp = arr[i]; | |
temp2 = arr[i+(SIZE/4)]; | 22 | 22 | temp2 = arr[i+(SIZE/4)]; | |
temp3 = arr[i+(SIZE/2)]; | 23 | 23 | temp3 = arr[i+(SIZE/2)]; | |
temp4 = arr[i+(3*SIZE/4)]; | 24 | 24 | temp4 = arr[i+(3*SIZE/4)]; | |
} | 25 | 25 | } | |
gettimeofday(&end, NULL); | 26 | 26 | gettimeofday(&end, NULL); | |
// asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2)); | 27 | 27 | // asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2)); | |
//printf("%u", time2-time1); | 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); | |||
printf("%llu\n",(-start.tv_sec*1e6-start.tv_usec+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)); |
memory/ram_bandwidth.o
View file @
5d73e14
memory/ram_bandwidth_overhead.c
View file @
5d73e14
#include <stdio.h> | 1 | 1 | #include <stdio.h> | |
#include <stdlib.h> | 2 | 2 | #include <stdlib.h> | |
3 | 3 | |||
#define KB 1024 | 4 | 4 | #define KB 1024 | |
#define MB 1024*KB | 5 | 5 | #define MB 1024*KB | |
#define SIZE 8*MB | 6 | 6 | #define SIZE 10000000 | |
7 | ||||
8 | int arr[SIZE] = {1, 2, 3, 4, 56}; | |||
9 | ||||
void main() | 7 | 10 | void main() | |
{ | 8 | 11 | { | |
int *arr=calloc(SIZE, sizeof(int)); | 9 | |||
unsigned time1, time2, sum=0; | 10 | 12 | unsigned time1, time2, sum=0; | |
struct timeval start, end; | 11 | 13 | struct timeval start, end; | |
int i; | 12 | 14 | int i; | |
register volatile int temp; | 13 | 15 | int temp, temp2, temp3, temp4; | |
register volatile int temp2; | 14 | |||
register volatile int temp3; | 15 | |||
register volatile int temp4; | 16 | |||
//asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i)); | 17 | 16 | //asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i)); | |
//asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1)); | 18 | 17 | //asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1)); | |
gettimeofday(&start, NULL); | 19 | 18 | gettimeofday(&start, NULL); | |
for (i = 0; i < SIZE/4; i=i+8) { | 20 | 19 | for (i = 0; i < SIZE/4; i=i+8) { | |
temp = i; | 21 | 20 | temp = i; | |
temp2 = i+(SIZE/4); | 22 | 21 | temp2 = i+(SIZE/4); | |
temp3 = i+(SIZE/2); | 23 | 22 | temp3 = i+(SIZE/2); | |
temp4 = i+(3*SIZE/4); | 24 | 23 | temp4 = i+(3*SIZE/4); | |
} | 25 | 24 | } | |
gettimeofday(&end, NULL); | 26 | 25 | gettimeofday(&end, NULL); | |
//asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2)); | 27 | 26 | //asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2)); | |
//printf("%u", time2-time1); | 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); | |||
printf("%llu\n",(-start.tv_sec*1e6-start.tv_usec+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 | } | |
31 | 32 |
memory/ram_bandwidth_overhead.o
View file @
5d73e14
memory/sathya_mem_bw.c
View file @
5d73e14
File was created | 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); |
memory/sathya_mem_bw.o
View file @
5d73e14
memory/sathya_mem_bw_wr.o
View file @
5d73e14
memory/sathya_mem_overhead.c
View file @
5d73e14
File was created | 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); |
memory/sathya_mem_overhead.o
View file @
5d73e14
memory/thd_ctx_mtx.o
View file @
5d73e14
memory/thd_ctxsw.o
View file @
5d73e14