Skip to content

[hipTensor] hipTensor buildable on Windows#4893

Open
evedovelli wants to merge 9 commits intodevelopfrom
users/evedovel/hiptensor-windows
Open

[hipTensor] hipTensor buildable on Windows#4893
evedovelli wants to merge 9 commits intodevelopfrom
users/evedovel/hiptensor-windows

Conversation

@evedovelli
Copy link
Contributor

@evedovelli evedovelli commented Feb 25, 2026

Motivation

Add support to building hipTensor on Windows

Technical Details

  • Set specific commands for Windows in CMake
  • Replace /dev/null with NUL for Windows
  • The hiptensor-export.h file is generated with macros to allow exporting the public API
  • printf format options were changed to fix warnings on Windows
  • Multiple platform specific functions were replaced to fix warnings on Windows
  • Calls to hiptensor_options were removed from samples (as they are not part of the public API)

Test Plan

  • hipTensor builds on both Linux and Windows.
  • No test is broken on Linux.
  • Tests and programs with mode HIPTENSOR_ALGO_ACTOR_CRITIC are expected to fail on Windows for now. They require updated kernel IDs, to be obtained next.

Test Result

  • Passing according to the test plan.

Submission Checklist

@evedovelli evedovelli requested a review from Ryker0627 March 5, 2026 14:04
#include "include/logger.hpp"

// Cross-platform safe file opening
FILE* safeFopen(const char* filename, const char* mode)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not in hiptensor scope - intended?

@@ -52,7 +52,11 @@ namespace hiptensor
reset();

// Handle our own outputs
#ifdef _WIN32
Copy link
Contributor

Choose a reason for hiding this comment

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

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();
Copy link
Contributor

Choose a reason for hiding this comment

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

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Still compatible with CK ? CK is still using C++17

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Static buffer here being returned. Could change again before read.

Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, but does the INTERFACE obtained from llvm package take care of this already?

Copy link
Contributor

@cgmillette cgmillette left a comment

Choose a reason for hiding this comment

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

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();
Copy link
Contributor

Choose a reason for hiding this comment

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

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

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];"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants