-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[MXNET-372] Add build flag for USE_F16C in CMake and clarify flag in make #10760
Conversation
CMakeLists.txt
Outdated
@@ -102,6 +103,10 @@ else(MSVC) | |||
else() | |||
set(SUPPORT_MSSE2 FALSE) | |||
endif() | |||
# If USE_F16C set to ON, mshadow checks support | |||
if(NOT USE_F16C) | |||
set(SUPPORT_MF16C FALSE) |
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.
Please print a message if this is getting disabled
@@ -132,10 +132,19 @@ endif | |||
ARCH := $(shell uname -a) | |||
ifneq (,$(filter $(ARCH), armv6l armv7l powerpc64le ppc64le aarch64)) | |||
USE_SSE=0 | |||
USE_F16C=0 |
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.
Please print a message if this is getting disabled
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.
That's not the behavior of any make flag though. Cmake does do that. Also for those devices there, F16C instruction set is absent. So it's not really a choice
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.
Well this is basically the first case, right? But I guess you're right, so it's fine that way.
CMakeLists.txt
Outdated
@@ -102,6 +104,29 @@ else(MSVC) | |||
else() | |||
set(SUPPORT_MSSE2 FALSE) | |||
endif() | |||
# For cross complication, turn off flag if target device does not support it | |||
if(USE_F16C AND NOT MSVC) |
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.
It is already guaranteed that MSVC is not present at this point
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.
Yeah corrected it thanks
@@ -86,6 +87,8 @@ if(MSVC) | |||
add_definitions(-DNNVM_EXPORTS) | |||
add_definitions(-DDMLC_STRICT_CXX11) | |||
add_definitions(-DNOMINMAX) | |||
set(SUPPORT_F16C FALSE) |
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.
This question might be stupid, but why are we disabling support on Windows? If this is a processor instruction, why does it depend on the OS?
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.
It's actually the MSVC (visual studio compiler) that's not yet supported. That doesn't support the current usage of f16c functions. One of the problems being that it does not have any specific link flag for f16c and the header file used does not exist. Future work, I'll see whether there are analogous features. Updated the message.
To use the feature we need not just processor, but also compiler support.
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.
Aaah I see, that makes sense. Thanks for elaborating
# For distributed training with fp16, this helps even if training on GPUs | ||
# If left empty, checks CPU support and turns it on. | ||
# For cross compilation, please check support for F16C on target device and turn off if necessary. | ||
USE_F16C = |
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.
Why aren't we adding similar logic like CMake for F16C support to Makefile ?
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.
That is in mshadow's makefile. I didn't add it here because it is always included in all code paths.
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.
IMO, we should try to do most work (including whether hardware has FP16 support, and compiler has Fp16 support) in MXNet itself and pass the flag to Mshadow, so that we reduce the dependency on mshadow. This way MXNet users won't be impacted if something in MShadow breaks. WDYT ?
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.
I think this is hard to pull off, considering it's a compile flag, and overcomplicates our build-process even further. As @hen pointed out on dev@, we should rather find a more permanent solution rather than trying to add even more hacks
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.
@rahul003 @marcoabreu I am okay with leaving this for now if its too much effort. Having said that, I think this stop-gap solution is better than what we have today if it means less pain for the user until we move to the more permanent solution. Considering that permanent solution (or atleast one of them) would be to move all the dmlc projects under apache (so that MXNet has better control on the repos), I don't see it happening anytime soon.
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.
I've added the logic of identifying the flag here in MXNet. MShadow's role now is to use that flag if defined and set the compiler flag. This means we have control over when to turn on or off the flag in MXNet
COMMAND grep F16C | ||
OUTPUT_VARIABLE CPU_SUPPORT_F16C) | ||
endif() | ||
if(NOT CPU_SUPPORT_F16C) |
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.
Is an unitiliazed variable automatically assumed as FALSE?
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.
We never set SUPPORT_MF16C explicitely to FALSE
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.
Yes that's right
…make (apache#10760) * add comments to makefile config * add f16c check in mxnet * update cmake * clarify * small updates * add message * add message * update msvc message * update mshadow * typo * only print message for MSVC if USE_F16C * improve build logic * update mshadow * remove def from amalgamation makefile * trigger CI
…make (apache#10760) * add comments to makefile config * add f16c check in mxnet * update cmake * clarify * small updates * add message * add message * update msvc message * update mshadow * typo * only print message for MSVC if USE_F16C * improve build logic * update mshadow * remove def from amalgamation makefile * trigger CI
…make (apache#10760) * add comments to makefile config * add f16c check in mxnet * update cmake * clarify * small updates * add message * add message * update msvc message * update mshadow * typo * only print message for MSVC if USE_F16C * improve build logic * update mshadow * remove def from amalgamation makefile * trigger CI
Description
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments