complex gemm implementation#626
Conversation
There was a problem hiding this comment.
rocblas_isnan() should be applied to arg.beta rather than arg.get_beta<T>().
There was a problem hiding this comment.
Understand, I correct it on third commit "update complex change".
But, do we have to check nan for betai too??
It is only used in complex type.
Should we use another template function for is_nan check??
There was a problem hiding this comment.
is_nan should be defined for rocblas_float_complex and rocblas_double_complex, which will return true if either the real or imaginary part is NaN.
There was a problem hiding this comment.
But since arg.beta and arg.betai are always floating-point types, you can use std::isnan(arg.beta) || std::isnan(arg.betai).
There was a problem hiding this comment.
understand. update it in commit "update complex change 2".
There was a problem hiding this comment.
arg.get_beta<T>() should already consider whether rocblas_isnan(arg.beta) and return accordingly.
There was a problem hiding this comment.
understand. This is my mistake.
Update it on third commit "update complex change"
There was a problem hiding this comment.
rocblas_isnan(arg.beta) should be left alone -- it is separate from arg.get_beta<T>().
There was a problem hiding this comment.
Understand, I will correct it on third commit "update complex change".
But, do we have to check nan for betai too??
It is only used in complex type.
Should we use another template function for is_nan check??
There was a problem hiding this comment.
rocblas_isnan(arg.beta) || rocblas_isnan(arg.betai). It does not matter that betai is only used during complex. It will default to 0 in non-complex cases.
There was a problem hiding this comment.
understand. update it in commit "update complex change 2".
|
+@deven-amd +@jerryyin for awareness. CGEMM / ZGEMM in rocBLAS. |
There was a problem hiding this comment.
We might want a trailing comma, for consistency
There was a problem hiding this comment.
Understand.
I correct it on third commit "update complex change".
There was a problem hiding this comment.
std::is_same<T1,T2>{} can be used as shorthand instead of std::is_same<T1,T2>::value, but this is not critical.
There was a problem hiding this comment.
Understand, I correct it on third commit "update complex change".
There was a problem hiding this comment.
unsigned(...) can be used instead of static_cast<unsigned int>(...) for brevity.
There was a problem hiding this comment.
Understand,
I correct it on third commit "update complex change".
leekillough
left a comment
There was a problem hiding this comment.
Ignore the CI build failures, which are global. Saad is working on a fix for them.
I have verified that the full rocBLAS tests pass on GFX900 and GFX906.
I will look at the code some more, but I approve the changes, as long as:
- Complex values for alpha and beta are tested sufficiently.
- Complex values for A, B, C, D matrices are tested sufficiently.
- Most of the concerns I've raised in comments are addressed or downplayed, such as the
isnanstuff withbeta. Some of the suggestions can be addressed in a later refactoring change.
amcamd
left a comment
There was a problem hiding this comment.
Need to review alpha and beta behavior when they have NaN values
Library side : didn’t treat NaN as a special case, so NaN operate with other value will generate NaN. Client side: set C as NaN if beta is NaN and set beta as 0 when beta is NaN |
Lee : 1. Complex values for alpha and beta are tested sufficiently. Reply :We have add alpha and beta imaginary value in rocblas-test for complex gemm Lee: 2. Complex values for A, B, C, D matrices are tested sufficiently. Reply: Same as item a. We have add complex test item in rocblas-test. Lee: 3. Most of the concerns I've raised in comments are addressed or downplayed, such as the Reply :We have modified implementation according to your comment and update in other commits in this PR (do we need to squash all commits to one commit ??). |
There was a problem hiding this comment.
I would remove comments about "Complex is not supported yet".
There was a problem hiding this comment.
understand. update it in commit "update complex change 2".
There was a problem hiding this comment.
We use C++14 for our internal code (not external C interfaces), so it's okay to use auto as a placeholder for function return type.
There was a problem hiding this comment.
understand. update it in commit "update complex change 2".
There was a problem hiding this comment.
TODO: Consolidate these functions into a smaller number of templates , varying them only by template arguments.
There was a problem hiding this comment.
Need to wrap rocblas_half to a class form to get conversion operation from half to double.
I think this can be done later.
There was a problem hiding this comment.
Pointers to void are not allowed as template arguments. It should be changed to:
template <typename T, typename std::enable_if<!is_complex<T>, int>::type = 0>
There was a problem hiding this comment.
understand. update it in commit "update complex change 2".
There was a problem hiding this comment.
As above:
template <typename T, typename std::enable_if<!is_complex<T>, int>::type = 0>
There was a problem hiding this comment.
understand. update it in commit "update complex change 2".
There was a problem hiding this comment.
This may need to be changed to:
bool nantest = rocblas_isnan(arg.beta) || rocblas_isnan(arg.betai);
For non-complex types, betai is 0 and so rocblas_isnan(arg.betai) is false.
There was a problem hiding this comment.
understand. update it in commit "update complex change 2".
There was a problem hiding this comment.
The comment is a little off.
There was a problem hiding this comment.
understand. update it in commit "update complex change 2".
There was a problem hiding this comment.
Typo -- COPMLEX should be COMPLEX
There was a problem hiding this comment.
understand. update it in commit "update complex change 2".
There was a problem hiding this comment.
Same typo throughout file -- maybe do global search and replacce
There was a problem hiding this comment.
understand. update it in commit "update complex change 2".
There was a problem hiding this comment.
I agree with moving norm.cpp to a header file norm.hpp.
There was a problem hiding this comment.
Thanks for agreement :)
leekillough
left a comment
There was a problem hiding this comment.
Once the changes I commented on are made, and the CI tests pass, I approve the changes.
|
@TonyYHsieh Your PR failed CI due to minor formatting differences on just 1 file (rocblas_gemm_ex.cpp), so I re-ran the formatter. It should pass the format check now. |
1. complex gemm(_ex) and gemm_strided_batched(ex) implementation 2. rocblas test and benchmark for complex
1. fix typo 2. fix beta nan condition check 3. fix invalid style of template function 4. fix bench log 5. add more alpha/beta setting for complex rocblas-test
resolves #___
Summary of proposed changes: