This projects contains tools for J-PET (strip PET) image reconstruction, simulation and various other utilities.
Makefile
CMakeLists.txt
cmake
)cmake -G Ninja
)libpng
headers and libraries for PNG output2d_barrel_geometry
)libpng
is available on Debian/Ubuntu GNU/Linux via:
apt-get install libpng12-dev
libpng
is available on Mac OS X with XQuartz X11 server
CUDA
7.5 is required to compile GPU C++11 code
Although project now compiles on Windows, however our main build environment is UNIX, so Windows compatibility may break any time.
Windows build flavor automatically downloads and compiles libpng
and
zlib
, since these both does not come with Windows by default. Therefore
build requires Internet connection.
Ninja currently does not work on Windows with our project.
This project uses Git submodules, make sure you pull them before the build:
git submodule update --init
Project uses CMake to generate platform specific build scripts, to build with default settings run:
cmake . && make
Additional options:
To build outside of project directory use:
cmake <path_to_project>
To use Ninja build instead default (make
) use:
cmake -G Ninja
To use different than default compiler:
cmake -DCMAKE_CXX_COMPILER=icpc # for Intel C++ compiler
cmake -DCMAKE_CXX_COMPILER=g++ # for GCC
cmake -DCMAKE_CXX_COMPILER=clang # for Clang
There are several compile time options that can be changed, enabled or
disabled. All PET specific options are CMake variables/options prefixed
with PET_
.
To list all available configure options:
cmake -LH
Once command above is run, typing cmake -DPET
and pressing [TAB] in
terminal completes all PET specific variables, unless Bash completion is
disabled.
To disable some option enabled by default, e.g. PET_WARP_GRANULARITY
:
cmake -DPET_WARP_GRANULARITY:BOOL=OFF
Please consult Related Pages of Doxygen generated documentation for detailed description of available commands and run examples.
Some commands offer --gpu
/-G
option to enable GPU (CUDA) backend. The most
powerful GPU card is selected automatically by default. This choice may be
overridden by -D
/--device
expecting integer device index.
There are two common errors that can appear when using GPU (CUDA) backend:
cudaSetDevice() 35: CUDA driver version is insufficient for CUDA runtime version
This means that there is no CUDA compatible device available in the system, regardless of successful compilation using CUDA SDK. Please make sure you have CUDA compatible GPU device installed in your system.
cudaPeekAtLastError() 8: invalid device function
This means that available/selected GPU card computing capability is not sufficient. Only devices with compute capability 3.0 or higher are officially supported. Please consult compute capability device list and see if your device is supported.
You can alternatively tweak CMakeLists.txt
adding extra -gencode
entry
with lower device compute capability to CUDA_NVCC_FLAGS
, however we do not
guarantee it will work fine.
Tests are not build by default. In order to build and run tests run:
make test && ./test
Files containing tests have _test.cpp
suffix.
Project uses Doxygen to generate documentation out of source code and Markdown files. To generate documentation run:
doxygen
Next open doc/html/index.html
file to view documentation.
Doxygen documentation uses figures from pet/pubs
sibling project, and
assumes its working copy in pubs
directory. If you see warning messages
about missing figure files, please clone pet/pubs
in this project root.
Doxygen documentation build process uses Perl based filter to generate command line reference output and it will unlikely work well on Windows.
This project follows C++11 and Chromium/Google source coding style
with custom settings described in .clang-format
.
Prior committing code should be formatted using clang-format using following methods:
Automatically using Git clean filter executed on each change introduced to index. This is set up running following command in root of the project:
git config filter.format.clean $PWD/scripts/format-filter
Manually, calling following script in root of the project:
./scripts/format
Using Qt Creator 3.1 or newer ClangFormat beautifier.
File format must be selected in Settings > Beautifier > Clang Format > Style.
When using Qt Creator code style used in this project can be imported using
Settings > C++ > Code Style > Import from src/Google.xml
file.
SmallPotato
small_potato.h
BROWN_POTATO
some_potato
Type
suffix, i.e.: SizeType
Class
suffix, i.e.: DetectorClass
This project can be built to use float
or double
as floating point
representation, depending on the need, therefore:
All classes must be templates taking FType
(aka floating point type),
SType
(aka short integer type) when necessary. They should not use float
,
double
or short
directly, eg.:
template <typename FType> struct Point {
using F = FType;
F x, y
};
All template instantiations shall use F
and S
types respectively
including common/types.h
prior instantiation, eg.:
#include "2d/geometry/point.h"
#include "2d/geometry/pixel.h"
#include "common/types.h"
using Point = PET2D::Point<F>;
using Pixel = PET2D::Point<S>;
Project uses std::istream
& std::ostream
for textual
serialization/deserialization, and special util::ibstream
& util::obstream
for binary serialization/deserialization.
Since this project is not using virtual methods, if class uses both textual and
binary serialization, it should define separate methods/constructors for both
std::
text streams and util::
binary streams.
All classes that can be serialized into ostream
or obstream
should define
"friend" operator<<
inside their body, eg.:
std::ostream& operator<<(std::ostream& out, const Point& p) {
return out << x << ' ' << y;
}
util::obstream& operator<<(util::obstream& out, const Point& p) {
return out << x << y; // NOTE: no ' ' separator since it is binary stream
}
All classes that can be deserialized from input stream should provide constructors taking input stream reference as an argument, eg.:
Point(std::istream& in) { in >> x >> y; }
Point(util::ibstream& in) { in >> x >> y; }
This project uses C++11 extensively, it also targets NVIDIA CUDA version 7.5 providing complete C++11 support.
Most of the classes as reused between CPU & GPU code using following rules:
All CUDA enabled class source files should include util/cuda/compat.h
All class methods available to CUDA should be started with single _
, that
will be turned into __device__
when compiling via CUDA, eg.:
_ Vector operator+(const Vector& other) { ... }
All CUDA enabled classes should NOT use <cmath>
functions like std::sin
,
but instead use compat::sin
counterparts which will be mapped to proper
CUDA functions.
All CUDA enabled classes should NOT use any STL containers or headers, if it is necessary class may provide CPU only methods using preprocessor conditional blocks, eg.:
#if !__CUDACC__
#include <ostream>
#endif
...
#if !__CUDACC__
std::ostream& operator<<(std::ostream& out, const Point& p) {
return out << x << ' ' << y;
}
#endif