C++ Examples#

File list#

CMakeLists.txt

CMake configuration file for building all of the examples below.

meson.build

Meson configuration file for building all of the examples below.

example.cpp

The simple 1D complex FFT from the Introduction.

fft_cc.cpp

Several examples of complex time domain, complex frequency domain FFTs. Also, the use of scratch memory is explored.

fft_cc_2d.cpp

A complex time, complex frequency 2D FFT that demonstrates strides and passing a Factory to a function. It also uses OpenMP.

fft_rc.cpp

Several examples of real time domain, complex frequency domain FFTs.

advanced/CMakeLists.txt

CMake configuration file for building all of the advanced examples below.

advanced/meson.build

Meson configuration file for building all of the advanced examples below.

advanced/link-f.py

Python script that creates hard links, removing existing destination files.

advanced/fft_12.cpp

An example that illustrates disabling dlsym() lookup.

advanced/fft_3x6.cpp

A 2D complex time, complex frequency FFT that demonstrates dynamically loading FFT libraries at runtime.

advanced/ncpu.cpp

An example demonstrating run-time detection of cpus, cores, dies, and packages. The resulting binary may itself be of practical utility.

The links above have some further discussion particular to each example. In addition to reading the code and the comments sprinkled throughout, please see the API Design section for an overview.


CMake#

Assuming Hpk has been installed into /opt/libhpk0, the following command will make the directory mybuild and write Makefile therein:

cmake -B mybuild -S /opt/libhpk0/share/doc/hpk/examples

By default, the CMakeLists.txt in the examples directory looks for the Hpk package files in the directory /opt/libhpk0/lib/cmake/hpk on x86_64 and in /opt/libhpk0/lib64/cmake/hpk on aarch64. If your installation directory differs, specify the directory that contains HpkConfig.cmake on the command line as follows:

cmake -D Hpk_DIR=/opt/libhpk0/lib/cmake/hpk  \
      -B mybuild -S /opt/libhpk0/share/doc/hpk/examples

Next, build all the examples:

cmake --build mybuild

Please see Building for additional discussion on preprocessor macros and CMake targets.


Meson#

Assuming Hpk has been installed into /opt/libhpk0, the following command will make the directory mybuild and write build.ninja therein:

meson setup mybuild /opt/libhpk0/share/doc/hpk/examples

By default, the meson.build from the examples directory looks for the Hpk pkgconfig files in both /opt/libhpk0/lib/pkgconfig and /opt/libhpk0/lib64/pkgconfig. If your installation directory differs, specify the directory that contains hpk_core.pc, etc. on the command line as follows:

meson setup --pkg-config-path=/opt/libhpk0/lib/pkgconfig \
            mybuild /opt/libhpk0/share/doc/hpk/examples

Next, build all the examples:

meson compile -C mybuild

Please see Building for additional discussion on preprocessor macros and Meson dependencies.