Skip to content

lapis generated c++ fails to compile #70

Open
@vmiheer

Description

@vmiheer

Hello @brian-kelley, this is code generated with older version of lapis so please let me know if this is already fixed in one of the newer changes:

bsddmm.cpp
#include <Kokkos_Core.hpp>
#include <type_traits>
#include <cstdint>
#include <unistd.h>
#include <iostream>

template <typename T, int N>
struct StridedMemRefType {
  T *basePtr;
  T *data;
  int64_t offset;
  int64_t sizes[N];
  int64_t strides[N];
};

namespace LAPIS
{
  using TeamPolicy = Kokkos::TeamPolicy<>;
  using TeamMember = typename TeamPolicy::member_type;

  template<typename V>
    StridedMemRefType<typename V::value_type, V::rank> viewToStridedMemref(const V& v)
    {
      StridedMemRefType<typename V::value_type, V::rank> smr;
      smr.basePtr = v.data();
      smr.data = v.data();
      smr.offset = 0;
      for(int i = 0; i < int(V::rank); i++)
      {
        smr.sizes[i] = v.extent(i);
        smr.strides[i] = v.stride(i);
      }
      return smr;
    }

  template<typename V>
    V stridedMemrefToView(const StridedMemRefType<typename V::value_type, V::rank>& smr)
    {
      using Layout = typename V::array_layout;
      static_assert(std::is_same_v<typename V::memory_space, Kokkos::HostSpace> ||
          std::is_same_v<typename V::memory_space, Kokkos::AnonymousSpace>,
          "Can only convert a StridedMemRefType to a Kokkos::View in HostSpace.");
      if constexpr(std::is_same_v<Layout, Kokkos::LayoutStride>)
      {
        size_t extents[8] = {0};
        size_t strides[8] = {0};
        for(int i = 0; i < V::rank; i++) {
          extents[i] = smr.sizes[i];
          strides[i] = smr.strides[i];
        }
        Layout layout(
            extents[0], strides[0],
            extents[1], strides[1],
            extents[2], strides[2],
            extents[3], strides[3],
            extents[4], strides[4],
            extents[5], strides[5],
            extents[6], strides[6],
            extents[7], strides[7]);
        return V(&smr.data[smr.offset], layout);
      }
      size_t extents[8] = {
        KOKKOS_INVALID_INDEX, KOKKOS_INVALID_INDEX, KOKKOS_INVALID_INDEX, KOKKOS_INVALID_INDEX,
        KOKKOS_INVALID_INDEX, KOKKOS_INVALID_INDEX, KOKKOS_INVALID_INDEX, KOKKOS_INVALID_INDEX};
      for(int i = 0; i < V::rank; i++)
        extents[i] = smr.sizes[i];
      Layout layout(
          extents[0], extents[1], extents[2], extents[3],
          extents[4], extents[5], extents[6], extents[7]);
      if constexpr(std::is_same_v<Layout, Kokkos::LayoutLeft>)
      {
        int64_t expectedStride = 1;
        for(int i = 0; i < int(V::rank); i++)
        {
          if(expectedStride != smr.strides[i])
            Kokkos::abort("Cannot shallow-copy StridedMemRefType that is not contiguous and LayoutLeft to LayoutLeft Kokkos::View");
          expectedStride *= smr.sizes[i];
        }
      }
      else if constexpr(std::is_same_v<Layout, Kokkos::LayoutRight>)
      {
        int64_t expectedStride = 1;
        for(int i = int(V::rank) - 1; i >= 0; i--)
        {
          if(expectedStride != smr.strides[i])
            Kokkos::abort("Cannot shallow-copy StridedMemRefType that is not contiguous and LayoutRight to LayoutRight Kokkos::View");
          expectedStride *= smr.sizes[i];
        }
      }
      return V(&smr.data[smr.offset], layout);
    }

  struct DualViewBase
  {
    virtual ~DualViewBase() {}
    virtual void syncHost() = 0;
    virtual void syncDevice() = 0;
    bool modified_host = false;
    bool modified_device = false;
    DualViewBase* parent;
  };

  template<typename DataType, typename Layout>
    struct DualView : public DualViewBase
  {
    using HostView = Kokkos::View<DataType, Layout, Kokkos::DefaultHostExecutionSpace>;
    using DeviceView = Kokkos::View<DataType, Layout, Kokkos::DefaultExecutionSpace>;

