Nebo assignments cause runtime errors on GPUs when multiplying by a constant
Consider the following nebo assignment
const double a = 2.0;
Field1 <<= Field2 * a;
where Field1 and Field2 are spatialfields and a is a double. The above assignments breaks on the GPU but NOT on CPU. If I switch the order of algebraic operations to:
Field1 <<= a * Field2;
Then things work fine.
To test this:
- Wasatch GPU build (opt or dbg)
- ./sus -gpu -nthreads 2 -mpi inputs/Wasatch/Turbulence/decay-isotropic-turbulence-csmag_32.ups
With repository code, I get the following error:
terminate called after throwing an instance of 'std::runtime_error'
what():
Error trapped while executing expression: ( TurbulentViscosity, STATE_NONE )
details follow...
Request for const field pointer on a device for which it has not been allocated
(Locally allocated, generic system RAM) - /scratch/local/aurora_fast/tsaad/uintah-work/opt-gpu/Wasatch3P/install/SpatialOps/include/spatialops/structured/FieldInfo.h : 789
If you modify TurbulentViscosity.cc, line 110 to read:
result <<= mixingLengthSq * rho ; // rho * (Cs * delta)^2 * |S|, Cs is the Smagorinsky constant
Then things work fine. Note that I had to remove sqrt(2.0 * strTsrSq_->field_ref() )
because the sqrt doesn't work either, alghouth strTsrSq_->field_ref()
is fine.