This projects contains tools for J-PET (strip PET) image reconstruction, simulation and various other utilities.
- Piotr Bialas pbialas@th.if.uj.edu.pl (professor, supervisor)
- Adam Strzelecki adam.strzelecki@uj.edu.pl (PhD, code maintainer)
- Jakub Kowal jakub.kowal@uj.edu.pl (former PhD student)
- UNIX compatible build environment such as Linux or Mac OS X
- C++11 compatible compiler i.e. GCC 4.8.1, Clang 3.3 or ICC 15
- CMake 2.8.10 for build script generation
- GNU Make 3.8 for building using
Makefile
- QtCreator 3.1 for project editing via
CMakeLists.txt
- CUDA 7.5 (automatically detected by
cmake
) - Ninja 1.4 for faster re-builds (with
cmake -G Ninja
) libpng
headers and libraries for PNG output- Boost 1.58 for alternative geometry calculation
(
2d_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
- Visual Studio 2015
- CMake 3.0 for build script generation
- CMake Tools for editing CMake in Visual Studio
-
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
andzlib
, 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 toCUDA_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 inpubs
directory. If you see warning messages about missing figure files, please clonepet/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.
- Camel-case naming for classes and template names i.e.
SmallPotato
- Lower case with underscores for class files, i.e.:
small_potato.h
- Constants are upper case with underscores, i.e.:
BROWN_POTATO
- Variables and instances using lower case, i.e.:
some_potato
- Type template parameters should have
Type
suffix, i.e.:SizeType
- Class template parameters should have
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 usefloat
,double
orshort
directly, eg.:template <typename FType> struct Point { using F = FType; F x, y };
-
All template instantiations shall use
F
andS
types respectively includingcommon/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 likestd::sin
, but instead usecompat::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