diff --git a/include/pareas/compiler/futhark_interop.hpp b/include/pareas/compiler/futhark_interop.hpp index ab4bad5..8fd9c54 100644 --- a/include/pareas/compiler/futhark_interop.hpp +++ b/include/pareas/compiler/futhark_interop.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -166,6 +167,12 @@ namespace futhark { const int64_t* shape() const { return ArrayTraits::shape_fn(this->handle.ctx, this->handle.data); } + + std::vector download() const { + auto out = std::vector(this->shape()[0]); + this->values(out.data()); + return out; + } }; template <> diff --git a/src/compiler/backend.cpp b/src/compiler/backend.cpp index 38718cf..0a25a45 100644 --- a/src/compiler/backend.cpp +++ b/src/compiler/backend.cpp @@ -1,6 +1,10 @@ #include "pareas/compiler/backend.hpp" #include "pareas/compiler/futhark_interop.hpp" +#include +#include +#include + namespace backend { DeviceModule compile(futhark_context* ctx, DeviceAst& ast, pareas::Profiler& p) { auto tree = futhark::UniqueTree(ctx); @@ -87,7 +91,7 @@ namespace backend { auto instr_gen_rs1 = futhark::UniqueArray(ctx); auto instr_gen_rs2 = futhark::UniqueArray(ctx); auto instr_gen_jt = futhark::UniqueArray(ctx); - int err = futhark_entry_backend_split_instr( + futhark_entry_backend_split_instr( ctx, &instr_gen_opcodes, &instr_gen_rd, @@ -95,8 +99,17 @@ namespace backend { &instr_gen_rs2, &instr_gen_jt, instr - ); + ); + + auto h_opcodes = instr_gen_opcodes.download(); + auto h_rd = instr_gen_rd.download(); + auto h_rs1 = instr_gen_rs1.download(); + auto h_rs2 = instr_gen_rs2.download(); + auto h_jt = instr_gen_jt.download(); + for (size_t i = 0; i < h_opcodes.size(); ++i) { + fmt::print(std::cerr, "{:0>32b} {} {} {} {}\n", h_opcodes[i], h_rd[i], h_rs1[i], h_rs2[i], h_jt[i]); + } // Stage 4, optimizer auto optimize = futhark::UniqueArray(ctx);