LCOV - code coverage report
Current view: top level - src/grid/dgemm - grid_dgemm_tensor_local.c (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:42dac4a) Lines: 95.5 % 22 21
Test Date: 2025-07-25 12:55:17 Functions: 100.0 % 3 3

            Line data    Source code
       1              : /*----------------------------------------------------------------------------*/
       2              : /*  CP2K: A general program to perform molecular dynamics simulations         */
       3              : /*  Copyright 2000-2025 CP2K developers group <https://cp2k.org>              */
       4              : /*                                                                            */
       5              : /*  SPDX-License-Identifier: BSD-3-Clause                                     */
       6              : /*----------------------------------------------------------------------------*/
       7              : 
       8              : #include "grid_dgemm_tensor_local.h"
       9              : #include "../common/grid_common.h"
      10              : #include "grid_dgemm_utils.h"
      11              : 
      12       518972 : size_t realloc_tensor(tensor *t) {
      13       518972 :   assert(t != NULL);
      14              : 
      15       518972 :   if (t->alloc_size_ == 0) {
      16              :     /* there is a mistake somewhere. We can not have t->old_alloc_size_ != 0 and
      17              :      * no allocation */
      18            0 :     abort();
      19              :   }
      20              : 
      21       518972 :   if ((t->old_alloc_size_ >= t->alloc_size_) && (t->data != NULL))
      22              :     return t->alloc_size_;
      23              : 
      24           98 :   if ((t->old_alloc_size_ < t->alloc_size_) && (t->data != NULL)) {
      25           62 :     free(t->data);
      26              :   }
      27              : 
      28           98 :   t->data = NULL;
      29              : 
      30           98 :   if (t->data == NULL) {
      31           98 :     t->data = malloc(sizeof(double) * t->alloc_size_);
      32           98 :     assert(t->data != NULL);
      33           98 :     t->old_alloc_size_ = t->alloc_size_;
      34              :   }
      35              : 
      36           98 :   return t->alloc_size_;
      37              : }
      38              : 
      39        14112 : void alloc_tensor(tensor *t) {
      40        14112 :   assert(t != NULL);
      41              : 
      42        14112 :   t->data = malloc(sizeof(double) * t->alloc_size_);
      43        14112 :   assert(t->data != NULL);
      44        14112 :   t->old_alloc_size_ = t->alloc_size_;
      45        14112 : }
      46              : 
      47         1280 : void tensor_copy(tensor *const b, const tensor *const a) {
      48         1280 :   memcpy(b, a, sizeof(tensor));
      49         1280 : }
        

Generated by: LCOV version 2.0-1