Skip to content

Commit 7a4fd91

Browse files
author
Nesterov Alexander
committed
Check warnings
1 parent aa029b0 commit 7a4fd91

File tree

5 files changed

+40
-30
lines changed

5 files changed

+40
-30
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ script:
2525
- mpirun -np 4 ./modules/task_1/Yakovlev_Pavel_mul_vect/Yakovlev_Pavel_mul_vect 100000
2626
- mpirun -np 4 ./modules/task_1/Perov_Dima_task1_SumElVect/Perov_Dima_task1_SumElVect 10000
2727
- mpirun -np 4 ./modules/task_1/vikhrev_array_sum/vikhrev_array_sum 10 10
28-
- mpirun -np 4 ./modules/task_1/Vdovin_Eugene_task1_NumWords/Vdovin_Eugene_task1_NumWords 300000000
28+
- mpirun -np 4 ./modules/task_1/Vdovin_Eugene_task1_NumWords/Vdovin_Eugene_task1_NumWords 3000000

CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,14 @@ if( MPI_FOUND )
77
include_directories( ${MPI_INCLUDE_PATH} )
88
endif( MPI_FOUND )
99

10+
if ( UNIX )
11+
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
12+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
13+
endif( UNIX )
14+
15+
if ( MSVC )
16+
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} /WX")
17+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
18+
endif( MSVC )
19+
1020
add_subdirectory(modules)

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ build_script:
4949
- cmd: mpiexec.exe -np 4 modules\task_1\Perov_Dima_task1_SumElVect\%configuration%\Perov_Dima_task1_SumElVect.exe 10000
5050
- cmd: mpiexec.exe -np 4 modules\task_1\vikhrev_array_sum\%configuration%\vikhrev_array_sum.exe 10 10
5151
- cmd: mpiexec.exe -np 4 modules\task_1\Yakovlev_Pavel_mul_vect\%configuration%\Yakovlev_Pavel_mul_vect.exe 100000
52-
- cmd: mpiexec.exe -np 4 modules\task_1\Vdovin_Eugene_task1_NumWords\%configuration%\Vdovin_Eugene_task1_NumWords.exe 300000000
52+
- cmd: mpiexec.exe -np 4 modules\task_1\Vdovin_Eugene_task1_NumWords\%configuration%\Vdovin_Eugene_task1_NumWords.exe 3000000

modules/task_1/vikhrev_array_sum/array_sum.cpp

+23-23
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
#define OutputSize 26
99

1010
int main(int argc, char* argv[])
11-
{
11+
{
1212
// mpi variables
1313
int status, rank, size, nProc = 0;
14-
double t1, t2;
14+
double t1 = 0, t2 = 0;
1515
//usual variables
1616
int cols,
1717
rows,
1818
arrSize,
1919
N; // number of elems that will be given to one process
20-
double *arr, //matrix
20+
double *arr = NULL, //matrix
2121
*buff, // buffer for messages
2222
partialSum = 0,
2323
arrSum = 0;
24-
24+
2525
//read argv
2626
if (argc > 2)
2727
{
@@ -34,27 +34,27 @@ int main(int argc, char* argv[])
3434

3535
//mpi part
3636
status = MPI_Init(&argc, &argv);
37-
assert(status == MPI_SUCCESS);
37+
if (status != MPI_SUCCESS) { return -1; }
3838

3939
status = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
40-
assert(status == MPI_SUCCESS);
40+
if (status != MPI_SUCCESS) { return -1; }
4141

4242
status = MPI_Comm_size(MPI_COMM_WORLD, &size);
43-
assert(status == MPI_SUCCESS);
43+
if (status != MPI_SUCCESS) { return -1; }
44+
45+
if (size > 64) return -1; // limit
4446

45-
if (size > 64) return -1; // limit
46-
4747
nProc = (arrSize >= size) ? size : arrSize;
4848
N = arrSize / nProc;
49-
49+
5050
if (rank == MainProc) // sending
51-
{
51+
{
5252
//init arr
5353
arr = new double[arrSize];
5454
std::srand((unsigned)time(NULL));
5555
for (int i = 0; i < arrSize; i++)
5656
arr[i] = (std::rand()%100)/100.0;
57-
57+
5858
if (arrSize < OutputSize)
5959
{
6060
for (int i = 0; i < arrSize; i++)
@@ -66,23 +66,23 @@ int main(int argc, char* argv[])
6666
}
6767
std::cout << std::endl;
6868
buff = arr;
69-
69+
7070
//sequential part
71-
t1 = MPI_Wtime();
71+
t1 = MPI_Wtime();
7272
for (int i = 0; i < arrSize; i++)
7373
arrSum += arr[i];
7474
t2 = MPI_Wtime();
7575
std::cout << "Sequential Time: " << t2 - t1 << std::endl;
7676
std::cout << "Sequential Sum = " << arrSum << std::endl;
7777
//end sequential part
78-
79-
t1 = MPI_Wtime(); // start
78+
79+
t1 = MPI_Wtime(); // start
8080
for (int i = 1; i < nProc - 1; i++)
8181
status = MPI_Send(&arr[i*N], N, MPI_DOUBLE, i, i, MPI_COMM_WORLD);
8282

8383
if (size != 1) // sending last part separately in case if arrSize % size != 0
8484
MPI_Send(&arr[N*(nProc - 1)], arrSize - N * (nProc - 1), MPI_DOUBLE, nProc - 1, nProc - 1, MPI_COMM_WORLD);
85-
85+
8686

8787
}
8888
else //receiving
@@ -100,16 +100,16 @@ int main(int argc, char* argv[])
100100
}
101101
}
102102

103-
//common part
103+
//common part
104104
for (int i = 0; i < N; i++)
105105
partialSum += buff[i];
106-
106+
107107
//sum
108108
if (rank == MainProc)
109-
{
109+
{
110110
arrSum = 0;
111111
arrSum += partialSum;
112-
112+
113113
for (int i = 1; i < size; i++)
114114
{
115115
MPI_Recv(&partialSum, 1, MPI_DOUBLE, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
@@ -124,14 +124,14 @@ int main(int argc, char* argv[])
124124
{
125125
MPI_Send(&partialSum, 1, MPI_DOUBLE, MainProc, 0, MPI_COMM_WORLD);
126126
}
127-
127+
128128
//del
129129
if (rank == 0)
130130
delete[] arr;
131131
else
132132
delete[] buff;
133133

134134
status = MPI_Finalize();
135-
assert(status == MPI_SUCCESS);
135+
if (status != MPI_SUCCESS) { return -1; }
136136
return 0;
137137
}

modules/test_task/main.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ int main (int argc, char* argv[])
66
{
77
int status, rank, size;
88
status = MPI_Init (&argc, &argv);
9-
assert(status == MPI_SUCCESS);
9+
if (status != MPI_SUCCESS) { return -1; }
1010

1111
status = MPI_Comm_rank (MPI_COMM_WORLD, &rank);
12-
assert(status == MPI_SUCCESS);
12+
if (status != MPI_SUCCESS) { return -1; }
1313

1414
status = MPI_Comm_size (MPI_COMM_WORLD, &size);
15-
assert(status == MPI_SUCCESS);
15+
if (status != MPI_SUCCESS) { return -1; }
1616

1717
std::cout << "Process #" << rank << '\n';
1818
std::cout << "Count process: " << size << '\n';
1919

2020
status = MPI_Finalize();
21-
assert(status == MPI_SUCCESS);
22-
21+
if (status != MPI_SUCCESS) { return -1; }
22+
2323
return 0;
2424
}

0 commit comments

Comments
 (0)