-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add Windows support #930
Add Windows support #930
Conversation
Remove isatty for windows: ``` E:\scale\external\celeritas\src\corecel\io\ColorUtils.cc(13): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory ``` String view iterator is not a const char*: ``` E:\scale\external\celeritas\src\corecel\io\StringUtils.cc(66): note: 'std::basic_string_view<char,std::char_traits<char>>:: basic_string_view(const char *const ,const std::basic_string_view<char,std::char_traits<char>>::size_type) noexcept': canno t convert argument 1 from 'std::_String_view_iterator<_Traits>' to 'const char *const ' with [ _Traits=std::char_traits<char> ] ``` 'environ' is a macro on windows (boo) ``` E:\scale\external\celeritas\src\corecel\sys\Environment.cc(31): error C2267: '__p__environ': static functions with block scope are illegal ``` psapi must be included *after* windows.h ``` C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um\psapi.h(132): error C2146: syntax error: missing ';' before identifier 'WINAPI' ``` ptrdiff_t is implicitly converted to long ``` E:\scale\external\celeritas\src\corecel\sys\ScopedMem.cc(125): warning C4244: 'argument': conversion from 'ptrdiff_t' to 'long', possible loss of dat a ```
This might have relied on compiler optimization stopping the template instantiation early. With 'if constexpr' this should always be correct.
``` E:\scale\external\celeritas\test\corecel\math\NumericLimits.test.cc(40): error C2124: divide or mod by zero ```
``` E:\scale\external\celeritas\src\celeritas/field/DormandPrinceStepper.hh(144): warning C4146: unary minus operator applied to unsigned type, result st ill unsigned ```
``` E:\scale\external\celeritas\src\celeritas\geo\detail\BoundaryAction.hh(37): warning C4250: 'celeritas::detail::BoundaryAction': inherits 'celeritas::C oncreteAction::celeritas::ConcreteAction::action_id' via dominance E:\scale\external\celeritas\src\celeritas/global/ActionInterface.hh(151): note: see declaration of 'celeritas::ConcreteAction::action_id' E:\scale\external\celeritas\src\celeritas\geo\detail\BoundaryAction.hh(37): warning C4250: 'celeritas::detail::BoundaryAction': inherits 'celeritas::C oncreteAction::celeritas::ConcreteAction::label' via dominance E:\scale\external\celeritas\src\celeritas/global/ActionInterface.hh(154): note: see declaration of 'celeritas::ConcreteAction::label' E:\scale\external\celeritas\src\celeritas\geo\detail\BoundaryAction.hh(37): warning C4250: 'celeritas::detail::BoundaryAction': inherits 'celeritas::C oncreteAction::celeritas::ConcreteAction::description' via dominance ```
There are weird scoping rules about static const for lambdas. ``` E:\scale\external\celeritas\test\celeritas\track\TrackInit.test.cc(417): error C3493: 'num_tracks' cannot be implicitly captured because no default ca pture mode has been specified ```
``` E:\scale\external\celeritas\app\celer-sim\Transporter.cc(70): error C2065: 'SIGUSR2': undeclared identifier ```
``` E:\scale\external\celeritas\test\celeritas\em\UrbanMsc.test.cc(281): error C2397: conversion from 'const int' to 'T' requires a narrowing conversion with [T=celeritas::real_type ] ``` More conversion warnings
``` E:\scale\external\celeritas\test\corecel\cont\Range.test.cc(215): error: Value of: (std::is_same<std::underlying_type<pokemon::Pokemon>::type, unsigne d int>::value) Actual: false Expected: true ```
@@ -44,11 +46,13 @@ bool use_color() | |||
// Color is explicitly enabled | |||
return true; | |||
} | |||
#ifndef _WIN32 |
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 there a Windows
equivalent to tell if there a terminal attached or not?
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'm not sure at all... even if there is, the Windows terminals don't natively support ANSI color sequences (only when running through something like git-bash). Either way, for the use cases of concern to SCALE, we won't be running through the command line.
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.
humm ... isn't the code then
#ifdef _WIN32
return false;
#else
... existing code...
#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.
You could be running through git-bash but compiled against only regular windows. (This is how I was testing.) In that case the ANSI sequences are processed correctly because git-bash defines the TERM
variable.
src/corecel/sys/MemRegistry.hh
Outdated
@@ -20,12 +20,12 @@ namespace celeritas | |||
//! SI prefix for multiples of 1024 | |||
struct Kibi | |||
{ | |||
static CELER_CONSTEXPR_FUNCTION int value() { return 1024; } | |||
static CELER_CONSTEXPR_FUNCTION long int value() { return 1024; } |
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.
What the purpose of that change? Rather than long int
, do we mean int64_t
? (And almost more important how to we remember to use the right type in similar future construct?)
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.
Int is 32-bit on windows and I wanted something "long"er. I try to steer away from special integer types for JSON I/O though now that I think about it, I'm not sure why. I'll unify all this.
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 wanted something "long"er
Why does it matter here?
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.
Because any memory change over 2GB overflows int
on windows.
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.
right, I should have look up the usage :).
But then why using size_t
isn't the right type? (or make_signed<size_t>
)?
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 was the conversion between size_t and ptrdiff_t that was throwing me off. I've replaced it all with size_t.
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.
LGTM. Thanks.
86849c9
to
21ac428
Compare
This adds non-CI-tested support for building and running on Windows. (Compiled with MS Visual Studio 2022, 14.37.32822.) All applications and tests build and pass in a near-minimal (only JSON and Googletest enabled) configuration.
Key compatibility issues are:
if constexpr
rather than triad to fix compiler crash from template recursion. Before this,ipow
relied on an optimization trick.SIGUSR2
andisatty
string_view::const_iterator
aschar const*
Celeritas is about to become a dependency of SCALE to use ORANGE for CPU and GPU geometry. SCALE must compile on Windows.