    static constexpr bool deviceAccessesHost = Kokkos::SpaceAccessibility<Kokkos::DefaultHostExecutionSpace, typename DeviceView::memory_space>::accessible;
    static constexpr bool hostAccessesDevice = Kokkos::SpaceAccessibility<Kokkos::DefaultHostExecutionSpace, typename DeviceView::memory_space>::accessible;

    // Default constructor makes empty views and self as parent.
    DualView() : device_view(), host_view() {
      parent = this;
    }

    // Constructor for allocating a new view.
    // Does not actually allocate anything yet; instead 
    DualView(
        const std::string& label,
        size_t ex0 = KOKKOS_INVALID_INDEX, size_t ex1 = KOKKOS_INVALID_INDEX, size_t ex2 = KOKKOS_INVALID_INDEX, size_t ex3 = KOKKOS_INVALID_INDEX,
        size_t ex4 = KOKKOS_INVALID_INDEX, size_t ex5 = KOKKOS_INVALID_INDEX, size_t ex6 = KOKKOS_INVALID_INDEX, size_t ex7 = KOKKOS_INVALID_INDEX)
    {
      if constexpr(hostAccessesDevice) {
        device_view = DeviceView(Kokkos::view_alloc(Kokkos::WithoutInitializing, label + "_dev"), ex0, ex1, ex2, ex3, ex4, ex5, ex6, ex7);
        host_view = HostView(device_view.data(), ex0, ex1, ex2, ex3, ex4, ex5, ex6, ex7);
      }
      else if constexpr(deviceAccessesHost) {
        // Otherwise, host_view must be a separate allocation.
        host_view = HostView(Kokkos::view_alloc(Kokkos::WithoutInitializing, label + "_host"), ex0, ex1, ex2, ex3, ex4, ex5, ex6, ex7);
        device_view = DeviceView(host_view.data(), ex0, ex1, ex2, ex3, ex4, ex5, ex6, ex7);
      }
      else {
        device_view = DeviceView(Kokkos::view_alloc(Kokkos::WithoutInitializing, label + "_dev"), ex0, ex1, ex2, ex3, ex4, ex5, ex6, ex7);
        host_view = HostView(Kokkos::view_alloc(Kokkos::WithoutInitializing, label + "_host"), ex0, ex1, ex2, ex3, ex4, ex5, ex6, ex7);
      }
      parent = this;
    }

    // Constructor which is given explicit device and host views, and a parent.
    // This can be used for subviewing/casting operations.
    // Note: d,h should alias parent's memory, but they can
    // have a different data type and layout.
    DualView(DeviceView d, HostView h, DualViewBase* parent_)
      : device_view(d), host_view(h)
    {
      parent = parent_;
      // Walk up to the top-level DualView (which has itself as parent).
      // This is important because its modify flags must be used for itself and all children.
      // Children have their own flag members, but they are not used or kept in sync with parent.
      while(parent->parent != parent)
        parent = parent->parent;
    }

    // Constructor taking a host or device view
    template<typename DT, typename... Args>
    DualView(Kokkos::View<DT, Args...> v)
    {
      using ViewType = decltype(v);
      using Space = typename ViewType::memory_space;
      if constexpr(std::is_same_v<typename DeviceView::memory_space, Space>) {
        // Treat v like a device view, even though it's possible that DeviceView and HostView have the same type.
        // In this case, the host view will alias it.
        modified_device = true;
        if constexpr(deviceAccessesHost) {
          host_view = HostView(v.data(), v.layout());
        }
        else {
          host_view = HostView(Kokkos::view_alloc(Kokkos::WithoutInitializing, v.label() + "_host"), v.layout());
        }
        device_view = v;
      }
      else {
        modified_host = true;
        if constexpr(deviceAccessesHost) {
          device_view = DeviceView(v.data(), v.layout());
        }
        else {
          device_view = DeviceView(Kokkos::view_alloc(Kokkos::WithoutInitializing, v.label() + "_dev"), v.layout());
        }
        host_view = v;
      }
      parent = this;
    }

