cpu.mode fastest code on the internet
solution

sol_3860713_1787981813753161157_4

C++ Scalar sparse merge dot 3 runs
01 source
Submitted source 723 bytes
Compiler clang++ Flags -O3 -march=native -std=c++20
show source
#include <cstddef>
#include <cstdint>

extern "C" void nk_sparse_dot_u32f32(
    const std::uint32_t *a,
    const std::uint32_t *b,
    const float *a_weights,
    const float *b_weights,
    std::size_t a_length,
    std::size_t b_length,
    double *product
) {
    std::size_t i = 0;
    std::size_t j = 0;
    double sum = 0.0;

    while (i < a_length && j < b_length) {
        const std::uint32_t ai = a[i];
        const std::uint32_t bj = b[j];
        if (ai == bj) {
            sum += static_cast<double>(a_weights[i]) * static_cast<double>(b_weights[j]);
            ++i;
            ++j;
        } else if (ai < bj) {
            ++i;
        } else {
            ++j;
        }
    }

    *product = sum;
}
02 jobs
Systems 03 jobs
03 counters
Performance counters 31 counters
cyclesi
183,682,995
Show more
branch_instructionsi
46,447,108
branch_missesi
5,711,173
cycle_activity.stalls_l1d_missi
996,806
cycle_activity.stalls_l2_missi
692,923
cycle_activity.stalls_l3_missi
562,423
cycle_activity.stalls_totali
83,392,602
dtlb_load_misses.walk_completedi
799
exe_activity.bound_on_loadsi
15,811,849
exe_activity.bound_on_storesi
15,608
instructionsi
116,124,155
machine_clearsi
800
mem_inst_retired.split_loadsi
1,214
mem_load_retired.l1_missi
90,710
mem_load_retired.l2_missi
5,702
mem_load_retired.l3_missi
3,812
tma_backend_boundi
99,278,784
tma_bad_speculationi
321,164,523
tma_branch_mispredict_slotsi
321,903,505
tma_frontend_boundi
604,476,850
tma_memory_boundi
12,345,006
tma_retiringi
85,021,647
tma_slotsi
1,104,221,352
uops_dispatched.port_0i
12,000,137
uops_dispatched.port_1i
9,068,955
uops_dispatched.port_2_3_10i
60,329,088
uops_dispatched.port_4_9i
821,731
uops_dispatched.port_5_11i
31,942,929
uops_dispatched.port_6i
80,700,354
uops_dispatched.port_7_8i
820,640
uops_retired.msi
0
04 top down
Top-down analysis Raptor Cove P-core
05 profile
load profile