-
Notifications
You must be signed in to change notification settings - Fork 406
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
Deprecate InitArguments
struct and replace it with InitializationSettings
#5135
Conversation
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 conceptionally (interface-wise) good. I'm not quite sure if we really need the getter-functions but they seem to be good for testing at least.
As discussed elsewhere, we also need to see what issues we would need to revolve for interfaces taking the InitArguments
right now.
I would be in favor of adding the getters as well. This obviously gets complicated for the cases where the variable is not set (what to return? the optional itself?). |
I like this interface as well. While I don't see a need for getters, maybe a way to print out the configuration? |
I would favor getters and making the members private, so that the compiler will enforce that all modifications go through the setters, rather than doing weird stuff with clunky name modifications in macros. |
InitArguments
struct and replace it with <PLACEHOLDER>InitArguments
struct and replace it with InitializationSettings
7385dbf
to
fd19f91
Compare
fff711c
to
6840b43
Compare
6840b43
to
45a5850
Compare
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.
Looks like a guard for the deprecated struct is missing:
/var/jenkins/workspace/Kokkos/core/unit_test/TestInitializationSettings.cpp:56:11: error: no type named 'InitArguments' in namespace 'Kokkos'
Kokkos::InitArguments arguments;
~~~~~~~~^
1 error generated.
core/unit_test/CMakeFiles/KokkosCore_UnitTest_Default.dir/build.make:94: recipe for target 'core/unit_test/CMakeFiles/KokkosCore_UnitTest_Default.dir/TestInitializationSettings.cpp.o' failed
45a5850
to
fa2e410
Compare
// Prevent "unused variable" warning for 'args' input struct. If | ||
void OpenMPTargetSpaceInitializer::initialize( | ||
const InitializationSettings& settings) { | ||
// Prevent "unused variable" warning for 'settings' input struct. If | ||
// Serial::initialize() ever needs to take arguments from the input |
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.
Wrong comment. It should be OpenMPTarget::initialize()
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.
You're right I hadn't seen it. Considering that I will remove that code in #5144, I would rather not fix here though.
@@ -100,45 +99,105 @@ void declare_configuration_metadata(const std::string& category, | |||
metadata_map[category][key] = value; | |||
} | |||
|
|||
ExecSpaceManager& ExecSpaceManager::get_instance() { | |||
void combine(Kokkos::InitializationSettings& out, | |||
Kokkos::InitializationSettings const& in) { |
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 do you need this function?
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 replaces void combine(InitArguments& out, InitArguments const& in)
and we use it in initialize(InitializationSettings const&)
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.
Overall, this looks good to me. Just a few questions/suggestions/nitpicks.
#define KOKKOS_IMPL_COMBINE_SETTING(NAME) \ | ||
if (in.has_##NAME()) { \ | ||
out.set_##NAME(in.get_##NAME()); \ | ||
} \ | ||
static_assert(true, "no-op to require trailing semicolon") | ||
KOKKOS_IMPL_COMBINE_SETTING(num_threads); | ||
KOKKOS_IMPL_COMBINE_SETTING(device_id); | ||
KOKKOS_IMPL_COMBINE_SETTING(num_devices); | ||
KOKKOS_IMPL_COMBINE_SETTING(skip_device); | ||
KOKKOS_IMPL_COMBINE_SETTING(disable_warnings); | ||
KOKKOS_IMPL_COMBINE_SETTING(tune_internals); | ||
KOKKOS_IMPL_COMBINE_SETTING(tool_help); | ||
KOKKOS_IMPL_COMBINE_SETTING(tool_lib); | ||
KOKKOS_IMPL_COMBINE_SETTING(tool_args); | ||
#undef KOKKOS_IMPL_COMBINE_SETTING |
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.
Nitpick: I know you didn't introduce this in this pull request, but I would prefer avoiding macros here and rather do
#define KOKKOS_IMPL_COMBINE_SETTING(NAME) \ | |
if (in.has_##NAME()) { \ | |
out.set_##NAME(in.get_##NAME()); \ | |
} \ | |
static_assert(true, "no-op to require trailing semicolon") | |
KOKKOS_IMPL_COMBINE_SETTING(num_threads); | |
KOKKOS_IMPL_COMBINE_SETTING(device_id); | |
KOKKOS_IMPL_COMBINE_SETTING(num_devices); | |
KOKKOS_IMPL_COMBINE_SETTING(skip_device); | |
KOKKOS_IMPL_COMBINE_SETTING(disable_warnings); | |
KOKKOS_IMPL_COMBINE_SETTING(tune_internals); | |
KOKKOS_IMPL_COMBINE_SETTING(tool_help); | |
KOKKOS_IMPL_COMBINE_SETTING(tool_lib); | |
KOKKOS_IMPL_COMBINE_SETTING(tool_args); | |
#undef KOKKOS_IMPL_COMBINE_SETTING | |
// clang-format off | |
if (in.has_num_threads) out.set_num_threads(in.get_num_threads); | |
if (in.has_device_id) out.set_device_id(in.get_device_id); | |
[...] | |
// clang-format off |
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.
Not changing as I do not agree with the suggestion
Kokkos::Impl::InitializationSettingsHelper<std::string>::storage_type const | ||
Kokkos::Impl::InitializationSettingsHelper<std::string>::unspecified = | ||
"some string we don't expect user would ever provide"; |
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.
Shouldn't this be in its own *.cc
file since you already split the implementation of the struct into its own header file?
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.
Considering that we will drop it when C++17 is available, I'd rather not create a source file.
#define KOKKOS_IMPL_INIT_ARGS_DATA_MEMBER(NAME) \ | ||
impl_do_not_use_i_really_mean_it_##NAME##_ | ||
|
||
#define KOKKOS_IMPL_INIT_ARGS_DATA_MEMBER_TYPE(NAME) impl_##NAME##_type |
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 find the code here with all the macros very hard to read and would rather see more boilerplate.
For these two macros, in particular, I don't see much of a reason to not replace them with their definition.
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 was introduced before we added the getters and was really handy then. I would rather wait until C++17 is available to refactor. Then I will get rid of the member type and "inline" all data member references.
…nitiliazationSettings setters in converting constructor
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.
Good enough for me.
…nit_args_struct
// Serial::initialize() ever needs to take arguments from the input | ||
// struct, you may remove this line of code. | ||
(void)args; | ||
(void)settings; |
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.
Minor: I know it wasn't done like this originally, but why not just comment out the variable name in the function declaration?
OpenMPTarget timeout is clearly unrelated |
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
compatibility update for kokkos deprecated code removal, corresponding to kokkos/kokkos#5135
I drafted a replacement struct for
InitArguments
.At this time it is still missing the implicit conversion fromI haven't put any thought into the name yet. I am looking for early feedback on the design, that is public member function to set the values that can be chained and "private" macros to query if a variable is set and and get its value.InitArguments
.