-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
86 lines (72 loc) · 1.8 KB
/
Copy pathmain.c
File metadata and controls
86 lines (72 loc) · 1.8 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#include <omp.h>
#include "main.h"
#include "cpu_funcs.h"
#include "mpi_funcs.h"
extern MPI_Datatype mutant_type;
extern MPI_Datatype program_data_type;
int main(int argc, char* argv[])
{
int pid; // rank of process
int num_processes; // number of processes
double time;
cuda_percentage = -1;
MPI_Init(&argc, &argv); // start MPI
MPI_Comm_rank(MPI_COMM_WORLD, &pid); // get process rank
MPI_Comm_size(MPI_COMM_WORLD, &num_processes); // get number of processes
// create mpi datatypes
program_data_type_initiate();
mutant_type_initiate();
omp_set_num_threads(THREADS_COUNT);
if (argc == 2)
{
cuda_percentage = atoi(argv[1]);
if (cuda_percentage == -100)
{
omp_set_num_threads(1);
cuda_percentage = 0;
}
if (cuda_percentage < 0 || cuda_percentage > 100)
{
cuda_percentage = -1;
}
}
time = initiate_program(pid, num_processes);
if (pid == ROOT)
printf("total time: %g\n", time);
// free mpi's datatypes
mpi_free_type(&program_data_type);
mpi_free_type(&mutant_type);
MPI_Finalize();
return 0;
}
void sequences_generator()
{
time_t t;
FILE* f = fopen("t.txt", "w");
srand((unsigned) time(&t));
int first = rand() % SEQ1_MAX_LEN;
int second;
do {
second = rand() % SEQ2_MAX_LEN;
} while (second >= first);
int count = 0;
char c;
while (count< first)
{
c = FIRST_CHAR + rand() % NUM_CHARS;
fprintf(f, "%c", c);
count++;
}
fprintf(f, "\n");
count=0;
while (count< second)
{
c = FIRST_CHAR + rand() % NUM_CHARS;
fprintf(f, "%c", c);
count++;
}
fclose(f);
}