Skip to content

Commit 89d98f3

Browse files
authored
Merge pull request #16 from DCM-UPB/polish
new release v0.2
2 parents b5464f5 + 7500542 commit 89d98f3

33 files changed

+291
-569
lines changed

.gitignore

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,10 @@ DerivedData
6060

6161
# -- project specific ignores --
6262
lib*
63+
build
6364
config.sh
64-
*exe*
6565
vgcore*
6666

67-
src/*.o
68-
69-
debug/*.o
70-
debug/*.txt
71-
72-
debug/unittests/ut*/*.o
73-
debug/unittests/ut*/*.sh
74-
75-
examples/*/a.out
76-
examples/*/*.o
77-
7867
doc/*.aux
7968
doc/*.dvi
8069
doc/*.idx

CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
cmake_minimum_required (VERSION 3.5)
2+
include(FindPackageHandleStandardArgs)
3+
4+
project (mci LANGUAGES CXX VERSION 0.0.1)
5+
6+
set(CMAKE_CXX_STANDARD 11)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
9+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USER_CXX_FLAGS}")
10+
11+
# find packages
12+
message(STATUS "Configured CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
13+
message(STATUS "Configured CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
14+
15+
find_package(MPI)
16+
if (MPI_FOUND)
17+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MPI=1")
18+
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
19+
message(STATUS "MPI_INCLUDE_PATH: ${MPI_INCLUDE_PATH}")
20+
message(STATUS "MPI_CXX_LIBRARIES: ${MPI_CXX_LIBRARIES}")
21+
endif()
22+
23+
# set header / library paths
24+
include_directories(include/) # headers
25+
26+
enable_testing()
27+
28+
# continue with subdirectories
29+
add_subdirectory(src)
30+
add_subdirectory(test)
31+
add_subdirectory(examples)
32+

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ Some basic tools for finding the average and standard deviation of an array of d
66

77
In `doc/` there is a user manual in pdf.
88

9-
In `examples/` there are several examples (STILL TO BE DONE).
9+
In `examples/` there are examples.
1010

1111

1212

1313
# Build the library
1414

15-
Insert the system parameters in a file named `config.sh` (use `config_template.sh` as template) and then simply execute the command
15+
We use the CMake build system, so you need to have it on your system to build the library out of the box.
16+
Then copy the file `config_template.sh` to `config.sh`, edit it to your liking and then simply execute the command
1617

1718
`./build.sh`
19+
20+
Note that we build out-of-tree, so the compiled library and executable files can be found in the directories under `./build/`.

build.sh

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,6 @@
1-
#!/bin/bash
2-
3-
OS_NAME=$(uname)
4-
echo "The Operating System is: "${OS_NAME} # here we consider only Linux and Darwin (Mac Os X)
5-
6-
source config.sh
7-
ACTUAL_FOLDER=$(pwd)
8-
9-
\rm -f *.so
10-
cd src/
11-
\rm -f *.o *.so
12-
echo "$CC $FLAGS $OPTFLAGS -fpic -c *.cpp"
13-
$CC $FLAGS $OPTFLAGS -fpic -c *.cpp
14-
15-
case ${OS_NAME} in
16-
"Linux")
17-
echo "$CC $FLAGS $OPTFLAGS -shared -o lib${LIBNAME}.so *.o"
18-
$CC $FLAGS $OPTFLAGS -shared -o lib${LIBNAME}.so *.o
19-
;;
20-
"Darwin")
21-
ROOT_FOLDER=$(dirname $(pwd))
22-
echo "$CC $FLAGS $OPTFLAGS -shared -install_name ${ROOT_FOLDER}/lib${LIBNAME}.so -o lib${LIBNAME}.so *.o"
23-
$CC $FLAGS $OPTFLAGS -shared -install_name ${ROOT_FOLDER}/lib${LIBNAME}.so -o lib${LIBNAME}.so *.o
24-
;;
25-
*)
26-
echo "The detected operating system is not between the known ones (Linux and Darwin)"
27-
;;
28-
esac
29-
30-
mv lib${LIBNAME}.so ../
31-
cd ..
32-
33-
34-
echo
35-
echo "Library ready!"
36-
echo
37-
echo "Help, how can I use it?"
38-
case ${OS_NAME} in
39-
"Linux")
40-
echo "1) $CC $FLAGS -I$(pwd)/src/ -c example.cpp"
41-
echo " $CC $FLAGS -L$(pwd) example.o -l${LIBNAME}"
42-
echo "2) $CC $FLAGS -I$(pwd)/src/ -L$(pwd) example.cpp -l${LIBNAME}"
43-
;;
44-
"Darwin")
45-
echo "1) $CC $FLAGS -I$(pwd)/src/ -c example.cpp"
46-
echo " $CC $FLAGS -I$(pwd)/src/ -L$(pwd) example.o -l${LIBNAME}"
47-
echo "2) $CC $FLAGS -I$(pwd)/src/ -L$(pwd) example.cpp -l${LIBNAME}"
48-
;;
49-
esac
1+
#!/bin/sh
2+
. ./config.sh
3+
mkdir -p build
4+
cd build
5+
cmake -DCMAKE_CXX_COMPILER="${CXX_COMPILER}" -DUSER_CXX_FLAGS="${CXX_FLAGS}" ..
6+
make

build_debug_library.sh

Lines changed: 0 additions & 49 deletions
This file was deleted.

config_template.sh

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
#!/bin/bash
22

3-
# Library name
4-
LIBNAME="mci"
3+
#C++ compiler
4+
CXX_COMPILER="g++"
55

6-
# C++ compiler
7-
CC="g++"
6+
# C++ flags
7+
CXX_FLAGS="-O3 -flto -Wall -Wno-unused-function"
88

9-
# MPI compiler wrapper
10-
MPICC="mpic++"
11-
12-
# C++ flags (std=c++11 is necessary)
13-
FLAGS="-std=c++11 -Wall -Werror"
14-
15-
# Optimization flags
16-
OPTFLAGS="-O3 -flto"
17-
18-
# Debuggin flags
19-
DEBUGFLAGS="-g -O0"

debug/run.sh

Lines changed: 0 additions & 53 deletions
This file was deleted.

debug/unittests/run.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

debug/unittests/run_single_unittest.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
link_libraries(mci)
2+
add_executable(ex1.exe ex1/main.cpp)
3+
if (MPI_FOUND)
4+
add_executable(ex2.exe ex2/main.cpp)
5+
target_link_libraries(ex2.exe ${MPI_CXX_LIBRARIES})
6+
endif()

0 commit comments

Comments
 (0)