forked from diku-dk/hpps-e2022-pub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsumbytes-par-n.c
52 lines (40 loc) · 887 Bytes
/
sumbytes-par-n.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "util.h"
#include "csapp.h"
struct thread_arg {
// TODO
int dummy;
};
void* thread_fn(void *p) {
// TODO
int dummy;
}
int main(int argc, char* argv[]) {
if (argc != 2) {
fprintf(stderr, "Usage: %s <infile>\n", argv[0]);
exit(1);
}
const char *fname = argv[1];
double file_bef = seconds();
long size;
unsigned char *bytes = read_file(fname, &size);
assert(bytes != NULL);
double file_aft = seconds();
printf("I/O: %fs\n", file_aft-file_bef);
double sum_bef = seconds();
int sum = 0;
for (int i = 0; i < size; i++) {
// TODO - launch threads
assert(0);
}
for (int i = 0; i < size; i++) {
// TODO - join threads
assert(0);
}
double sum_aft = seconds();
printf("Summing: %fs\n", sum_aft-sum_bef);
printf("Result: %d\n", sum);
free(bytes);
}