-
Notifications
You must be signed in to change notification settings - Fork 127
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
[ON HOLD] Unit Tests for CPX mode #1319
base: develop
Are you sure you want to change the base?
Conversation
int getDeviceMode (bool *cpxMode){ | ||
// Prepare parent->child pipe | ||
int pipefd[2]; | ||
if (pipe(pipefd) == -1) | ||
{ | ||
ERROR("Unable to create parent->child pipe for getting the device mode\n"); | ||
return TEST_FAIL; | ||
} | ||
pid_t pid = fork(); | ||
if (0 == pid) | ||
{ | ||
bool iscpxMode = false; | ||
try { | ||
std::string log = execCommand("rocm-smi --showcomputepartition"); | ||
bool foundCPX = log.find("CPX") != std::string::npos; | ||
if (foundCPX) { | ||
iscpxMode = true; | ||
} | ||
} catch (const std::exception& e) { | ||
std::cerr << "Error: " << e.what() << std::endl; | ||
return 1; | ||
} | ||
if (write(pipefd[1], &iscpxMode, sizeof(iscpxMode)) != sizeof(iscpxMode)) return TEST_FAIL; | ||
close(pipefd[0]); | ||
close(pipefd[1]); | ||
exit(EXIT_SUCCESS); | ||
} | ||
else { | ||
int status; | ||
if (read(pipefd[0], cpxMode, sizeof(*cpxMode)) != sizeof(*cpxMode)) return TEST_FAIL; | ||
waitpid(pid, &status, 0); | ||
assert(!status); | ||
close(pipefd[0]); | ||
close(pipefd[1]); | ||
} | ||
return TEST_SUCCESS; | ||
return 0; | ||
} |
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 curious why rocm-smi
is run in a fork process?
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 we cannot use HIP call prior to launching unless it is inside another child process. You can refer to line 207 for this comment. The same procedure is used for other features such as finding the architecture of the system as in line 211.
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.
In your case, I think popen
already forks and creates a pipe internally, so you may not need your own fork. If so, getDeviceMode
and getDevicePriority
can be simplified.
} | ||
if(isGfx94) { | ||
bool cpxMode = false; | ||
getDeviceMode(&cpxMode); |
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 return value of getDeviceMode
is never used, so if it can be simplified as I've suggested, you could rename it to isDeviceCpxMode
and return bool
.
Details
Work item: "Internal"
What were the changes?
Enabling Unit Tests to run for CPX mode.
Why were the changes made?
Currently UT tests all possible numbers of GPUs up to 16. If same scheme is used to test CPX mode, UT will take forever to complete.
How was the outcome achieved?
Additional Documentation:
None.
Approval Checklist
Do not approve until these items are satisfied.