-
Notifications
You must be signed in to change notification settings - Fork 88
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
port class 'process' to Windows #2277
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2277 +/- ##
========================================
Coverage 91.45% 91.45%
========================================
Files 433 433
Lines 16173 16179 +6
========================================
+ Hits 14791 14797 +6
Misses 1382 1382
|
src/CMakeLists.txt
Outdated
@@ -104,6 +103,11 @@ add_library(migraphx | |||
value.cpp | |||
verify_args.cpp | |||
) | |||
if(WIN32) | |||
target_sources(migraphx PRIVATE process_win32.cpp) |
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.
Dont create another source file, just add an ifdef to the process.cpp 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.
Ok, I will move it to the process.cpp
. I thought you asked me to do that in the Draft PR, but I might mistaken that with someone else asking me from a different component.
src/process_win32.cpp
Outdated
|
||
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_TRACE_CMD_EXECUTE) | ||
|
||
#define MIGRAPHX_PROCESS_BUFSIZE 4096 |
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.
Use a const variable.
Why arent you using #ifdef WIN32
#define MIGRAPHX_PCLOSE _pclose
#define MIGRAPHX_POPEN _popen
#else
#define MIGRAPHX_PCLOSE pclose
#define MIGRAPHX_POPEN popen
#endif
template <class F>
int exec(const std::string& cmd, const char* type, F f)
{
int ec = 0;
if(enabled(MIGRAPHX_TRACE_CMD_EXECUTE{}))
std::cout << cmd << std::endl;
auto closer = [&](FILE* stream) {
auto status = MIGRAPHX_PCLOSE(stream);
#ifdef WIN32
ec = status < 0 : -1 : 0;
#else
ec = WIFEXITED(status) ? WEXITSTATUS(status) : 0; // NOLINT
#endif
};
{
// TODO: Use execve instead of popen
std::unique_ptr<FILE, decltype(closer)> pipe(MIGRAPHX_POPEN(cmd.c_str(), type), closer); // NOLINT
if(not pipe)
MIGRAPHX_THROW("popen() failed: " + cmd);
f(pipe.get());
}
return ec;
} |
src/process_win32.cpp
Outdated
if(bSuccess == FALSE) | ||
return GetLastError(); | ||
|
||
DWORD dwRead, dwWritten; |
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 need to run clang tidy on this. These variables do not match the naming scheme we use.
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 will. I thought I did. This is Hungarian notation, the WIN32 API notation, and the most seen when someone is writing WIN32 API applications.
src/process_win32.cpp
Outdated
|
||
void process::exec() { impl->check_exec(impl->get_command()); } | ||
|
||
void process::write(std::function<void(process::writer)> pipe_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.
The pipe_in
variable is not used.
src/process_win32.cpp
Outdated
if(SetHandleInformation(&hRead_, HANDLE_FLAG_INHERIT, 0) == FALSE) | ||
throw GetLastError(); | ||
} | ||
|
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.
Need to add a move constructor, delete dopy constructor and add an assignment operator.
The MSDN documentation for |
More |
This build is OK for merge ✅ |
🔴bert_base_cased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output🔴distilgpt2_fp16: FAILED: MIGraphX is not within tolerance - check verbose output |
I see, it would be better to use tiny-process-library for this. The |
No description provided.