brotensor/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
20 / 20
100.0%
Branches:
11 / 24
45.8%
Functions:
3 / 3
100.0%

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
3/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
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
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 gpu_mir::build_elementwise_fn(mod, dag, plan, plan.vec, kEntryVec, true);
27
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 gpu_mir::build_elementwise_fn(mod, dag, plan, 1, kEntryScalar, true);
28
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
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
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 gpu_mir::build_row_norm_fn(mod, dag, plan, plan.ew.vec, kEntryRowNorm, true);
35
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 gpu_mir::build_row_norm_fn(mod, dag, plan, 1, kEntryRowNormScalar, true);
36
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 return brass::target::PtxTarget::emit_module(mod, ptx_opts_for(arch));
37 10 }
38
39 } // namespace brotensor::jit::ptx
40