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

[SWDEV-492880] Add ROCm path for hipRTC #3391

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/comgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,19 @@ void BuildHip(const std::string& name,
}))
opts.push_back("-std=c++17");

const char* rocm_path = std::getenv("ROCM_PATH");
Copy link
Collaborator

@BrianHarrisonAMD BrianHarrisonAMD Nov 20, 2024

Choose a reason for hiding this comment

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

There is an error on this line for the checker, I think we need to use the MIOpen Macros instead.

Ex:

// at top of file
MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_CUSTOM_CACHE_DIR)

// etc.

// usage example
const auto& custom = env::value(MIOPEN_CUSTOM_CACHE_DIR);
if(!custom.empty())
{
    p = ExpandUser(custom);
}

It will also be a string type, and you can avoid some of the below manual conversions to std::string.

Copy link
Contributor

@CAHEK7 CAHEK7 Nov 21, 2024

Choose a reason for hiding this comment

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

And the most important part, it caches the results, that all the consequence compilations with get that path much faster.

Also it supports default values, so path.empty() check is not required - it either returns user-provided path or default /opt/rocm and that result is cached.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @CAHEK7 , thank you very much for providing comments and instructions. There would be some cases where ROCM_PATH is not there at all. I checked with a clean installation of ROCm6.2.4. No ROCM_PATH...
So I think give a default value here is useful here to use hipRTC out of box, although we can capture this built options strings through logs printed below and add ROCM_PATH manually.

if(rocm_path == nullptr || std::string(rocm_path).empty())
{
rocm_path = "/opt/rocm";
}
opts.push_back(std::string("-I") + rocm_path + "/include");

MIOPEN_LOG_I("HIPRTC compile options:");
for(const auto& opt : opts)
{
MIOPEN_LOG_I(opt);
}

HiprtcProgram prog(name, text);
prog.Compile(opts);
prog.GetCode(binary);
Expand Down