LCOV - code coverage report
Current view: top level - src/fft - fft_utils.h (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:1be8651) Lines: 100.0 % 5 5
Test Date: 2026-11-24 01:22:08 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*----------------------------------------------------------------------------*/
       2              : /*  CP2K: A general program to perform molecular dynamics simulations         */
       3              : /*  Copyright 2000-2026 CP2K developers group <https://cp2k.org>              */
       4              : /*                                                                            */
       5              : /*  SPDX-License-Identifier: BSD-3-Clause                                     */
       6              : /*----------------------------------------------------------------------------*/
       7              : #ifndef FFT_UTILS_H
       8              : #define FFT_UTILS_H
       9              : 
      10              : #include "fft_timer.h"
      11              : 
      12              : #include <complex.h>
      13              : #include <omp.h>
      14              : #include <stdio.h>
      15              : #include <string.h>
      16              : 
      17              : #define FFT_FORWARD 1
      18              : #define FFT_BACKWARD -1
      19              : 
      20              : /*******************************************************************************
      21              :  * \brief Returns the number of threads used for FFT planning.
      22              :  *        Outside an OpenMP parallel region the maximum number of threads is
      23              :  *        used. Inside a parallel region a single thread is used to avoid
      24              :  *        nested parallelism and concurrently executed shared plans.
      25              :  * \author Frederick Stein
      26              :  ******************************************************************************/
      27     19244992 : static inline int fft_team_size(void) {
      28     19244992 :   return omp_in_parallel() ? 1 : omp_get_max_threads();
      29              : }
      30              : 
      31              : /*******************************************************************************
      32              :  * \brief Returns the smaller of two given integer (missing from the C standard)
      33              :  * \author Ole Schuett
      34              :  ******************************************************************************/
      35              : static inline int imin(int x, int y) { return (x < y ? x : y); }
      36              : 
      37              : /*******************************************************************************
      38              :  * \brief Returns the larger of two given integer (missing from the C standard)
      39              :  * \author Ole Schuett
      40              :  ******************************************************************************/
      41       467900 : static inline int imax(int x, int y) { return (x > y ? x : y); }
      42              : 
      43              : /*******************************************************************************
      44              :  * \brief Returns the smaller of two given integer (missing from the C standard)
      45              :  * \author Frederick Stein
      46              :  ******************************************************************************/
      47              : static inline double dmin(double x, double y) { return (x < y ? x : y); }
      48              : 
      49              : /*******************************************************************************
      50              :  * \brief Returns the larger of two given integer (missing from the C standard)
      51              :  * \author Frederick Stein
      52              :  ******************************************************************************/
      53              : static inline double dmax(double x, double y) { return (x > y ? x : y); }
      54              : 
      55              : /*******************************************************************************
      56              :  * \brief Equivalent of Fortran's MODULO which always returns a positive number.
      57              :  *        https://gcc.gnu.org/onlinedocs/gfortran/MODULO.html
      58              :  * \author Ole Schuett
      59              :  ******************************************************************************/
      60              : static inline int modulo(int a, int m) { return ((a % m + m) % m); }
      61              : 
      62              : /*******************************************************************************
      63              :  * \brief Calculates the product of three numbers.
      64              :  * \author Frederick Stein
      65              :  ******************************************************************************/
      66           64 : static inline long int product3(const int array3[3]) {
      67           64 :   return (long int)array3[0] * array3[1] * array3[2];
      68              : }
      69              : 
      70              : #endif /* FFT_UTILS_H */
      71              : 
      72              : // EOF
        

Generated by: LCOV version 2.0-1