LCOV - code coverage report
Current view: top level - src/grid/dgemm - grid_dgemm_tensor_local.c (source / functions) Hit Total Coverage
Test: CP2K Regtests (git:2fce0f8) Lines: 21 22 95.5 %
Date: 2024-12-21 06:28:57 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*----------------------------------------------------------------------------*/
       2             : /*  CP2K: A general program to perform molecular dynamics simulations         */
       3             : /*  Copyright 2000-2024 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      504788 : size_t realloc_tensor(tensor *t) {
      13      504788 :   assert(t != NULL);
      14             : 
      15      504788 :   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      504788 :   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       14032 : void alloc_tensor(tensor *t) {
      40       14032 :   assert(t != NULL);
      41             : 
      42       14032 :   t->data = malloc(sizeof(double) * t->alloc_size_);
      43       14032 :   assert(t->data != NULL);
      44       14032 :   t->old_alloc_size_ = t->alloc_size_;
      45       14032 : }
      46             : 
      47        1256 : void tensor_copy(tensor *const b, const tensor *const a) {
      48        1256 :   memcpy(b, a, sizeof(tensor));
      49        1256 : }

Generated by: LCOV version 1.15