(git:374b731)
Loading...
Searching...
No Matches
grid_dgemm_tensor_local.c
Go to the documentation of this file.
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
9#include "../common/grid_common.h"
10#include "grid_dgemm_utils.h"
11
13 assert(t);
14
15 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 abort();
19 }
20
21 if ((t->old_alloc_size_ >= t->alloc_size_) && (t->data != NULL))
22 return t->alloc_size_;
23
24 if ((t->old_alloc_size_ < t->alloc_size_) && (t->data != NULL)) {
25 free(t->data);
26 }
27
28 t->data = NULL;
29
30 if (t->data == NULL) {
31 t->data = malloc(sizeof(double) * t->alloc_size_);
32 if (!t->data)
33 abort();
34 t->old_alloc_size_ = t->alloc_size_;
35 }
36
37 return t->alloc_size_;
38}
39
41 if (t == NULL) {
42 abort();
43 }
44
45 t->data = malloc(sizeof(double) * t->alloc_size_);
46 if (!t->data)
47 abort();
48 t->old_alloc_size_ = t->alloc_size_;
49}
50
51void tensor_copy(tensor *const b, const tensor *const a) {
52 memcpy(b, a, sizeof(tensor));
53}
void tensor_copy(tensor *const b, const tensor *const a)
size_t realloc_tensor(tensor *t)
void alloc_tensor(tensor *t)