Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fmpi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
raphael.bach
fmpi
Commits
75175922
Verified
Commit
75175922
authored
3 years ago
by
raphael.bach
Browse files
Options
Downloads
Patches
Plain Diff
Add `fmpi_futhark_new_data()`
parent
78c6fb32
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/internal/fmpi_futhark.h
+9
-1
9 additions, 1 deletion
include/internal/fmpi_futhark.h
include/internal/generic/fmpi_futhark_generic.h
+12
-3
12 additions, 3 deletions
include/internal/generic/fmpi_futhark_generic.h
src/fmpi_futhark.c
+31
-3
31 additions, 3 deletions
src/fmpi_futhark.c
with
52 additions
and
7 deletions
include/internal/fmpi_futhark.h
+
9
−
1
View file @
75175922
...
...
@@ -29,7 +29,8 @@
// C Standard Library
// Internal
#include
"fmpi_error.h"
#include
"generic/fmpi_futhark_generic.h"
#include
"internal/generic/fmpi_futhark_generic.h"
#include
"internal/generic/fmpi_type.h"
/*==============================================================================
STRUCT
==============================================================================*/
...
...
@@ -127,6 +128,13 @@ int fmpi_futhark_sync(const struct fmpi_futhark_ctx * ctx);
* - \p{func} must not be `NULL`.
*/
_Bool
fmpi_futhark_check_error
(
const
struct
fmpi_futhark_ctx
*
ctx
,
const
char
*
func
);
/*------------------------------------------------------------------------------
fmpi_futhark_new_data()
------------------------------------------------------------------------------*/
void
*
fmpi_futhark_new_data
(
const
struct
fmpi_futhark_ctx
*
ctx
,
const
void
*
data
,
enum
fmpi_type
type
,
size_t
dim_cnt
,
size_t
x
,
size_t
y
,
size_t
z
);
/*==============================================================================
MACRO
==============================================================================*/
...
...
This diff is collapsed.
Click to expand it.
include/internal/generic/fmpi_futhark_generic.h
+
12
−
3
View file @
75175922
...
...
@@ -28,7 +28,10 @@
==============================================================================*/
// C Standard Library
#include
<stddef.h>
// size_t
// External
#include
"../../../external/cpl/cpl_map.h"
// Internal
#include
"../fmpi_common.h"
#include
"fmpi_generic.h"
/*==============================================================================
MACRO
...
...
@@ -38,6 +41,12 @@ struct fmpi_futhark_ctx;
#define FMPI_FUTHARK_TYPES \
FMPI_TYPE_REAL
#define FMPI_PRIV_FUTHARK_ARRAY_ENTRY(D, T) \
[FMPI_TYPE_##T * (FMPI_DIM_MAX) + ((D)-1)] = fmpi_futhark_new_##D##d_##T
#define FMPI_FUTHARK_ARRAY_ENTRY_LIST(D) \
CPL_MAP_FIXED(FMPI_PRIV_FUTHARK_ARRAY_ENTRY, CPL_COMMA, (D), FMPI_FUTHARK_TYPES)
#if defined(__GNUC__) || defined(__GNUG__)
_Pragma
(
"GCC diagnostic ignored
\"
-Wunused-parameter
\"
"
)
_Pragma
(
"GCC diagnostic push"
)
...
...
@@ -62,11 +71,11 @@ struct fmpi_futhark_ctx;
futhark_new_##T##_3d(ctx, array, (int64_t)(x), (int64_t)(y), (int64_t)(z));
#define FMPI_FUTHARK_DECLARATION(D, T) \
struct futhark_##T##_##D##
d * fmpi_futhark_new_##D##d_##T( \
const struct fmpi_futhark_ctx * ctx, const
T
* array, size_t x, size_t y, size_t z \
voi
d * fmpi_futhark_new_##D##d_##T( \
const struct fmpi_futhark_ctx * ctx, const
void
* array, size_t x, size_t y, size_t z \
); \
void fmpi_futhark_free_##D##d_##T( \
const struct fmpi_futhark_ctx * ctx,
struct futhark_##T##_##D##
d * array \
const struct fmpi_futhark_ctx * ctx,
voi
d * array \
)
FMPI_DECLARE_DIM_FUNCS
(
FMPI_FUTHARK_DECLARATION
,
1
,
FMPI_FUTHARK_TYPES
);
...
...
This diff is collapsed.
Click to expand it.
src/fmpi_futhark.c
+
31
−
3
View file @
75175922
...
...
@@ -29,9 +29,22 @@
#include
<stdint.h>
// int64_t
#include
<stdlib.h>
// Internal
#include
"internal/fmpi_common.h"
#include
"internal/fmpi_ctx.h"
#include
"internal/fmpi_futhark_entry.h"
#include
"internal/generic/fmpi_generic.h"
/*==============================================================================
STATIC
==============================================================================*/
typedef
void
*
(
*
fmpi_futhark_new_data_func
)(
const
struct
fmpi_futhark_ctx
*
ctx
,
const
void
*
data
,
size_t
x
,
size_t
y
,
size_t
z
);
static
const
fmpi_futhark_new_data_func
fmpi_futhark_new_data_func_list
[]
=
{
FMPI_FUTHARK_ARRAY_ENTRY_LIST
(
1
),
FMPI_FUTHARK_ARRAY_ENTRY_LIST
(
2
),
FMPI_FUTHARK_ARRAY_ENTRY_LIST
(
3
)
};
/*==============================================================================
MACRO
==============================================================================*/
...
...
@@ -127,10 +140,25 @@ _Bool fmpi_futhark_check_error(
}
return
false
;
}
/*------------------------------------------------------------------------------
fmpi_futhark_new_data()
------------------------------------------------------------------------------*/
void
*
fmpi_futhark_new_data
(
const
struct
fmpi_futhark_ctx
*
ctx
,
const
void
*
const
data
,
const
enum
fmpi_type
type
,
const
size_t
dim_cnt
,
const
size_t
x
,
const
size_t
y
,
const
size_t
z
){
assert
(
ctx
!=
NULL
);
assert
(
data
!=
NULL
);
assert
(
dim_cnt
<=
FMPI_DIM_MAX
);
const
size_t
idx
=
(
type
*
(
FMPI_DIM_MAX
)
+
((
dim_cnt
)
-
1
));
return
fmpi_futhark_new_data_func_list
[
idx
](
ctx
,
data
,
x
,
y
,
z
);
}
#define FMPI_FUTHARK_DEFINITION(D, T) \
struct futhark_##T##_##D##d * fmpi_futhark_new_##D##d_##T( \
const struct fmpi_futhark_ctx * const ctx, const T * const array, size_t x, size_t y, size_t z \
void * fmpi_futhark_new_##D##d_##T( \
const struct fmpi_futhark_ctx * const ctx, const void * const array, \
const size_t x, const size_t y, const size_t z \
){ \
assert(ctx != NULL); \
assert(array != NULL); \
...
...
@@ -142,7 +170,7 @@ struct futhark_##T##_##D##d * fmpi_futhark_new_##D##d_##T( \
return data; \
}\
void fmpi_futhark_free_##D##d_##T( \
const struct fmpi_futhark_ctx * const ctx,
struct futhark_##T##_##D##
d * const array \
const struct fmpi_futhark_ctx * const ctx,
voi
d * const array \
){ \
assert(ctx != NULL); \
assert(array != NULL); \
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment