A Modern GPGPU API & wip linux RDNA2+ Driver
rdna driver linux gpu
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gir: dump

+84
+6
drivers/common/gir/gir.h
··· 2 2 3 3 #include <cstdint> 4 4 #include <vector> 5 + #include <functional> 6 + #include <string_view> 7 + 8 + #define GIR_VERSION "v1" 5 9 6 10 namespace gir { 7 11 ··· 121 125 protected: 122 126 Module& mod; 123 127 }; 128 + 129 + std::string dump_module(Module &mod, std::function<std::string_view(uint32_t)> backend_intrinsic_to_string); 124 130 125 131 void pass_normalize(Module& mod); 126 132 void pass_eliminate_dead_code(Module &mod);
+78
drivers/common/gir/gir_dump.cpp
··· 1 + #include "gir.h" 2 + #include <string> 3 + #include <sstream> 4 + 5 + namespace gir { 6 + 7 + static const std::string type_str[] = { 8 + "Void", 9 + "I32", 10 + "F32", 11 + "Ptr", 12 + }; 13 + 14 + static const std::string op_str[] = { 15 + "Add", 16 + "Sub", 17 + "Mul", 18 + "Div", 19 + "Mod", 20 + "FAdd", 21 + "FSub", 22 + "FMul", 23 + "FDiv", 24 + "And", 25 + "Or", 26 + "Xor", 27 + "Shl", 28 + "Shr", 29 + "Eq", 30 + "Ne", 31 + "Lt", 32 + "Le", 33 + "Gt", 34 + "Ge", 35 + "Load", 36 + "Store", 37 + "Const", 38 + "GetRootPtr", 39 + "GetLocalInvocationId", 40 + "GetThreadIdX", 41 + "GetThreadIdY", 42 + "GetThreadIdZ", 43 + "GetWorkgroupIdX", 44 + "GetWorkgroupIdY", 45 + "GetWorkgroupIdZ", 46 + "BackendIntrinsic", 47 + }; 48 + 49 + std::string dump_module(Module &mod, std::function<std::string_view(uint32_t)> backend_intrinsic_to_string) { 50 + std::stringstream ss; 51 + 52 + ss << "; gir " << GIR_VERSION << std::endl; 53 + ss << "; instructions: " << mod.insts.size() << std::endl; 54 + 55 + for (uint32_t i = 0; i < mod.insts.size(); ++i) { 56 + auto &inst = mod.insts[i]; 57 + auto op_text = op_str[(uint32_t)inst.op]; 58 + if (inst.op == Op::BackendIntrinsic) { 59 + op_text = backend_intrinsic_to_string(inst.intrinsic_id); 60 + } 61 + 62 + ss << "$" << i << " = " << op_text; 63 + 64 + for (auto j = 0; j < inst.operands.size(); ++j) { 65 + auto &operand = inst.operands[j]; 66 + if (j != 0) { 67 + ss << ","; 68 + } 69 + ss << " $" << operand.id; 70 + } 71 + 72 + ss << std::endl; 73 + } 74 + 75 + return ss.str(); 76 + } 77 + 78 + };