Skip to content

Commit

Permalink
Changed "inline" to "static inline" to allow compilation without C99 …
Browse files Browse the repository at this point in the history
…standard (#1180)
  • Loading branch information
hfp committed Nov 20, 2020
1 parent e99762a commit 011eae4
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions src/grid/cpu/tensor_local.h
Expand Up @@ -50,8 +50,8 @@ extern void initialize_tensor_blocked(struct tensor_ *a, const int dim,

/* initialize a tensor structure for a tensor of dimension dim <= 4 */

inline void initialize_tensor(struct tensor_ *a, const int dim,
const int *const sizes) {
static inline void initialize_tensor(struct tensor_ *a, const int dim,
const int *const sizes) {
if (a == NULL)
return;

Expand Down Expand Up @@ -88,7 +88,7 @@ inline void initialize_tensor(struct tensor_ *a, const int dim,

/* initialize a tensor structure for a tensor of dimension dim = 2 */

inline void initialize_tensor_2(struct tensor_ *a, int n1, int n2) {
static inline void initialize_tensor_2(struct tensor_ *a, int n1, int n2) {
if (a == NULL)
return;

Expand All @@ -98,7 +98,8 @@ inline void initialize_tensor_2(struct tensor_ *a, int n1, int n2) {

/* initialize a tensor structure for a tensor of dimension dim = 2 */

inline void initialize_tensor_3(struct tensor_ *a, int n1, int n2, int n3) {
static inline void initialize_tensor_3(struct tensor_ *a, int n1, int n2,
int n3) {
if (a == NULL)
return;
int size_[3] = {n1, n2, n3};
Expand All @@ -107,8 +108,8 @@ inline void initialize_tensor_3(struct tensor_ *a, int n1, int n2, int n3) {

/* initialize a tensor structure for a tensor of dimension dim = 2 */

inline void initialize_tensor_4(struct tensor_ *a, int n1, int n2, int n3,
int n4) {
static inline void initialize_tensor_4(struct tensor_ *a, int n1, int n2,
int n3, int n4) {
if (a == NULL)
return;
int size_[4] = {n1, n2, n3, n4};
Expand All @@ -117,8 +118,8 @@ inline void initialize_tensor_4(struct tensor_ *a, int n1, int n2, int n3,

/* initialize a tensor structure for a tensor of dimension dim = 2 */

inline void initialize_tensor_blocked_2(struct tensor_ *a, int n1, int n2,
int *blockdim) {
static inline void initialize_tensor_blocked_2(struct tensor_ *a, int n1,
int n2, int *blockdim) {
if (a == NULL)
return;

Expand All @@ -129,8 +130,8 @@ inline void initialize_tensor_blocked_2(struct tensor_ *a, int n1, int n2,

/* initialize a tensor structure for a tensor of dimension dim = 2 */

inline void initialize_tensor_blocked_3(struct tensor_ *a, int n1, int n2,
int n3, int *blockdim) {
static inline void initialize_tensor_blocked_3(struct tensor_ *a, int n1,
int n2, int n3, int *blockdim) {
if (a == NULL)
return;
int size_[3] = {n1, n2, n3};
Expand All @@ -140,8 +141,9 @@ inline void initialize_tensor_blocked_3(struct tensor_ *a, int n1, int n2,

/* initialize a tensor structure for a tensor of dimension dim = 2 */

inline void initialize_tensor_blocked_4(struct tensor_ *a, int n1, int n2,
int n3, int n4, int *blockdim) {
static inline void initialize_tensor_blocked_4(struct tensor_ *a, int n1,
int n2, int n3, int n4,
int *blockdim) {
if (a == NULL)
return;
int size_[4] = {n1, n2, n3, n4};
Expand All @@ -150,7 +152,7 @@ inline void initialize_tensor_blocked_4(struct tensor_ *a, int n1, int n2,

/* initialize a tensor structure for a tensor of dimension dim = 2 */

inline tensor *create_tensor(const int dim, const int *sizes) {
static inline tensor *create_tensor(const int dim, const int *sizes) {
tensor *a = (tensor *)malloc(sizeof(struct tensor_));

if (a == NULL)
Expand All @@ -165,7 +167,7 @@ inline tensor *create_tensor(const int dim, const int *sizes) {
}

/* destroy a tensor created with the function above */
inline void destroy_tensor(tensor *a) {
static inline void destroy_tensor(tensor *a) {
if (a->block != NULL)
free(a->block);

Expand All @@ -174,32 +176,33 @@ inline void destroy_tensor(tensor *a) {
free(a);
}

inline size_t tensor_return_memory_size(const struct tensor_ *const a) {
static inline size_t tensor_return_memory_size(const struct tensor_ *const a) {
if (a == NULL)
abort();

return a->alloc_size_;
}

inline void tensor_assign_memory(struct tensor_ *a, void *data) {
static inline void tensor_assign_memory(struct tensor_ *a, void *data) {
if (a == NULL)
abort();
a->data = (double *)data;
}

inline int tensor_get_leading_dimension(struct tensor_ *a) {
static inline int tensor_get_leading_dimension(struct tensor_ *a) {
if (a == NULL)
abort();
return a->ld_;
}

inline void tensor_set_leading_dimension(struct tensor_ *a, const int ld) {
static inline void tensor_set_leading_dimension(struct tensor_ *a,
const int ld) {
if (a == NULL)
abort();
a->ld_ = ld;
}

inline void recompute_tensor_offsets(struct tensor_ *a) {
static inline void recompute_tensor_offsets(struct tensor_ *a) {
if (a == NULL)
abort();

Expand Down Expand Up @@ -229,18 +232,18 @@ inline void recompute_tensor_offsets(struct tensor_ *a) {
}
}

inline size_t compute_memory_space_tensor_3(const int n1, const int n2,
const int n3) {
static inline size_t compute_memory_space_tensor_3(const int n1, const int n2,
const int n3) {
return (n1 * n2 * n3);
}

inline size_t compute_memory_space_tensor_4(const int n1, const int n2,
const int n3, const int n4) {
static inline size_t compute_memory_space_tensor_4(const int n1, const int n2,
const int n3, const int n4) {
return (n1 * n2 * n3 * n4);
}

inline void setup_global_grid_size(tensor *const grid,
const int *const full_size) {
static inline void setup_global_grid_size(tensor *const grid,
const int *const full_size) {
switch (grid->dim_) {
case 1:
grid->full_size[0] = full_size[0];
Expand All @@ -261,9 +264,10 @@ inline void setup_global_grid_size(tensor *const grid,
}
}

inline void setup_grid_window(tensor *const grid, const int *const shift_local,
const int *const border_width,
const int border_mask) {
static inline void setup_grid_window(tensor *const grid,
const int *const shift_local,
const int *const border_width,
const int border_mask) {
for (int d = 0; d < grid->dim_; d++) {
grid->lower_corner[d] = shift_local[grid->dim_ - d - 1];
grid->window_shift[d] = 0;
Expand Down

0 comments on commit 011eae4

Please sign in to comment.