Skip to content

Commit

Permalink
feat(Lab3): complete lab 3 global optimizathon
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelLSmirnov committed Dec 21, 2023
1 parent 65b1a24 commit 2041e1c
Show file tree
Hide file tree
Showing 5 changed files with 648 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ubuntu:latest

# Устанавливаем зависимости
RUN apt-get update && \
apt-get upgrade && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:ubuntu-toolchain-r/test && \
apt-get update && \
apt-get install -y gcc-12 g++-12 cppcheck ninja-build mpich libmpich mpi openmpi-bin libomp-dev python3-pip valgrind

RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install setuptools cpplint

# Устанавливаем ccache
RUN apt-get install -y ccache

# Копируем код проекта внутрь контейнера
COPY . /app
WORKDIR /app

# Обновляем submodules
RUN git submodule update --init --recursive

# Выполняем настройку CMake
RUN mkdir build
WORKDIR /app/build
RUN cmake -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STD=ON -D CMAKE_BUILD_TYPE=RELEASE ..
WORKDIR /app

# Собираем проект с помощью Ninja
RUN export PATH="/usr/lib/ccache:$PATH" && cd build && ninja
WORKDIR /app

# Устанавливаем переменную среды для количества потоков OpenMP
ENV OMP_NUM_THREADS=8

# Запускаем скрипт для запуска тестов
CMD ["scripts/run.sh"]
36 changes: 36 additions & 0 deletions tasks/task_3/smirnov_p_global_optimization/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME)
enable_testing()

if( USE_MPI )
if( UNIX )
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Wno-uninitialized")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-uninitialized")
endif( UNIX )

set(ProjectId "${ProjectId}_mpi")
project( ${ProjectId} )
message( STATUS "-- " ${ProjectId} )

file(GLOB_RECURSE header_files "*.h")
file(GLOB_RECURSE source_files "*.cpp")
set(PACK_LIB "${ProjectId}_lib")
add_library(${PACK_LIB} STATIC ${header_files} ${source_files})

add_executable( ${ProjectId} ${source_files} )

target_link_libraries(${ProjectId} ${PACK_LIB})
if( MPI_COMPILE_FLAGS )
set_target_properties( ${ProjectId} PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS}" )
endif( MPI_COMPILE_FLAGS )

if( MPI_LINK_FLAGS )
set_target_properties( ${ProjectId} PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}" )
endif( MPI_LINK_FLAGS )
target_link_libraries( ${ProjectId} ${MPI_LIBRARIES} )
target_link_libraries(${ProjectId} gtest gtest_main)

enable_testing()
add_test(NAME ${ProjectId} COMMAND ${ProjectId})
else( USE_MPI )
message( STATUS "-- ${ProjectId} - NOT BUILD!" )
endif( USE_MPI )
Loading

0 comments on commit 2041e1c

Please sign in to comment.