-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GPU/OpenCL] Check fp16(half) support #2608
Conversation
Added check for fp16 support on OpenCL. Will show proper message if not found. Signed-off-by: Debadri Samaddar <[email protected]>
📝 TAOS-CI Version: 1.5.20200925. Thank you for submitting PR #2608. Please a submit 1commit/1PR (one commit per one PR) policy to get comments quickly from reviewers. Your PR must pass all verificiation processes of cibot before starting a review process from reviewers. If you are new member to join this project, please read manuals in documentation folder and wiki page. In order to monitor a progress status of your PR in more detail, visit http://ci.nnstreamer.ai/. |
cibot: @s-debadri, nntrainer/opencl/opencl_context_manager.cpp includes bug(s). Please fix incorrect coding constructs in your commit before entering a review process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@s-debadri, 💯 All CI checkers are successfully verified. Thanks.
@@ -155,6 +155,31 @@ bool ContextManager::CreateDefaultGPUDevice() { | |||
device_id_ = devices[0]; | |||
platform_id_ = platform_id_; | |||
|
|||
#ifdef ENABLE_FP16 | |||
// check for fp16 (half) support available on device |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which half-precision does it support? _Float16
, __fp16
, or half
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally all of _Float16
, __fp16
and half
can be used interchangeably inside kernels when cl_khr_fp16
extension is enabled. I have tested with __fp16
and half
myself, they worked exactly the same. However I did not test with __Float16
but it is supported by OpenCL 2.1 or later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
half
is specifically designed for use in OpenCL kernels. Some are architecture specific (e.g: __fp16
for ARM). So half
will be more portable and benefit from further optimizations..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the clarification! if using the half
type has advantages, should it be added as a tensor data type?
nntrainer/api/ccapi/include/tensor_dim.h
Lines 25 to 31 in 1a6537f
#ifdef ENABLE_FP16 | |
#ifdef USE__FP16 | |
#define _FP16 __fp16 | |
#else | |
#define _FP16 _Float16 | |
#endif | |
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
half
will only work inside OpenCL kernels. So I think adding it to tensor data type won't be useful in this scenario.
Added check for OpenCL fp16
half
support on device.Will show proper message if not found.
To use fp16 enable
cl_khr_fp16
as following with the kernels.Signed-off-by: Debadri Samaddar [email protected]