sunpho84 / nissa

Nissa Is a Set of SU(N) Algorithms
GNU General Public License v3.0
5 stars 13 forks source link

Segmentation violation while reading Field2 values on host with cuda threads enabled #41

Open joek93 opened 1 year ago

joek93 commented 1 year ago

A segmentation violation error appears at runtime when one tries to read Field2 components from HOST (with master_printf, for example), when Field2 is allocated on DEVICE (--with-threads-type=cuda).

sunpho84 commented 1 year ago

I've implemented a runtime check, unfortunately I did not manage to implement a static one, as a code such as:

    INLINE_FUNCTION constexpr CUDA_HOST_AND_DEVICE
    void assertCorrectMemorySpace() const
    {
#ifdef USE_CUDA
# ifdef COMPILING_FOR_DEVICE
      static_assert(MT==MemoryType::CPU,""); /* always fail */
      if constexpr(MT==MemoryType::CPU)
    crash("Cannot evaluate on CPU");
# else
      static_assert(MT==MemoryType::GPU,""); /* always fail */
      if constexpr(MT==MemoryType::GPU)
    crash("Cannot evaluate on GPU");
# endif
#endif
    }

would always fail

sunpho84 commented 1 year ago

then the machinery to move from host do device must still be implemented, please tell me if the error is correctly cought