    // Copy-assignment equivalent to the above constructor.
    // Shallow copying a temporary DualView to a persistent one leaves the
    // persistent one in an invalid state, since its parent pointer still points to the temporary.
    //
    // Shallow-copy from one persistent DualView to another persistent or temporary is OK, as long
    // as the lifetime of original covers the lifetime of the copy.
    DualView& operator=(const HostView& h)
    {
      modified_host = true;
      if constexpr(deviceAccessesHost) {
        device_view = DeviceView(h.data(), h.layout());
      }
      else {
        device_view = DeviceView(Kokkos::view_alloc(Kokkos::WithoutInitializing, h.label() + "_dev"), h.layout());
      }
      host_view = h;
      parent = this;
      return *this;
    }

    // General shallow-copy from one DualView to another
    // (used by static -> dynamic conversion)
    template<typename OtherData, typename OtherLayout>
    DualView(const DualView<OtherData, OtherLayout>& other)
    {
      device_view = other.device_view;
      host_view = other.host_view;
      parent = other.parent;
    }

    void modifyHost()
    {
      parent->modified_host = true;
    }

    void modifyDevice()
    {
      parent->modified_device = true;
    }

    bool modifiedHost()
    {
      // note: parent may just point to this
      return parent->modified_host;
    }

    bool modifiedDevice()
    {
      // note: parent may just point to this
      return parent->modified_device;
    }

    void syncHost() override
    {
      if (device_view.data() == host_view.data()) {
        // Imitating Kokkos::DualView behavior: if device and host are the same space
        // then this sync (if required) is equivalent to a fence.
        if(parent->modified_device) {
          parent->modified_device = false;
          Kokkos::fence();
        }
      }
      else if (parent->modified_device) {
        if(parent == this) {
          Kokkos::deep_copy(host_view, device_view);
          modified_device = false;
        }
        else {
          parent->syncHost();
        }
      }
    }

    void syncDevice() override
    {
      // If host and device views are the same, do not sync or fence
      // because all host execution spaces are synchronous.
      // Any changes on the host side are immediately visible on the device side.
      if (device_view.data() != host_view.data()) {
        if(parent == this) {
          if(modified_host) {
            Kokkos::deep_copy(device_view, host_view);
            modified_host = false;
          }
        }
        else {
          parent->syncDevice();
        }
      }
    }

    void deallocate() {
      device_view = DeviceView();
      host_view = HostView();
    }

    size_t extent(int dim) {
      return device_view.extent(dim);
    }

    size_t stride(int dim) {
      return device_view.stride(dim);
    }

    DeviceView device_view;
    HostView host_view;
  };

  inline int threadParallelVectorLength(int par) {
    if (par < 1)
      return 1;
    int max_vector_length = TeamPolicy::vector_length_max();
    int vector_length = 1;
    while(vector_length < max_vector_length && vector_length * 6 < par) vector_length *= 2;
    return vector_length;
  }

  // KeepAlive structure keeps a reference to Kokkos::Views which
  // are returned to Python. Since it's difficult to transfer ownership of a
  // Kokkos::View's memory to numpy, we just have the Kokkos::View maintain ownership
  // and return an unmanaged numpy array to Python.
  //
  // All these views will be deallocated during lapis_finalize to avoid leaking.
  // The downside is that if a function is called many times,
  // all its results are kept in memory at the same time.
  struct KeepAlive
  {
    virtual ~KeepAlive() {}
  };

  template<typename T>
  struct KeepAliveT : public KeepAlive
  {
    // Make a shallow-copy of val
    KeepAliveT(const T& val) : p(new T(val)) {}
    std::unique_ptr<T> p;
  };

  static std::vector<std::unique_ptr<KeepAlive>> alives;

  template<typename T>
  void keepAlive(const T& val)
  {
    alives.emplace_back(new KeepAliveT(val));
  }
} // namespace LAPIS

#ifndef LAPIS_CPP_DRIVER
extern "C" void delSparseTensor(void*);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" void* _mlir_ciface_newSparseTensor(StridedMemRefType<size_t, 1>*, StridedMemRefType<size_t, 1>*, StridedMemRefType<int64_t, 1>*, StridedMemRefType<size_t, 1>*, StridedMemRefType<size_t, 1>*, int32_t, int32_t, int32_t, int32_t, void*);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" void _mlir_ciface_sparseCoordinates0(StridedMemRefType<size_t, 1>*, void*, size_t);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" void _mlir_ciface_sparsePositions0(StridedMemRefType<size_t, 1>*, void*, size_t);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" size_t sparseLvlSize(void*, size_t);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" void _mlir_ciface_sparseValuesF32(StridedMemRefType<float, 1>*, void*);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" void* _mlir_ciface_mpi_getSliceForActiveMask(void*, StridedMemRefType<size_t, 1>*, size_t, size_t);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" size_t _mlir_ciface_mpi_getActiveMask(void*, StridedMemRefType<size_t, 1>*, size_t);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" void* _mlir_ciface_mpi_getSlice(void*, StridedMemRefType<size_t, 1>*);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" void _mlir_ciface_mpi_getPartitions(StridedMemRefType<size_t, 1>*, void*);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" size_t _mlir_ciface_mpi_getRank();
#endif

void* csr_to_csrv(void*, void*);

#ifndef LAPIS_CPP_DRIVER
extern "C" void overwrite_csrv_csrv(size_t, void*, size_t, size_t);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" void free_active_mask(size_t);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" void* _mlir_ciface_csr_to_csrv_v2(void*, void*, int8_t);
#endif

#ifndef LAPIS_CPP_DRIVER
extern "C" StridedMemRefType<float, 3> sparse_densev_to_vanilla_dense(void*);
#endif

void* bsddmm_core(void* v1, LAPIS::DualView<float***, Kokkos::LayoutRight> v2, LAPIS::DualView<float***, Kokkos::LayoutRight> v3) {
  size_t v4 = v2.extent(1);
  LAPIS::DualView<float*, Kokkos::LayoutRight> v5;
  {
    StridedMemRefType<float, 1> v5_smr;
    _mlir_ciface_sparseValuesF32(&v5_smr, v1);
    v5 = LAPIS::stridedMemrefToView<Kokkos::View<float*, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace>>(v5_smr);
  }
  ;
  size_t v6;
  {
    v6 = sparseLvlSize(v1, 0);
  }
  ;
  LAPIS::DualView<size_t*, Kokkos::LayoutRight> v7;
  {
    StridedMemRefType<size_t, 1> v7_smr;
    _mlir_ciface_sparsePositions0(&v7_smr, v1, 1);
    v7 = LAPIS::stridedMemrefToView<Kokkos::View<size_t*, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace>>(v7_smr);
  }
  ;
  LAPIS::DualView<size_t*, Kokkos::LayoutRight> v8;
  {
    StridedMemRefType<size_t, 1> v8_smr;
    _mlir_ciface_sparseCoordinates0(&v8_smr, v1, 1);
    v8 = LAPIS::stridedMemrefToView<Kokkos::View<size_t*, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace>>(v8_smr);
  }
  ;
  size_t v9;
  {
    v9 = sparseLvlSize(v1, 2);
  }
  ;
  v7.syncHost();
  size_t v10 = v7.host_view(v6);
  v7.syncHost();
  size_t v11 = v7.host_view(0);
  size_t v12 = v10 - v11;
  size_t v13 = v12 + v6;
  size_t v14 = v13 - 1;
  size_t v15 = v14 / v6;
  size_t v16 = v4 * v9;
  v8.syncDevice();
  v2.syncDevice();
  v7.syncDevice();
  v3.syncDevice();
  v5.syncDevice();
  v5.modifyDevice();
  auto lambda_v17 = 
  KOKKOS_LAMBDA(const LAPIS::TeamMember& team) {
    size_t v18 = v7.device_view(team.league_rank());
    size_t v19 = team.league_rank() + 1;
    size_t v20 = v7.device_view(v19);
    size_t v21 = v20 - v18;
    Kokkos::parallel_for(Kokkos::TeamThreadRange(team, 0, v21),
    [=](size_t v22) {
      size_t v23 = v18 + v22;
      size_t v24 = v8.device_view(v23);
      size_t v25 = v23 * v9;
      Kokkos::parallel_for(Kokkos::ThreadVectorMDRange(team, v4, v9),
      [=](size_t v26, size_t v27) {
        size_t v28 = v27 + v25;
        float v29 = v5.device_view(v28);
        float v30 = v2.device_view(team.league_rank(), v26, v27);
        float v31 = v3.device_view(v24, v26, v27);
        float v32 = v30 * v31;
        float v33 = v29 + v32;
        v5.device_view(v28) = v33;
      });
    });
    team.team_barrier();
  };
  size_t targetVectorLength_v34 = v16 ? v16 : 8;
  size_t vectorLength_v35 = Kokkos::min<size_t>(targetVectorLength_v34, LAPIS::TeamPolicy::vector_length_max());
  size_t teamSize_v36 = v15;
  if(teamSize_v36) {
    teamSize_v36 = Kokkos::min<size_t>(teamSize_v36, LAPIS::TeamPolicy(1, 1, vectorLength_v35).team_size_max(lambda_v17, Kokkos::ParallelForTag{}));
  }
  else {
    teamSize_v36 = LAPIS::TeamPolicy(1, 1, vectorLength_v35).team_size_recommended(lambda_v17, Kokkos::ParallelForTag{});
  }
  Kokkos::parallel_for(LAPIS::TeamPolicy(v6, teamSize_v36, vectorLength_v35), lambda_v17);
  v5.syncHost();
  v7.syncHost();
  v8.syncHost();
  return v1;
}


