-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding API functions to convert data buffers
- Loading branch information
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
This file is part of Task-Aware ACL and is licensed under the terms contained in the COPYING and COPYING.LESSER files. | ||
Copyright (C) 2021 Barcelona Supercomputing Center (BSC) | ||
*/ | ||
|
||
#include <acl/acl.h> | ||
#include <TACL.h> | ||
|
||
#include <cassert> | ||
|
||
#pragma GCC visibility push(default) | ||
|
||
extern "C" { | ||
|
||
aclError | ||
taclDoubleToFloat16Buffer(aclFloat16 *dst, const double *src, size_t count) | ||
{ | ||
if (count == 0) | ||
return ACL_ERROR_NONE; | ||
|
||
assert(dst != NULL); | ||
assert(src != NULL); | ||
|
||
for (size_t e = 0; e < count; ++e) { | ||
dst[e] = aclFloatToFloat16((float) src[e]); | ||
} | ||
|
||
return ACL_ERROR_NONE; | ||
} | ||
|
||
aclError | ||
taclFloatToFloat16Buffer(aclFloat16 *dst, const float *src, size_t count) | ||
{ | ||
if (count == 0) | ||
return ACL_ERROR_NONE; | ||
|
||
assert(dst != NULL); | ||
assert(src != NULL); | ||
|
||
for (size_t e = 0; e < count; ++e) { | ||
dst[e] = aclFloatToFloat16(src[e]); | ||
} | ||
|
||
return ACL_ERROR_NONE; | ||
} | ||
|
||
aclError | ||
taclFloat16ToDoubleBuffer(double *dst, const aclFloat16 *src, size_t count) | ||
{ | ||
if (count == 0) | ||
return ACL_ERROR_NONE; | ||
|
||
assert(dst != NULL); | ||
assert(src != NULL); | ||
|
||
for (size_t e = 0; e < count; ++e) { | ||
dst[e] = (double) aclFloat16ToFloat(src[e]); | ||
} | ||
|
||
return ACL_ERROR_NONE; | ||
} | ||
|
||
aclError | ||
taclFloat16ToFloatBuffer(float *dst, const aclFloat16 *src, size_t count) | ||
{ | ||
if (count == 0) | ||
return ACL_ERROR_NONE; | ||
|
||
assert(dst != NULL); | ||
assert(src != NULL); | ||
|
||
for (size_t e = 0; e < count; ++e) { | ||
dst[e] = aclFloat16ToFloat(src[e]); | ||
} | ||
|
||
return ACL_ERROR_NONE; | ||
} | ||
|
||
} // extern C | ||
|
||
#pragma GCC visibility pop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters