Skip to content

Commit 0fc150e

Browse files
committed
Added seq module
1 parent 676b86b commit 0fc150e

File tree

8 files changed

+102
-8
lines changed

8 files changed

+102
-8
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ script:
5555
- python scripts/lint.py
5656
- mkdir build
5757
- cd build
58-
- cmake -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STD=ON -D USE_LATEX=ON -D CMAKE_BUILD_TYPE=RELEASE ..
58+
- cmake -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STD=ON -D USE_LATEX=ON -D CMAKE_BUILD_TYPE=RELEASE ..
5959
- cmake --build . --config -j4
6060
- cd ..
6161
- export OMP_NUM_THREADS=4

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ endif( USE_MPI )
3030

3131
############################### OpenMP ##############################
3232
option(USE_OMP OFF)
33-
if( USE_OMP )
33+
if( USE_OMP OR USE_SEQ )
3434
find_package( OpenMP )
3535
if( OpenMP_FOUND )
3636
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
@@ -39,7 +39,7 @@ if( USE_OMP )
3939
else( OpenMP_FOUND )
4040
set( USE_OMP OFF )
4141
endif( OpenMP_FOUND )
42-
endif( USE_OMP )
42+
endif( USE_OMP OR USE_SEQ )
4343

4444
############################ std::thread ############################
4545
option(USE_STD OFF)

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[![Build Status](https://travis-ci.com/learning-process/parallel_programming_course.svg?branch=master)](https://travis-ci.com/learning-process/parallel_programming_course)
2-
[![Build status](https://ci.appveyor.com/api/projects/status/t46nd9gyt7iirdy8/branch/master?svg=true)](https://ci.appveyor.com/project/allnes/parallel-programming-course/branch/master)
1+
[![Build Status](https://travis-ci.com/allnes/pp_2020_spring.svg?branch=master)](https://travis-ci.com/allnes/pp_2020_spring)
2+
[![Build status](https://ci.appveyor.com/api/projects/status/ofu3hvr28bwp44vg/branch/master?svg=true)](https://ci.appveyor.com/project/allnes/pp-2020-spring/branch/master)
33

44
# Parallel programming course
55

@@ -84,10 +84,11 @@ Navigate to a source code folder.
8484

8585
```
8686
mkdir build && cd build
87-
cmake -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STD=ON -D USE_LATEX=ON ..
87+
cmake -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STD=ON -D USE_LATEX=ON ..
8888
```
8989
*Help on CMake keys:*
90-
- `-D USE_MPI=ON` enbale `MPI` labs.
90+
- `-D USE_SEQ=ON` enable `Sequential` labs (based on OpenMP's CMakeLists.txt).
91+
- `-D USE_MPI=ON` enable `MPI` labs.
9192
- `-D USE_OMP=ON` enable `OpenMP` labs.
9293
- `-D USE_TBB=ON` enable `TBB` labs.
9394
- `-D USE_STD=ON` enable `std::thread` labs.
@@ -106,7 +107,7 @@ Navigate to a source code folder.
106107
## 3. How to submit you work
107108
* There are `task_1`, `task_2`, `task_3`, `reports` folders in `modules` directory. There are 3 task and 1 report for the semester. Move to a folder of your task. Make a directory named `<last name>_<first letter of name>_<short task name>`. Example: `task1/nesterov_a_vector_sum`.
108109
* Go into the newly created folder and begin you work on the task. There must be only 4 files and 3 of them must be written by you:
109-
- `main.cpp` - google tests for the task. The number of tests must be 4 or greater.
110+
- `main.cpp` - google tests for the task. The number of tests must be 5 or greater.
110111
- `vector_sum.h` - a header file with function prototypes, name it in the same way as `<short task name>`.
111112
- `vector_sum.cpp` - the task implementation, name it in the same way as `<short task name>`.
112113
- `CMakeLists.txt` - a file to configure your project. Examples for each configuration can be found in `test_tasks`.

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ build_script:
2929
- cmd: mkdir build
3030
- cmd: cd build
3131
- cmd: cmake -G "%CMAKE_GENERATOR%" ^
32+
-D USE_SEQ=ON ^
3233
-D USE_MPI=ON ^
3334
-D USE_OMP=ON ^
3435
-D USE_TBB=ON ^
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME)
2+
3+
if ( USE_SEQ )
4+
set(ProjectId "${ProjectId}_seq")
5+
project( ${ProjectId} )
6+
message( STATUS "-- " ${ProjectId} )
7+
8+
file(GLOB_RECURSE header_files "*.h")
9+
file(GLOB_RECURSE source_files "*.cpp")
10+
set(PACK_LIB "${ProjectId}_lib")
11+
add_library(${PACK_LIB} STATIC ${header_files} ${source_files})
12+
13+
add_executable(${ProjectId} ${source_files})
14+
15+
target_link_libraries(${ProjectId} ${PACK_LIB})
16+
target_link_libraries(${ProjectId} gtest gtest_main)
17+
18+
enable_testing()
19+
add_test(NAME ${ProjectId} COMMAND ${ProjectId})
20+
else( USE_SEQ )
21+
message( STATUS "-- ${ProjectId} - NOT BUILD!" )
22+
endif( USE_SEQ )

modules/test_tasks/test_seq/main.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2018 Nesterov Alexander
2+
#include <gtest/gtest.h>
3+
#include <vector>
4+
5+
TEST(Sequential, Test_Sum) {
6+
const int count = 100;
7+
int sum = 0;
8+
for (size_t i = 0; i < count; i++) {
9+
sum++;
10+
}
11+
ASSERT_EQ(100, sum);
12+
}

scripts/run.bat

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,46 @@
11
@echo off
22
Setlocal EnableDelayedExpansion
33

4+
for /r "." %%a in (build\bin\*_seq.exe) do (
5+
echo -------------------------------------
6+
echo %%~na
7+
echo -------------------------------------
8+
set start=!time!
9+
%%~fa --gtest_repeat=10
10+
set end=!time!
11+
12+
set options="tokens=1-4 delims=:.,"
13+
for /f %options% %%a in ("!start!") do (
14+
set start_h=%%a
15+
set /a start_m=100%%b %% 100
16+
set /a start_s=100%%c %% 100
17+
set /a start_ms=100%%d %% 100
18+
)
19+
for /f %options% %%a in ("!end!") do (
20+
set end_h=%%a
21+
set /a end_m=100%%b %% 100
22+
set /a end_s=100%%c %% 100
23+
set /a end_ms=100%%d %% 100
24+
)
25+
26+
set /a hours=!end_h!-!start_h!
27+
set /a mins=!end_m!-!start_m!
28+
set /a secs=!end_s!-!start_s!
29+
set /a ms=!end_ms!-!start_ms!
30+
31+
if !ms! lss 0 set /a secs = !secs! - 1 & set /a ms = 100!ms!
32+
if !secs! lss 0 set /a mins = !mins! - 1 & set /a secs = 60!secs!
33+
if !mins! lss 0 set /a hours = !hours! - 1 & set /a mins = 60!mins!
34+
if !hours! lss 0 set /a hours = 24!hours!
35+
if 1!ms! lss 100 set ms=0!ms!
36+
set /a totalsecs = !hours!*3600 + !mins!*60 + !secs!
37+
if !totalsecs! gtr 5 (
38+
echo Alert: runtime greater then 5 sec.
39+
echo runtime = !totalsecs! sec.
40+
exit /b 1
41+
)
42+
)
43+
444
for /r "." %%a in (build\bin\*_omp.exe) do (
545
echo -------------------------------------
646
echo %%~na

scripts/run.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
#!/bin/bash
2+
3+
FILES_SEQ="build/bin/*_seq"
4+
for file in $FILES_SEQ; do
5+
start_seq=`date +%s`
6+
echo "--------------------------------"
7+
echo $(basename $file)
8+
echo "--------------------------------"
9+
./$file --gtest_repeat=10
10+
end_seq=`date +%s`
11+
runtime=$((end_seq-start_seq))
12+
if [ "$runtime" -gt "5" ]
13+
then
14+
echo "Alert: runtime > 5 sec. runtime = $runtime sec."
15+
exit 1
16+
fi
17+
done
18+
19+
220
FILES_OMP="build/bin/*_omp"
321
for file in $FILES_OMP; do
422
start_omp=`date +%s`

0 commit comments

Comments
 (0)