Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
mpim-sw
libcdi
Commits
c8c0bbec
Commit
c8c0bbec
authored
10 months ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Added float16.h
parent
3b450c40
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!85
M214003/develop
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/CMakeLists.txt
+1
-0
1 addition, 0 deletions
src/CMakeLists.txt
src/Makefile.am
+1
-0
1 addition, 0 deletions
src/Makefile.am
src/binary.c
+10
-0
10 additions, 0 deletions
src/binary.c
src/binary.h
+5
-0
5 additions, 0 deletions
src/binary.h
src/float16.h
+21
-0
21 additions, 0 deletions
src/float16.h
with
38 additions
and
0 deletions
src/CMakeLists.txt
+
1
−
0
View file @
c8c0bbec
...
...
@@ -50,6 +50,7 @@ list( APPEND cdi_src_files
exse.h
extra.h
extralib.c
float16.h
file.c
file.h
gaussian_latitudes.c
...
...
This diff is collapsed.
Click to expand it.
src/Makefile.am
+
1
−
0
View file @
c8c0bbec
...
...
@@ -127,6 +127,7 @@ libcdi_la_SOURCES = \
exse.h
\
extra.h
\
extralib.c
\
float16.h
\
file.c
\
file.h
\
gaussian_latitudes.c
\
...
...
This diff is collapsed.
Click to expand it.
src/binary.c
+
10
−
0
View file @
c8c0bbec
...
...
@@ -170,9 +170,19 @@ binWriteFlt64(int fileID, int byteswap, size_t size, double *ptr)
{
if
(
byteswap
)
swap8byte
(
ptr
,
size
);
fileWrite
(
fileID
,
(
void
*
)
ptr
,
8
*
size
);
return
0
;
}
#ifdef HAVE_FLOAT16
int
binWriteFlt16
(
int
fileID
,
int
byteswap
,
size_t
size
,
_Float16
*
ptr
)
{
if
(
byteswap
)
swap4byte
(
ptr
,
size
);
fileWrite
(
fileID
,
(
void
*
)
ptr
,
2
*
size
);
return
0
;
}
#endif
/*
* Local Variables:
* c-file-style: "Java"
...
...
This diff is collapsed.
Click to expand it.
src/binary.h
+
5
−
0
View file @
c8c0bbec
...
...
@@ -3,6 +3,7 @@
#include
<stdio.h>
#include
<inttypes.h>
#include
"float16.h"
#ifndef HOST_ENDIANNESS
#ifdef __cplusplus
...
...
@@ -30,6 +31,10 @@ int binWriteInt64(int fileID, int byteswap, size_t size, int64_t *ptr);
int
binWriteFlt32
(
int
fileID
,
int
byteswap
,
size_t
size
,
float
*
ptr
);
int
binWriteFlt64
(
int
fileID
,
int
byteswap
,
size_t
size
,
double
*
ptr
);
#ifdef HAVE_FLOAT16
int
binWriteFlt16
(
int
fileID
,
int
byteswap
,
size_t
size
,
_Float16
*
ptr
);
#endif
#endif
/* BINARY_H */
/*
* Local Variables:
...
...
This diff is collapsed.
Click to expand it.
src/float16.h
0 → 100644
+
21
−
0
View file @
c8c0bbec
#ifndef FLOAT16_H
#define FLOAT16_H
// CAUTION: __is_identifier behaves opposite how you would expect!
// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
// the compiler and '1' otherwise.
// borrowed from LLVM __config header under Apache license 2.
// (https://www.mend.io/blog/top-10-apache-license-questions-answered/)
#ifndef __is_identifier // Optional of course.
#define __is_identifier(x) 1 // Compatibility with non-clang compilers.
#endif
// More sensible macro for keyword detection
#define __has_keyword(__x) !(__is_identifier(__x))
// map a half float type, if available, to _OptionalHalfFloatType
#if __has_keyword(_Float16)
#define HAVE_FLOAT16
#endif
#endif
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