Skip to content
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

a few c++ fixes to allow compilation on Windows #2282

Merged
merged 6 commits into from
Oct 11, 2023

Conversation

apwojcik
Copy link
Collaborator

@apwojcik apwojcik commented Oct 3, 2023

Missing header files (mostly <array>), a few preprocessor checks, and a portable way for checking attributes.

@apwojcik apwojcik added skip bot checks Skips the Performance and Accuracy CI tests Windows Related changes for Windows Environments labels Oct 3, 2023
@apwojcik apwojcik requested review from pfultz2 and umangyadav October 3, 2023 22:21
@@ -66,7 +66,7 @@ template <class PrivateMigraphTypeNameProbe>
std::string compute_type_name()
{
std::string name;
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does it requires check for clang. Aren't both exclusive if it is MSVC, it can't be clang.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Clang compiler on Windows is running in MSVC compatibility mode. It sets _MSC_VER, too. So, only checking _MSC_VER is not exclusive and is insufficient to differentiate between native MSVC and Clang. See detailed information https://clang.llvm.org/docs/MSVCCompatibility.html

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Merging #2282 (7e94dd5) into develop (c58e7d8) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 7e94dd5 differs from pull request most recent head 5bafb63. Consider uploading reports for the commit 5bafb63 to get more accurate results

@@             Coverage Diff             @@
##           develop    #2282      +/-   ##
===========================================
- Coverage    91.45%   91.45%   -0.01%     
===========================================
  Files          433      433              
  Lines        16175    16174       -1     
===========================================
- Hits         14793    14792       -1     
  Misses        1382     1382              
Files Coverage Δ
src/api/api.cpp 72.36% <ø> (ø)
src/api/include/migraphx/migraphx.hpp 98.63% <ø> (ø)
src/include/migraphx/auto_register.hpp 100.00% <ø> (ø)
src/include/migraphx/float_equal.hpp 100.00% <ø> (ø)
src/include/migraphx/generate.hpp 76.92% <ø> (ø)
src/include/migraphx/instruction_ref.hpp 100.00% <ø> (ø)
src/include/migraphx/matcher.hpp 97.13% <ø> (-0.02%) ⬇️
src/include/migraphx/op/nonmaxsuppression.hpp 98.47% <ø> (ø)
src/include/migraphx/op/roialign.hpp 99.16% <ø> (ø)
src/include/migraphx/optional.hpp 100.00% <ø> (ø)
... and 3 more

@apwojcik apwojcik requested a review from umangyadav October 4, 2023 13:30
@@ -39,6 +39,7 @@
#include <migraphx/json.hpp>
#include <migraphx/version.h>

#include <migraphx/instruction.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are we using the instruction class in this file? I cant seem to find it.

@@ -333,7 +333,7 @@ enum class color
bg_blue = 44,
bg_default = 49
};
inline std::ostream& operator<<(std::ostream& os, const color& c)
inline std::ostream& operator<<(std::ostream& os, [[maybe_unused]] const color& c)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a (void)c added under #ifdef _WIN32, so we can still get diagnostics for unused variable on the linux side.

@@ -26,6 +26,7 @@
#include <migraphx/program.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/eliminate_common_subexpression.hpp>
#include <migraphx/instruction.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont use the instruction class here either, at least as far as I can tell. If windows has problems with incomplete types then maybe we should add this header in instruction_ref.hpp under #ifdef _WIN32

@@ -44,8 +44,8 @@ MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_DUMP_TEST)

// An improved async, that doesn't block
template <class Function>
std::future<typename std::result_of<Function()>::type> detach_async(Function&& f,
bool parallel = true)
std::future<typename std::invoke_result_t<Function>> detach_async(Function&& f,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is invoke_result_t available on sles?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove typename since it isn't needed anymore

@apwojcik apwojcik force-pushed the windows_cxx_compilation branch from 7f30cef to e599b93 Compare October 7, 2023 23:25
@causten causten merged commit a50cb30 into develop Oct 11, 2023
14 of 15 checks passed
@causten causten deleted the windows_cxx_compilation branch January 5, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip bot checks Skips the Performance and Accuracy CI tests Windows Related changes for Windows Environments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants