============================================= Build the Kokkos backend for CPU, CUDA or HIP ============================================= The Kokkos backend selects the execution space of its installed Kokkos library. A CPU installation (Serial or OpenMP) runs the Eigen backend's Cholesky, triangular solves and inverse in place on the host matrices, so those results have the Eigen backend's bits; Kokkos Kernels serves the Kokkos posterior and the explicit workspace and factor objects. A CUDA installation uses cuSOLVER and cuBLAS; a HIP installation uses rocSOLVER and rocBLAS. Select the backend with ``-Dlinalg_backend=kokkos`` when configuring GPRidge. The choice applies to both GP dimer and GP-NEB calculations in that build. The dense GP operations accept and return host Eigen matrices. On a CPU installation the host factor already lives in execution memory, so a GP model keeps no second copy. Solves, whitening and the log determinant use that Eigen factor. The log determinant is the sum of the logarithms of the factor diagonal. A failed factorization releases a device posterior together with any resident factor, so a later query does not follow a null factor. On a device installation each GP model retains an immutable physical Cholesky factor on the device across solves and variance queries. Factorization or an incremental factor update creates a new owner; clearing the training factor releases it. Queries do not compare or upload the host factor. A covariance solve uploads its right-hand side once, runs both triangular solves on the device and downloads the final solution. A variance-diagonal query downloads only the column norms. Independent models own separate workspaces. Covariance assembly, query assembly and the compensated prediction-mean contraction remain host operations. Query operands and returned results still cross the device boundary. The general ``BackendContext`` operations accept mutable Eigen factors and check an exact host witness before reuse; replacing or modifying that supplied factor uploads it again. The stateless dense functions copy their supplied factor for each call. Small training sets can therefore run faster on the CPU. The measurements in :doc:`Run GPRidge on a GPU ` compare complete fits and complete searches for the separate cuSOLVER backend. The oracle has its own device selection. Choose compatible dependencies ------------------------------ Use Kokkos and Kokkos Kernels from matching releases, built with the same C++ compiler and execution space. GPRidge requires version 4.7 or newer; the commands below pin both dependencies to 5.2.2. Kokkos 5 requires C++20 and a supported device compiler. Check the `Kokkos compiler requirements `_ against the toolkit installed at the site. .. table:: +------------------+-------------------------------------------------------------+-------------------------------------------+ | Execution space | C++ compiler | Dense dependencies | +==================+=============================================================+===========================================+ | Serial or OpenMP | supported host compiler | Kokkos Kernels BLAS component | +------------------+-------------------------------------------------------------+-------------------------------------------+ | CUDA | Kokkos ``nvcc_wrapper`` with a CUDA-supported host compiler | cuSOLVER and Kokkos Kernels with cuBLAS | +------------------+-------------------------------------------------------------+-------------------------------------------+ | HIP | ``hipcc`` | rocSOLVER and Kokkos Kernels with rocBLAS | +------------------+-------------------------------------------------------------+-------------------------------------------+ The backend rejects a SYCL configuration at configure time because it has no SYCL dense factorization implementation. Build on an allocated compute node. Load the site's compiler and toolkit before configuring dependencies, and keep one toolchain throughout the build. The :doc:`HPC guide ` covers allocation, storage, threads and runtime library paths. Prefer the site's native modules or packages; the commands below describe the dependency settings when a suitable installation is not available. Build the dependency pair ------------------------- Download and verify the tagged Kokkos and Kokkos Kernels sources before entering a node without network access. Set ``kokkos_source`` and ``kernels_source`` to the two extracted source directories, and ``kokkos_prefix`` to an owned installation prefix. Put temporary sources, build trees and compiler caches on node-local disk; retain the installed prefix, checksums and logs on project storage. For a CPU installation, configure the core with the host C++ compiler: .. code:: bash cmake -S "$kokkos_source" -B "$kokkos_source/build" -G Ninja \ -DCMAKE_INSTALL_PREFIX="$kokkos_prefix" \ -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 \ -DBUILD_SHARED_LIBS=ON -DKokkos_ENABLE_SERIAL=ON cmake --build "$kokkos_source/build" --parallel "${SLURM_CPUS_PER_TASK:-1}" cmake --install "$kokkos_source/build" For CUDA, add ``-DKokkos_ENABLE_CUDA=ON`` and an architecture such as ``-DKokkos_ARCH_AMPERE80=ON`` for an A100. Set ``-DCMAKE_CXX_COMPILER``"$kokkos\_source/bin/nvcc\_wrapper"= and ``NVCC_WRAPPER_DEFAULT_COMPILER`` to the supported host compiler. For HIP, use ``-DCMAKE_CXX_COMPILER=hipcc``, ``-DKokkos_ENABLE_HIP=ON`` and the architecture of the allocated GPU. A MI250X uses ``-DKokkos_ARCH_AMD_GFX90A=ON`` in the pinned release. Set the architecture explicitly when configuring without a visible GPU. Build Kokkos Kernels against that prefix. The CPU configuration is: .. code:: bash cmake -S "$kernels_source" -B "$kernels_source/build" -G Ninja \ -DCMAKE_PREFIX_PATH="$kokkos_prefix" \ -DCMAKE_INSTALL_PREFIX="$kokkos_prefix" \ -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 \ -DBUILD_SHARED_LIBS=ON -DKokkosKernels_ENABLE_ALL_COMPONENTS=OFF \ -DKokkosKernels_ENABLE_COMPONENT_BLAS=ON \ -DKokkosKernels_INST_DOUBLE=ON -DKokkosKernels_INST_FLOAT=OFF \ -DKokkosKernels_INST_COMPLEX_FLOAT=OFF \ -DKokkosKernels_INST_COMPLEX_DOUBLE=OFF \ -DKokkosKernels_INST_LAYOUTRIGHT=OFF cmake --build "$kernels_source/build" --parallel "${SLURM_CPUS_PER_TASK:-1}" cmake --install "$kernels_source/build" Use the same device compiler for this step. CUDA also needs ``-DKokkosKernels_ENABLE_TPL_CUBLAS=ON``; HIP needs ``-DKokkosKernels_ENABLE_TPL_ROCBLAS=ON``. The factorization bridge links cuSOLVER or rocSOLVER directly. The Kokkos Kernels BLAS component is sufficient for this backend. Configure and check GPRidge --------------------------- From the GPRidge checkout, extend ``CMAKE_PREFIX_PATH`` with the dependency prefix. A CUDA build uses the host C++ compiler for GP code and Meson's CUDA compiler for the device implementation. Set ``CXX`` to the supported host compiler and select ``nvcc`` in a Meson native file. Both compilers must use the same host toolchain. Meson takes the device architecture from ``Kokkos_CUDA_ARCHITECTURES`` in the installed Kokkos configuration. .. code:: bash export CXX=$(command -v g++) cat > kokkos-cuda.ini < dense-backend.csv The CSV records each repetition's wall time in seconds, relative numerical error, factor upload count and bytes copied in each direction. The ``kokkos_immutable`` route reports its initial factor upload separately and keeps that owner for all queries. Repeated query rows have zero factor uploads. A variance-diagonal query returns one double per right-hand-side column. The ``kokkos_workspace`` route also measures the host comparison required for mutable factors; its first query includes a factor upload. The stateless and host routes do not instrument transfer counters. Record the compiler, Kokkos configuration, CPU and GPU models, thread counts and raw repetitions with the results. These dense-operation measurements do not include covariance assembly, hyperparameter fitting, oracle evaluations or a complete dimer or NEB search. A100 measurement ~~~~~~~~~~~~~~~~ The retained A100 data and reduction contain 1065 raw rows from 15 workloads, including all factor-upload and query-transfer counts. The run uses one A100 PCIe 40 GB, CUDA 12.2.0, GCC 12.3.0, Kokkos and Kokkos Kernels 5.2.2. The CPU reference uses one Eigen thread on a Xeon Platinum 8358 with AVX2 available and floating-point contraction disabled. For 64 right-hand-side columns, covariance-solve medians are: .. table:: +-------+-----------------------+--------------------+--------------------+ | Order | One-thread Eigen (ms) | Stateless GPU (ms) | Immutable GPU (ms) | +=======+=======================+====================+====================+ | 128 | 0.108 | 0.335 | 0.168 | +-------+-----------------------+--------------------+--------------------+ | 512 | 1.221 | 1.517 | 0.594 | +-------+-----------------------+--------------------+--------------------+ | 1024 | 4.208 | 3.056 | 1.097 | +-------+-----------------------+--------------------+--------------------+ | 2048 | 16.214 | 11.139 | 2.746 | +-------+-----------------------+--------------------+--------------------+ | 4096 | 71.067 | 41.510 | 4.838 | +-------+-----------------------+--------------------+--------------------+ These medians use repetitions 1 through 6 of seven recorded queries and include RHS and result transfers. The immutable factor's initial upload is recorded separately and excluded from repeated-query medians. At order 4096 the solve improves by a factor of 8.58 over stateless GPU calls; at order 128 the CPU is faster. The corresponding immutable variance-diagonal query at order 4096 takes 2.475 ms. These measurements concern the dense API at source revision ``f6764d464``; the data record also identifies the GP objective-owner correction. They do not measure complete fitting or search performance, or compare against a fully threaded CPU solve. Prepare a LUMI build -------------------- LUMI-G has MI250X devices with two graphics compute dies per device. Use the site's `Spack instructions `_ or `Kokkos module documentation `_ to choose a consistent compiler and ROCm stack. The ``spack-gpu`` environment and a ``LUMI/`` EasyBuild programming environment are separate stacks. Choose one stack for the build. Use the ROCm version supplied by the chosen stack rather than building a second runtime into the home directory. Pin ``gfx90a`` for the device code, keep package stages and caches under an owned project or scratch root, and check inode quotas before unpacking sources. Preserve the concretized package specification or module list, compiler versions, source checksums and numerical test logs. A successful compile verifies the build route; performance and numerical validation require a GPU allocation. No LUMI performance measurement accompanies this recipe.