extern "C" void pte_bsddmm_tiled(void* v1, void* v2, void* v3, void* v4, void* v5, size_t v6, size_t v7, size_t v8, size_t v9, size_t v10, size_t v11) {
  void* v12 = 0;
  Kokkos::View<size_t*, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace> v13;
  {
    StridedMemRefType<size_t, 1> v13_smr;
    _mlir_ciface_mpi_getPartitions(&v13_smr, v1);
    v13 = LAPIS::stridedMemrefToView<Kokkos::View<size_t*, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace>>(v13_smr);
  }
  ;
  size_t v14;
  {
    v14 = _mlir_ciface_mpi_getRank();
  }
  ;
  Kokkos::View<size_t[4], Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace> v15(Kokkos::view_alloc(Kokkos::WithoutInitializing, "v15"));
  size_t v16 = v14 * 4;
  size_t v17 = v13(v16);
  size_t v18 = v16 + 1;
  size_t v19 = v13(v18);
  size_t v20 = v16 + 2;
  size_t v21 = v13(v20);
  size_t v22 = v16 + 3;
  size_t v23 = v13(v22);
  v15(0) = v17;
  v15(1) = v19;
  v15(2) = v21;
  v15(3) = v23;
  void* v24;
  {
    StridedMemRefType<size_t, 1> v15_smr = LAPIS::viewToStridedMemref(v15);
    v24 = _mlir_ciface_mpi_getSlice(v1, &v15_smr);
  }
  ;
  size_t v25;
  {
    v25 = sparseLvlSize(v24, 0);
  }
  ;
  size_t v26;
  {
    StridedMemRefType<size_t, 1> v15_smr = LAPIS::viewToStridedMemref(v15);
    v26 = _mlir_ciface_mpi_getActiveMask(v1, &v15_smr, 1);
  }
  ;
  Kokkos::View<size_t[6], Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace> v27(Kokkos::view_alloc(Kokkos::WithoutInitializing, "v27"));
  v27(0) = v17;
  v27(1) = 0;
  v27(2) = 0;
  v27(3) = v21;
  v27(4) = v8;
  v27(5) = v9;
  void* v28;
  {
    StridedMemRefType<size_t, 1> v27_smr = LAPIS::viewToStridedMemref(v27);
    v28 = _mlir_ciface_mpi_getSlice(v2, &v27_smr);
  }
  ;
  LAPIS::DualView<float***, Kokkos::LayoutRight> v29;
  {
    StridedMemRefType<float, 3> v29_smr;
    v29 = sparse_densev_to_vanilla_dense(v28);
    v29 = LAPIS::stridedMemrefToView<Kokkos::View<float***, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace>>(v29_smr);
  }
  ;
  v29.syncHost();
  v29.modifyHost();
  for (size_t v30 = 0; v30 < v7; v30 += v11) {
    v15(1) = v30;
    size_t v31 = v30 + v11;
    v15(3) = v31;
    void* v32;
    {
      StridedMemRefType<size_t, 1> v15_smr = LAPIS::viewToStridedMemref(v15);
      v32 = _mlir_ciface_mpi_getSlice(v1, &v15_smr);
    }
    ;
    size_t v33 = v15(1);
    size_t v34 = v15(3);
    Kokkos::View<size_t[6], Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace> v35(Kokkos::view_alloc(Kokkos::WithoutInitializing, "v35"));
    v35(0) = v33;
    v35(1) = 0;
    v35(2) = 0;
    v35(3) = v34;
    v35(4) = v8;
    v35(5) = v9;
    void* v36;
    {
      StridedMemRefType<size_t, 1> v35_smr = LAPIS::viewToStridedMemref(v35);
      v36 = _mlir_ciface_mpi_getSliceForActiveMask(v3, &v35_smr, v26, 0);
    }
    ;
    LAPIS::DualView<float***, Kokkos::LayoutRight> v37;
    {
      StridedMemRefType<float, 3> v37_smr;
      v37 = sparse_densev_to_vanilla_dense(v36);
      v37 = LAPIS::stridedMemrefToView<Kokkos::View<float***, Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace>>(v37_smr);
    }
    ;
    size_t v38;
    {
      v38 = sparseLvlSize(v32, 1);
    }
    ;
    Kokkos::View<int64_t[3], Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace> v39(Kokkos::view_alloc(Kokkos::WithoutInitializing, "v39"));
    v39(0) = 65536;
    v39(1) = 262144;
    v39(2) = 65536;
    Kokkos::View<size_t[3], Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace> v40(Kokkos::view_alloc(Kokkos::WithoutInitializing, "v40"));
    v40(0) = v25;
    v40(1) = v38;
    v40(2) = v9;
    Kokkos::View<size_t[3], Kokkos::LayoutRight, Kokkos::DefaultHostExecutionSpace> v41(Kokkos::view_alloc(Kokkos::WithoutInitializing, "v41"));
    v41(0) = 0;
    v41(1) = 1;
    v41(2) = 2;
    void* v42;
    {
      StridedMemRefType<size_t, 1> v40_smr = LAPIS::viewToStridedMemref(v40);
      StridedMemRefType<int64_t, 1> v39_smr = LAPIS::viewToStridedMemref(v39);
      StridedMemRefType<size_t, 1> v41_smr = LAPIS::viewToStridedMemref(v41);
      v42 = _mlir_ciface_newSparseTensor(&v40_smr, &v40_smr, &v39_smr, &v41_smr, &v41_smr, 0, 0, 2, 0, v12);
    }
    ;
    void* v43;
    {
      v43 = _mlir_ciface_csr_to_csrv_v2(v42, v32, 0);
    }
    ;
    v37.syncHost();
    v37.modifyHost();
    void* v44 = bsddmm_core(v43, v29, v37);
    {
      overwrite_csrv_csrv(v6, v44, 1, v33);
    }
    ;
    {
      delSparseTensor(v42);
    }
    ;
    {
      delSparseTensor(v36);
    }
    ;
  }
  {
    free_active_mask(v26);
  }
  ;
  v29.syncHost();
  v37.syncHost();
  return;
}



extern "C" void lapis_initialize()
{
  if (!Kokkos::is_initialized()) Kokkos::initialize();
  Kokkos::DefaultExecutionSpace().fence();
}

extern "C" void lapis_finalize()
{
  Kokkos::finalize();
}

The error I get is:

/usr/bin/g++-12 -DKOKKOS_DEPENDENCE -DUSE_KOKKOS=1 -isystem /home/mvaidya/source/repos/LAPIS_Workspace/kokkos_install/include -isystem /home/mvaidya/source/repos/LAPIS_Workspace/cpm_cache/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include -O3 -DNDEBUG -fopenmp -MD -MT CMakeFiles/bsddmm.dist.dir/bsddmm.dist.cpp.o -MF CMakeFiles/bsddmm.dist.dir/bsddmm.dist.cpp.o.d -o CMakeFiles/bsddmm.dist.dir/bsddmm.dist.cpp.o -c /home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp: In function ‘void pte_bsddmm_tiled(void*, void*, void*, void*, void*, size_t, size_t, size_t, size_t, size_t, size_t)’:
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:544:45: error: no match for ‘operator=’ (operand types are ‘LAPIS::DualView<float***, Kokkos::LayoutRight>’ and ‘StridedMemRefType<float, 3>’)
  544 |     v29 = sparse_densev_to_vanilla_dense(v28);
      |                                             ^
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:192:15: note: candidate: ‘LAPIS::DualView<DataType, Layout>& LAPIS::DualView<DataType, Layout>::operator=(const HostView&) [with DataType = float***; Layout = Kokkos::LayoutRight; HostView = Kokkos::View<float***, Kokkos::LayoutRight, Kokkos::OpenMP>]’
  192 |     DualView& operator=(const HostView& h)
      |               ^~~~~~~~
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:192:41: note:   no known conversion for argument 1 from ‘StridedMemRefType<float, 3>’ to ‘const LAPIS::DualView<float***, Kokkos::LayoutRight>::HostView&’ {aka ‘const Kokkos::View<float***, Kokkos::LayoutRight, Kokkos::OpenMP>&’}
  192 |     DualView& operator=(const HostView& h)
      |                         ~~~~~~~~~~~~~~~~^
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:104:12: note: candidate: ‘LAPIS::DualView<float***, Kokkos::LayoutRight>& LAPIS::DualView<float***, Kokkos::LayoutRight>::operator=(const LAPIS::DualView<float***, Kokkos::LayoutRight>&)’
  104 |     struct DualView : public DualViewBase
      |            ^~~~~~~~
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:104:12: note:   no known conversion for argument 1 from ‘StridedMemRefType<float, 3>’ to ‘const LAPIS::DualView<float***, Kokkos::LayoutRight>&’
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:104:12: note: candidate: ‘LAPIS::DualView<float***, Kokkos::LayoutRight>& LAPIS::DualView<float***, Kokkos::LayoutRight>::operator=(LAPIS::DualView<float***, Kokkos::LayoutRight>&&)’
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:104:12: note:   no known conversion for argument 1 from ‘StridedMemRefType<float, 3>’ to ‘LAPIS::DualView<float***, Kokkos::LayoutRight>&&’
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:578:47: error: no match for ‘operator=’ (operand types are ‘LAPIS::DualView<float***, Kokkos::LayoutRight>’ and ‘StridedMemRefType<float, 3>’)
  578 |       v37 = sparse_densev_to_vanilla_dense(v36);
      |                                               ^
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:192:15: note: candidate: ‘LAPIS::DualView<DataType, Layout>& LAPIS::DualView<DataType, Layout>::operator=(const HostView&) [with DataType = float***; Layout = Kokkos::LayoutRight; HostView = Kokkos::View<float***, Kokkos::LayoutRight, Kokkos::OpenMP>]’
  192 |     DualView& operator=(const HostView& h)
      |               ^~~~~~~~
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:192:41: note:   no known conversion for argument 1 from ‘StridedMemRefType<float, 3>’ to ‘const LAPIS::DualView<float***, Kokkos::LayoutRight>::HostView&’ {aka ‘const Kokkos::View<float***, Kokkos::LayoutRight, Kokkos::OpenMP>&’}
  192 |     DualView& operator=(const HostView& h)
      |                         ~~~~~~~~~~~~~~~~^
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:104:12: note: candidate: ‘LAPIS::DualView<float***, Kokkos::LayoutRight>& LAPIS::DualView<float***, Kokkos::LayoutRight>::operator=(const LAPIS::DualView<float***, Kokkos::LayoutRight>&)’
  104 |     struct DualView : public DualViewBase
      |            ^~~~~~~~
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:104:12: note:   no known conversion for argument 1 from ‘StridedMemRefType<float, 3>’ to ‘const LAPIS::DualView<float***, Kokkos::LayoutRight>&’
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:104:12: note: candidate: ‘LAPIS::DualView<float***, Kokkos::LayoutRight>& LAPIS::DualView<float***, Kokkos::LayoutRight>::operator=(LAPIS::DualView<float***, Kokkos::LayoutRight>&&)’
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:104:12: note:   no known conversion for argument 1 from ‘StridedMemRefType<float, 3>’ to ‘LAPIS::DualView<float***, Kokkos::LayoutRight>&&’
/home/mvaidya/source/repos/LAPIS_Workspace/vmiheer-mlir-playground/33-pt-sparse-mha/build/bsddmm.dist.cpp:633:3: error: ‘v37’ was not declared in this scope; did you mean ‘v27’?
  633 |   v37.syncHost();
      |   ^~~
      |   v27

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions