Blitz limitation with the debugging mode
Created by: laurentes
Blitz has a current limitation when combining reduction and complex expressions, AND enabling the debugging mode using the -DBZ_DEBUG flag. This problem is described in this blitz ticket.
In particular, this means that such a piece code will throw an assert when the DBZ_DEBUG flag is set, but will work fine otherwise:
blitz::firstIndex bi; blitz::secondIndex bj; blitz::thirdIndex bk; blitz::Array A(2,2,2); A = 2.; blitz::Array B(2,2); B = 7.; blitz::sum(A(bi,bj,bk)*B(bi,bj),bk); // throws an assert // linux-x86_64/include/blitz/array/expr.h:492 Two array operands have different orders: for rank 0, the orders are 2 and 1 // linux-x86_64/include/blitz/array/expr.h:493: static int blitz::bounds::compute_ordering(int, int, int): Assertion `0' failed.
More precisely, this happens when the expression inside the reduction is built on arrays of different dimensions. The current workaround to make everything work with the DBZ_DEBUG flag enabled is to declare an intermediate array:
blitz::Array C(A(bi,bj,bk)*B(bi,bj)); blitz::sum(C,bk); // throw an assert
Please be aware that this might generate some overhead.