https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121760

--- Comment #21 from Benjamin Schulz <schulz.benjamin at googlemail dot com> ---
Created attachment 62287
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62287&action=edit
datastruct_gpu_memory_functions.h

Hi there, thank you for your advice jacub.

I now have looked at the code a bit longer... It turned out that in the offload
helper, there was a variable, which was not stored as reference.

If I changed 

       datastruct<T> pdL;

into 
       datastruct<T> &pdL;

in the code below, then gcc would compile the correct code and not try to map 
structs that were already on device.

It was not the datafields, and not the code in the strassen algorithm. these it
could eat. I have now changed the files into

template<typename T>
class Datastruct_GPU_Memory_Functions
{
public:
    class OffloadHelper
    {
    protected:
        bool pupdate_host;
        datastruct<T> &pdL;
        int pdevicenum;
    public:
        inline OffloadHelper(datastruct<T>& dL, int devicenum, bool just_alloc,
bool update_host_on_exit)
            :pupdate_host(update_host_on_exit), pdL(dL),pdevicenum(devicenum)
        {
#if !defined(Unified_Shared_Memory)
            if (just_alloc)
                Datastruct_GPU_Memory_Functions::create_out_struct(dL,
devicenum);
            else
                Datastruct_GPU_Memory_Functions::create_in_struct(dL,
devicenum);
#endif
        }

        inline  ~OffloadHelper()
        {
#if !defined(Unified_Shared_Memory)

            if (pupdate_host)
            {
                Datastruct_GPU_Memory_Functions::update_host(pdL, pdevicenum);
            }
            Datastruct_GPU_Memory_Functions::release_struct(pdL, pdevicenum);
#endif
        }

        OffloadHelper(const OffloadHelper&) = delete;
        OffloadHelper& operator=(const OffloadHelper&) = delete;
    };and ive changed strassen_multiply_h and winograd_multiply_h such that
they only want device pointers for the pdata fields and that the structs
themselves are mapped properly. But that was not really the problem, the
problem was the that it stored a copy and then tried to map that which confused
it... Now the strassen and Winograd algorithms work on device and host

Reply via email to