Skip to content
Snippets Groups Projects
Verified Commit 5f54ebce authored by raphael.bach's avatar raphael.bach
Browse files

Add `fmpi_data` module

parent 1391a1f2
No related branches found
No related tags found
No related merge requests found
// SPDX-License-Identifier: 0BSD
/*!
* @file
* @license{
* BSD Zero Clause License
*
* Copyright (c) 2022 by Raphael Bach
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
* }
*/
/*==============================================================================
GUARD
==============================================================================*/
#ifndef FMPI_DATA_H_20211228231216
#define FMPI_DATA_H_20211228231216
/*==============================================================================
INCLUDE
==============================================================================*/
// C Standard Library
#include <stddef.h>
#include <stdint.h>
// Internal
#include "internal/generic/fmpi_data_generic.h"
#include "internal/generic/fmpi_generic.h"
#include "internal/generic/fmpi_type.h"
/*==============================================================================
TYPE
==============================================================================*/
/*------------------------------------------------------------------------------
fmpi_data
------------------------------------------------------------------------------*/
/**
* TODO
*
* @example{
* TODO
* }
*/
typedef struct fmpi_data {
enum fmpi_type type; //!< TODO
size_t dims_length[3]; //!< TODO
size_t dims_cnt; //!< TODO
void * start; //!< TODO
} fmpi_data;
/*==============================================================================
PUBLIC FUNCTION
==============================================================================*/
/*------------------------------------------------------------------------------
fmpi_data_1d()
------------------------------------------------------------------------------*/
/**
* TODO
*
* @param data : TODO
* @param x : TODO
*
* @expansion{
* TODO
* }
*
* @example{
* TODO
* }
*/
#define fmpi_data_1d(data, x) \
FMPI_GENERIC_FUNC(data, data_1d, FMPI_DATA_TYPES)(data, x, 0, 0)
/*------------------------------------------------------------------------------
fmpi_data_2d()
------------------------------------------------------------------------------*/
/**
* TODO
*
* @param data : TODO
* @param x : TODO
* @param y : TODO
*
* @expansion{
* TODO
* }
*
* @example{
* TODO
* }
*/
#define fmpi_data_2d(data, x, y) \
FMPI_GENERIC_FUNC(data, data_2d, FMPI_DATA_TYPES)(data, x, y, 0)
/*------------------------------------------------------------------------------
fmpi_data_3d()
------------------------------------------------------------------------------*/
/**
* TODO
*
* @param data : TODO
* @param x : TODO
* @param y : TODO
* @param z : TODO
*
* @expansion{
* TODO
* }
*
* @example{
* TODO
* }
*/
#define fmpi_data_3d(data, x, y, z) \
FMPI_GENERIC_FUNC(data, data_3d, FMPI_DATA_TYPES)(data, x, y, z)
/*==============================================================================
GUARD
==============================================================================*/
#endif // FMPI_DATA_H_20211228231216
// SPDX-License-Identifier: 0BSD
/*!
* @file
* @license{
* BSD Zero Clause License
*
* Copyright (c) 2022 by Raphael Bach
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
* }
*/
/*==============================================================================
GUARD
==============================================================================*/
#ifndef FMPI_DATA_INTERNAL_H_20211231184018
#define FMPI_DATA_INTERNAL_H_20211231184018
/*==============================================================================
INCLUDE
==============================================================================*/
// C Standard Library
#include <stddef.h> // size_t
// Internal
#include "fmpi_generic.h"
/*==============================================================================
MACRO
==============================================================================*/
#define FMPI_DATA_TYPES \
FMPI_TYPE_REAL
#define FMPI_DATA_DECLARATION(D, T) \
struct fmpi_data fmpi_data_##D##d_##T(T * data, size_t x, size_t y, size_t z)
FMPI_DECLARE_DIM_FUNCS(FMPI_DATA_DECLARATION, 1, FMPI_DATA_TYPES);
FMPI_DECLARE_DIM_FUNCS(FMPI_DATA_DECLARATION, 2, FMPI_DATA_TYPES);
FMPI_DECLARE_DIM_FUNCS(FMPI_DATA_DECLARATION, 3, FMPI_DATA_TYPES);
/*==============================================================================
GUARD
==============================================================================*/
#endif // FMPI_DATA_INTERNAL_H_20211231184018
// SPDX-License-Identifier: 0BSD
/*!
* @file
* @license{
* BSD Zero Clause License
*
* Copyright (c) 2022 by Raphael Bach
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
* }
*/
/*==============================================================================
INCLUDE
==============================================================================*/
// Own header
#include "fmpi_data.h"
// C Standard Library
#include <assert.h>
#include <stddef.h> // NULL, size_t
// Internal
#include "internal/generic/fmpi_type.h"
/*==============================================================================
PRIVATE FUNCTION DECLARATION
==============================================================================*/
static struct fmpi_data fmpi_data_create(
void * data, enum fmpi_type type, size_t dims_cnt, size_t x, size_t y, size_t z
);
/*==============================================================================
PUBLIC FUNCTION DEFINITION
==============================================================================*/
#define FMPI_DATA_DEFINITION(D, T) \
struct fmpi_data fmpi_data_##D##d_##T( \
T * const data, const size_t x, const size_t y, const size_t z \
){ \
assert(data != NULL); \
return fmpi_data_create(data, FMPI_TYPE_##T, D, x, y, z); \
}
FMPI_DEFINE_DIM_FUNCS(FMPI_DATA_DEFINITION, 1, FMPI_DATA_TYPES)
FMPI_DEFINE_DIM_FUNCS(FMPI_DATA_DEFINITION, 2, FMPI_DATA_TYPES)
FMPI_DEFINE_DIM_FUNCS(FMPI_DATA_DEFINITION, 3, FMPI_DATA_TYPES)
/*==============================================================================
PRIVATE FUNCTION DEFINITION
==============================================================================*/
static struct fmpi_data fmpi_data_create(
void * const data, const enum fmpi_type type, const size_t dims_cnt,
const size_t x, const size_t y, const size_t z
){
assert(data != NULL);
assert(dims_cnt >= 0 && dims_cnt <= 3);
return (struct fmpi_data){
.type = type,
.dims_length = {x, y, z},
.dims_cnt = dims_cnt,
.start = data
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment