src/jit/ptx_emit.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Thin PTX compilation wrapper over the shared Brass GPU MIR builders. | ||
| 2 | |||
| 3 | #include "ptx_emit.h" | ||
| 4 | #include "gpu_mir_emit_detail.h" | ||
| 5 | |||
| 6 | #include <brass/target/ptx_target.hpp> | ||
| 7 | |||
| 8 | namespace brotensor::jit::ptx { | ||
| 9 | |||
| 10 | namespace { | ||
| 11 | |||
| 12 | 16 | brass::target::PtxOptions ptx_opts_for(const std::string& arch) { | |
| 13 | 16 | brass::target::PtxOptions opts; | |
| 14 | 16 | opts.sm_arch = arch.empty() ? "sm_80" : arch; | |
| 15 | 16 | opts.ptx_version_major = 7; | |
| 16 | 16 | opts.ptx_version_minor = (opts.sm_arch == "sm_80") ? 4u : 0u; | |
| 17 | 16 | opts.cleanup = true; | |
| 18 | 16 | return opts; | |
| 19 | 16 | } | |
| 20 | |||
| 21 | } // namespace | ||
| 22 | |||
| 23 | 6 | std::string emit_elementwise(const TraceDAG& dag, const ElementwisePlan& plan, | |
| 24 | const std::string& arch) { | ||
| 25 | 6 | brass::Module mod("brotensor_trace_ew_ptx"); | |
| 26 | 6 | gpu_mir::build_elementwise_fn(mod, dag, plan, plan.vec, kEntryVec, true); | |
| 27 | 6 | gpu_mir::build_elementwise_fn(mod, dag, plan, 1, kEntryScalar, true); | |
| 28 | 6 | return brass::target::PtxTarget::emit_module(mod, ptx_opts_for(arch)); | |
| 29 | 6 | } | |
| 30 | |||
| 31 | 10 | std::string emit_row_norm(const TraceDAG& dag, const RowNormPlan& plan, | |
| 32 | const std::string& arch) { | ||
| 33 | 10 | brass::Module mod("brotensor_trace_rn_ptx"); | |
| 34 | 10 | gpu_mir::build_row_norm_fn(mod, dag, plan, plan.ew.vec, kEntryRowNorm, true); | |
| 35 | 10 | gpu_mir::build_row_norm_fn(mod, dag, plan, 1, kEntryRowNormScalar, true); | |
| 36 | 10 | return brass::target::PtxTarget::emit_module(mod, ptx_opts_for(arch)); | |
| 37 | 10 | } | |
| 38 | |||
| 39 | } // namespace brotensor::jit::ptx | ||
| 40 |