BTAS icon indicating copy to clipboard operation
BTAS copied to clipboard

For the transposition directive in gemv, CblasConjTrans just gives results as CblasTrans.

Open shengg opened this issue 11 years ago • 16 comments

For blas functions, gemv and gemm, there are parameters to determine how to transpose for the matrix: NoTrans, Trans or ConjTrans. In btas, all of these three parameters are implemented for gemm. However, only NoTrans and Trans are implemented for gemv. If ConjTrans is used, it is considered as Trans. I do not know why.

shengg avatar Jul 17 '14 21:07 shengg

I think complex support is not well implemented (I guess I was the only person who uses complex arithmetics?), so I would expect that it is simply a bug.

shiozaki avatar Jul 17 '14 21:07 shiozaki

That should be a bug. But, as long as calling CBLAS, I think they work correctly, calling with TensorView might have a trouble.

On Fri, Jul 18, 2014 at 6:54 AM, Toru Shiozaki [email protected] wrote:

I think complex support is not well implemented (I guess I was the only person who uses complex arithmetics?), so I would expect that it is simply a bug.

— Reply to this email directly or view it on GitHub https://github.com/BTAS/BTAS/issues/54#issuecomment-49371901.

naokin avatar Jul 18 '14 02:07 naokin

@shengg Most contract-like and permute should be assumed to NOT work with TensorView. Although TensorView meets the TWG.Tensor concept spec (checked by btas::is_boxtensor), and hence gets accepted by genv() and like, most of these functions assume "contiguous" view. Assume that most uses of TensorView will produce wrong results and should be checked.

All, note pull request #53 that addresses the issue of const TensorView not behaving like TensorConstView. The only way I found this to be solvable is through a configurable parameter (hence a distinct type of TensorView). Feel free to comment. test.C has the relevant examples that explain the new TensorRWView.

On Thu, Jul 17, 2014 at 8:29 PM, Naoki Nakatani [email protected] wrote:

That should be a bug. But, as long as calling CBLAS, I think they work correctly, calling with TensorView might have a trouble.

On Fri, Jul 18, 2014 at 6:54 AM, Toru Shiozaki [email protected] wrote:

I think complex support is not well implemented (I guess I was the only person who uses complex arithmetics?), so I would expect that it is simply a bug.

— Reply to this email directly or view it on GitHub https://github.com/BTAS/BTAS/issues/54#issuecomment-49371901.

— Reply to this email directly or view it on GitHub https://github.com/BTAS/BTAS/issues/54#issuecomment-49389477.

web: valeyev.net

evaleev avatar Jul 18 '14 03:07 evaleev

The unit test is now broken (with Commit: bde5b24f5867b8e7347f57e479623580bbe44370). @shengg Is this related to this issue?

test is a Catch v1.0 b48 host application.
Run with -? for options
-------------------------------------------------------------------------------
Tensor Gemv
  Complex Double Gemv --- ConjTrans
-------------------------------------------------------------------------------
tensor_blas_test.cc:223
...............................................................................

tensor_blas_test.cc:371: FAILED:
  CHECK( res < 1E-10 )
with expansion:
  121.1902981253 < 0.0000000001

===============================================================================
14 test cases - 1 failed (2370 assertions - 1 failed)

Makefile:29: recipe for target 'run' failed
gmake: *** [run] Error 1

shiozaki avatar Jul 22 '14 18:07 shiozaki

Yes. In gemv_impl.h, there are only TransA == CblasNoTrans and TransA != CblasNoTrans. There is no option to distinguish CblasConjTrans from CblasTrans .

shengg avatar Jul 22 '14 18:07 shengg

@shiozaki I made a small change. It works now.

shengg avatar Jul 22 '14 18:07 shengg

Thanks - but if _HAS_CBLAS is defined, it still breaks.

shiozaki avatar Jul 22 '14 22:07 shiozaki

I used mkl cblas. When _HAS_CBLAS is defined, several other tests also failed.

shengg avatar Jul 23 '14 15:07 shengg

I do use MKL CBLAS on Mac, and this (tensor_blas_test.cc:371) is the only test that fails.

shiozaki avatar Jul 23 '14 15:07 shiozaki

I should check my MKL or try another version. Maybe, it was not configured well, since MKL in my desktop was never used before.

shengg avatar Jul 23 '14 15:07 shengg

For what it's worth, my MKL is composer_xe_2013_sp1.0.074 and I do in ~/.profile

source /opt/intel/bin/compilervars.sh intel64

shiozaki avatar Jul 23 '14 15:07 shiozaki

WAIT! you are right, there are some tests that are broken (I was looking at a wrong build). I will try to look into it as far as I can.

shiozaki avatar Jul 23 '14 15:07 shiozaki

There are bugs in tests due to hardwired threshold. Note below that float does not have 10 digits accuracy. I think they should be implemented using std::numerical_limits<T>::epsilon() in some way.

 48     SECTION("Float Dot")
 49         {
 50         Tensor<float> Tf(2,3,7,3);
 51         Tf.generate([](){ return randomReal<float>(); });
 52         const auto fres = dot(Tf,Tf);
 53         float fcheck = 0.;
 54         for(const auto& el : Tf) fcheck += el*el;
 55         CHECK(fabs(fcheck-fres) < 1E-10);

shiozaki avatar Jul 23 '14 16:07 shiozaki

Yes, It should be changed. When I did not define _HAS_CBLAS, it works for some tests. So, I only changed the accuracy for the ones that failed.

However, after defining _HAS_CBLAS, the deviation was very big. And some tests for double also failed.

Best regards,

Sheng Guo Ph.D student 352 Frick Laboratory Department of Chemistry Princeton University

On Wed, Jul 23, 2014 at 12:08 PM, Toru Shiozaki [email protected] wrote:

There are bugs in tests due to hardwired threshold. Note below that float does not have 10 digits accuracy. I think they should be implemented using std::numerical_limits::epsilon() in some way.

48 SECTION("Float Dot") 49 { 50 Tensor Tf(2,3,7,3); 51 Tf.generate({ return randomReal(); }); 52 const auto fres = dot(Tf,Tf); 53 float fcheck = 0.; 54 for(const auto& el : Tf) fcheck += el*el; 55 CHECK(fabs(fcheck-fres) < 1E-10);

— Reply to this email directly or view it on GitHub https://github.com/BTAS/BTAS/issues/54#issuecomment-49895916.

shengg avatar Jul 23 '14 16:07 shengg

In addition, do not use fabs in the global scope from math.h. They are only implemented for double, so if you use it for float, it involves casts that introduce numerical noise.

The numerical behavior _HAS_CBLAS mainly stems from loop optimization (and use of SSE/AVX instructions) and is legitimate.

shiozaki avatar Jul 23 '14 16:07 shiozaki

They are only -> They may be only. Anyway it seems to change the behavior on my laptop. I guess it is better to use std::abs.

shiozaki avatar Jul 23 '14 16:07 shiozaki