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

Add HIP test host-min-max #100

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yxsamliu
Copy link
Contributor

No description provided.

void compareResults(T1 hipResult, T2 stdResult, const std::string& testName) {
using CommonType = typename std::common_type<T1, T2>::type;
if (static_cast<CommonType>(hipResult) != static_cast<CommonType>(stdResult)) {
std::cerr << testName << " mismatch: HIP result " << hipResult << " (" << demangle(typeid(hipResult).name()) << "), std result " << stdResult << " (" << demangle(typeid(stdResult).name()) << ")" << std::endl;
Copy link
Member

Choose a reason for hiding this comment

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

Those long lines could use some wrapping. It may be a good idea to just clang-format the sources.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

#include <cstdlib> // For std::abort
#include <typeinfo> // For typeid

std::string demangle(const char* name) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I'd just use some kind of map here. Else/ifs with explicit conversion to string just clutter things up. Not that it matters much here, but...

std::string demangle(const char *name) {
    static std::pair<std::string, std::string> map[] = {{"f", "float"}, {"i", "int"}};
    for (auto p : map) {
        if (p.first == name)
           return p.second;
    }
    return name;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

int main() {
checkHipCall(hipSetDevice(0), "hipSetDevice failed");

runTest(10uLL, -5LL); // Testing with unsigned int and long long
Copy link
Member

Choose a reason for hiding this comment

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

I do not know what would be the correct answer here, unless the user explicitly tells me that they do want to compare a negative signed value as an unsigned one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this assumes CUDA compatibility, which assumes the result of x<y?x:y with the implicit signed-to-unsigned conversion is correct. I can put a comment for clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants