Passing class to arbb code

Passing class to arbb code

Imagen de xavier.warin@gmail.com

Hi Trying to have large arbb function, i face a problem with executing function captured by arbb. Here is the small exemple i took : // a small class
class PayOffSoSimple { public : PayOffSoSimple() {} PayOffSoSimple( const PayOffSoSimple & pay) {} arbb::f64 operator()() const { return 1.; } }; // a first caller with payoff function instanciated inside the caller void caller_( const arbb::usize & N) { PayOffSoSimple pay; arbb::dense Sol(N); _for (arbb::usize i= 0 , i < N , ++i) { Sol[i] = pay(); } _end_for; } // a second one with the pay off as argument void caller( const PayOffSoSimple & pay, const arbb::usize & N) { arbb::dense Sol(N); _for (arbb::usize i= 0 , i < N , ++i) { Sol[i] = pay(); } _end_for; } int main(int argc, char *argv[]) { arbb::usize N_ = 10 ; PayOffSoSimple paySoSimple; // OK arbb::dense sol(N_) ; _for (arbb::usize i= 0 , i < N_ , ++i) { sol[i] = paySoSimple(); } _end_for; // OK arbb::call(caller_)(N_); // exception arbb::call(caller)(paySoSimple,N_); return 0 ; } here is the exception : terminate called after throwing an instance of 'arbb_2::exception' what(): zero types captured Aborted Why is the second caller impossible to use ? Thank you Sincerely yours.

publicaciones de 3 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de Zhang Z (Intel)

The problem here is that the PayoffSoSimple class does not have a member variable. So when ArBB tries to capture this user defined type it has nothing to capture. ArBB documentation says one of the requirements for a user defined type is that member variables of the type must be ArBB types. But it does not say what if the user defined type does not have any data members. This particular case is really a corner case. Thanks for bringing it to our attention. We will investigate how to better address this corner issue and make improvements if necessary.

An easy workaround for this problem is adding a dummy member variable to your class:

class PayOffSoSimple { public : PayOffSoSimple() {} PayOffSoSimple( const PayOffSoSimple & pay) {} arbb::f64 operator()() const { return 1.; }

u8 dummy; };

Thanks.

Imagen de xavier.warin@gmail.com

Thank you very much !!

Inicie sesión para dejar un comentario.