gfor problem : seq use

258 views
Skip to first unread message

Louis Sarazin

unread,
Jul 28, 2015, 10:04:43 AM7/28/15
to ArrayFire Users
Hi,

I experienced some trouble with gfor in this simple code :

af::array centers = af::constant(0,100);

gfor
(af::seq i,100) centers(i) = 2.1*i ;

It compiles without any errors but execution sends :

terminate called after throwing an instance of 'af::exception'
  what
():  ArrayFire Exception(203): Invalid input size
In /var/lib/jenkins-slave/workspace/arrayfire-linux-mkl-graphics-installer/src/api/cpp/array.cpp:530
Abandon (core dumped)



I started to suspect the  float * seq to be the problem so I try this :

gfor(af::seq i,nbin) centers(i) = 2*i ;

It executes correctly but rises this error at compilation :

warning
: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: [enabled by default]
 gfor
(af::seq i,nbin) centers(i) = 2*i ;
 
^
In file included from /usr/local/include/af/array.h:12:0,
 
from /usr/local/include/arrayfire.h:259,
 
from umbral_af.cpp:7:
/usr/local/include/af/seq.h:56:23: note: candidate 1: af::seq af::operator*(double, af::seq)
 
friend inline seq operator*(double x, seq y) { return y * x; }
 
^
In file included from /usr/local/include/arrayfire.h:259:0,
 
from umbral_af.cpp:7:
/usr/local/include/af/array.h:982:5: note: candidate 2: af::array af::operator*(const int&, const af::array&)
 BIN_OP
(operator* )
 
^



Finally I run this :

gfor(af::seq i,nbin) centers(i) = 2.5*i ;

which compile without any errors and executes well.



Someone have any idea of what is happening ?



Here my af::info

// af::info
ArrayFire v3.0.2 (CUDA, 64-bit Linux, build 93427f0)
Platform: CUDA Toolkit 7, Driver: 346.46
[0] NVS 315, 1024 MB, CUDA Compute 2.1



Pradeep Garigipati

unread,
Jul 28, 2015, 10:51:38 AM7/28/15
to ArrayFire Users, louis....@gmail.com, louis....@gmail.com
Hi Louis,

I was able to reproduce the scenario. The message from compiler warning is precisely the reason why
centers = 2*i
is working, the compiler is picking the second candidate "operattor*" that takes integer and array which returns an array. This is returning an array of same dimensions as centers(i) , hence no error. Where as when you do the following
centers= 2.0*i
it is using the first alternative which is returning an seq that has been reordered for gfor construct where as the lhs still stayed with original dimensions. That is as far as i could get through, finding the cause of why it is happening.

There is another developer Pavan who originally wrote this construct, he should be able to enlighten us on the situation more. Lets wait for his inputs.

Pradeep.

Pavan Yalamanchili

unread,
Jul 28, 2015, 10:53:09 AM7/28/15
to Louis Sarazin, ArrayFire Users
Hi Louis,

It looks like we did not overload properly when you are multiplying sequences with scalars. For now you will need to make sure the multiplying factor is always float by using "2.0" instead of "2". We will look into fixing this before 3.1.

That said, for the stuff you are doing it is more efficient and faster to simply do this:

array centers = 2.0 * seq(nbin);

This avoids the writing of the original array creation and subsequent copy.

--
You received this message because you are subscribed to the Google Groups "ArrayFire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arrayfire-use...@googlegroups.com.
To post to this group, send email to arrayfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arrayfire-users/ceae7f2d-fd2d-4ac7-bf31-9f683a2c5521%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages