[hipTensor] hipTensor buildable on Windows#4893
Conversation
| #include "include/logger.hpp" | ||
|
|
||
| // Cross-platform safe file opening | ||
| FILE* safeFopen(const char* filename, const char* mode) |
There was a problem hiding this comment.
This is not in hiptensor scope - intended?
| @@ -52,7 +52,11 @@ namespace hiptensor | |||
| reset(); | |||
|
|
|||
| // Handle our own outputs | |||
| #ifdef _WIN32 | |||
There was a problem hiding this comment.
To avoid this duplication in many files, maybe can have a helper function defined to silence the log file.
| std::mt19937 gen(rd()); | ||
| std::uniform_int_distribution<> dis(100000, 999999); | ||
|
|
||
| std::filesystem::path temp_dir = std::filesystem::temp_directory_path(); |
There was a problem hiding this comment.
Maybe on the off chance we should check if this file exists then re-roll?
| @@ -76,7 +86,7 @@ else() | |||
|
|
|||
| cmake_minimum_required(VERSION 3.14) | |||
| project(hiptensor_app) | |||
| add_compile_options(-std=c++17) | |||
| add_compile_options(-std=c++20) | |||
There was a problem hiding this comment.
Still compatible with CK ? CK is still using C++17
There was a problem hiding this comment.
It's compatible. hipTensor had already moved to C++20 but the samples were being built with C++17. The ask came originally from CK which was planning to move to C++20.
| size_t required_size; | ||
| if(getenv_s(&required_size, buffer, sizeof(buffer), name) == 0 && required_size > 0) | ||
| { | ||
| return buffer; |
There was a problem hiding this comment.
Static buffer here being returned. Could change again before read.
There was a problem hiding this comment.
Required size may need a check if it's bigger than the buffer.
| // Cross-platform safe file opening | ||
| FILE* safeFopen(const char* filename, const char* mode) | ||
| { | ||
| #ifdef _WIN32 |
There was a problem hiding this comment.
I might recommend to pull all the cross-platform utilities into a separate file to keep the macros isolated and unify the interface.
| @@ -25,11 +25,17 @@ | |||
| ############################################################################### | |||
|
|
|||
| # Find / configure LLVM | |||
| if(WIN32) | |||
| # On Windows, LLVM is built with static dependencies and has a transitive dependency | |||
There was a problem hiding this comment.
Not sure, but does the INTERFACE obtained from llvm package take care of this already?
cgmillette
left a comment
There was a problem hiding this comment.
Looks good so far, just a few things to address
| std::mt19937 gen(rd()); | ||
| std::uniform_int_distribution<> dis(100000, 999999); | ||
|
|
||
| std::filesystem::path temp_dir = std::filesystem::temp_directory_path(); |
There was a problem hiding this comment.
We did not use std::filesystem since it was not supported on some CI OSes.
But it has been a while. It will be great if all OSes support it now.
| @@ -49,6 +51,24 @@ namespace hiptensor | |||
| return (numerator + divisor - 1) / divisor; | |||
| } | |||
|
|
|||
| // Cross-platform safe environment variable access | |||
| inline const char* getEnvironmentVariable(const char* name) | |||
There was a problem hiding this comment.
Suggest this function return a std::string so that you can use a std::string to replace the fixed size buffer "static thread_local char buffer[256];"
Motivation
Add support to building hipTensor on Windows
Technical Details
Test Plan
Test Result
Submission Checklist