-
Notifications
You must be signed in to change notification settings - Fork 365
Add test for number of threads of OpenBLAS #3293
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
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8493a25
Add openblas_get_num_threads
filikat 285cb6f
Add runtime test for number of threads of openblas
filikat 3299481
Fix
filikat 35ea8ee
Check if BLAS_LIBRARIES contains string openblas
filikat 1d28d4a
Check provider string in lower case
filikat c2ea26b
Include Luke's comments
filikat e44f9fe
Simplify
filikat 7373cbc
Simplify susbtring search
filikat d1e6269
Remove isProvider
filikat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| #include "mycblas.h" | ||
|
|
||
| void highs_openblas_set_num_threads(int num_threads) { | ||
| int highs_openblas_set_num_threads(int num_threads) { | ||
| #if defined(HIPO_USES_OPENBLAS) | ||
| openblas_set_num_threads(num_threads); | ||
| return openblas_get_num_threads(); | ||
| #else | ||
| return -1; | ||
| #endif | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,4 +146,22 @@ bool is_end(std::string& str, size_t end, | |
| std::string first_word(std::string& str, size_t start); | ||
| size_t first_word_end(std::string& str, size_t start); | ||
|
|
||
| #if defined(_WIN32) || defined(_WIN64) | ||
| #include <string.h> // _strnicmp | ||
| #else | ||
| #include <strings.h> // strcasestr | ||
| #endif | ||
|
|
||
| // check if rhs is a substring of lhs, case insensitive | ||
| inline bool is_substring_case(const char* lhs, const char* rhs) { | ||
| #if defined(_WIN32) || defined(_WIN64) | ||
| size_t len = strlen(rhs); | ||
| for (; *lhs != '\0'; ++lhs) | ||
| if (_strnicmp(lhs, rhs, len) == 0) return true; | ||
| return false; | ||
| #else | ||
| return strcasestr(lhs, rhs) != nullptr; | ||
| #endif | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential suggestion? Note that inline bool is_substring_case(const char* str, const char* substring) {
if (!str || !substring) return false;
const size_t substring_len = strlen(substring);
if (substring_len == 0) return true;
const size_t str_len = strlen(str);
if (substring_len > str_len) return false;
const char* str_last_possible = str + str_len - substring_len;
for (; str <= str_last_possible; ++str) {
#if defined(_WIN32) || defined(_WIN64)
if (_strnicmp(str, substring, substring_len) == 0) return true;
#else
if (strncasecmp(str, substring, substring_len) == 0) return true;
#endif
}
return false;
} |
||
| } | ||
|
|
||
| #endif | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry, can you explain why this is needed?
Uh oh!
There was an error while loading. Please reload this page.
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.
If I use OpenBLAS by passing
libopenblas.sotoBLAS_LIBRARIES, CMake doesn't know which vendor is being used and so it doesn't set the BLAS metadata (i.e., the provider is unknown, etc). Crucially, this means thatHIPO_USES_OPENBLASis not set, and OpenBLAS runs multi-threaded, with a substantial reduction in performance.Maybe there are better ways of achieving this.
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.
Ah yeah, that makes sense. Previously in my tests I simply passed
BLA_VENDORas well, but probably not the nicest either.