基于 CCCL single_pass_scan_operators.cuh 源码分析: delay() 在 gridDim.x < 500 时只做 __threadfence_block,不 __nanosleep BI-V100: 16 SMs → max 32 CTAs → 永远 < 500 变更文件: tuning_reduce_by_key.cuh: 全部 66 条 → no_delay (已在上个 commit) tuning_scan_by_key.cuh: 全部 ~76 条 → no_delay (已在上个 commit) tuning_select_if.cuh: 38 个 scale_delay() → nd(l2w), 删除 scale_delay 函数 tuning_unique_by_key.cuh: 31 个 sd() → nd(l2w), 删除 sd 函数 tuning_three_way_partition.cuh: 6 个 sd() → nd(l2w) tuning_rle_encode.cuh: 5 个 sd() → nd(l2w) tuning_rle_non_trivial_runs.cuh: 5 个 sd() → nd(l2w) tuning_scan.cuh: 12 个 exponential_* → no_delay L2WriteLatency 全部保留 (CCCL 构造函数一次性 L2 write 等待) threads/items/load_algorithm/load_modifier 不变 (CCCL benchmark-tuned)
64 lines
2.4 KiB
Plaintext
64 lines
2.4 KiB
Plaintext
// muh/include/muh/tuning/tuning_rle_encode.cuh — BI-V100
|
|
// Full port from CCCL (626 lines): SM100 (4) + SM90 (5) + SM80 (5) + int128
|
|
// Dispatch: (length_size=4, key_size 1/2/4/8/16)
|
|
#pragma once
|
|
#include "muh/hardware.cuh"
|
|
#include "muh/tuning/common.cuh"
|
|
|
|
namespace muh::tuning::rle_encode {
|
|
|
|
struct RleLookbackPolicy {
|
|
int threads_per_block; int items_per_thread;
|
|
BlockLoadAlgorithm load_algorithm; CacheLoadModifier load_modifier;
|
|
BlockScanAlgorithm scan_algorithm; LookbackDelayPolicy delay;
|
|
};
|
|
enum class RleAlgorithm { lookback };
|
|
struct RleEncodePolicy { RleAlgorithm algorithm; RleLookbackPolicy lookback; };
|
|
|
|
struct policy_selector {
|
|
int key_size;
|
|
bool key_is_primitive;
|
|
|
|
static constexpr LookbackDelayPolicy nd(int l2w) { return {LookbackDelayAlgorithm::no_delay, 0, l2w}; }
|
|
static constexpr LookbackDelayPolicy nd(int l2w) {
|
|
return {LookbackDelayAlgorithm::no_delay, 0, l2w};
|
|
}
|
|
|
|
constexpr RleLookbackPolicy p(int tpb, int ipt, BlockLoadAlgorithm la,
|
|
CacheLoadModifier lm, LookbackDelayPolicy d) const {
|
|
return {tpb, ipt, la, lm, BLOCK_SCAN_WARP_SCANS, d};
|
|
}
|
|
|
|
constexpr RleLookbackPolicy dispatch() const {
|
|
if (!key_is_primitive) {
|
|
if (key_size==16) return p(128, 11, BLOCK_LOAD_WARP_TRANSPOSE, LOAD_DEFAULT,
|
|
nd(930));
|
|
int ipt = 6 * 8 / (key_size + 4); if (ipt<1) ipt=1; if (ipt>6) ipt=6;
|
|
return p(128, ipt, BLOCK_LOAD_DIRECT, LOAD_DEFAULT, nd(450));
|
|
}
|
|
|
|
// SM100 (delay scaled)
|
|
// ipt_14.tpb_256.trp_0.ld_1.ns_468.dcid_7.l2w_300
|
|
if (key_size==1) return p(256, 14, BLOCK_LOAD_DIRECT, LOAD_CA,
|
|
nd(300));
|
|
// ipt_14.tpb_224.trp_0.ld_0.ns_376.dcid_7.l2w_420
|
|
if (key_size==2) return p(224, 14, BLOCK_LOAD_DIRECT, LOAD_DEFAULT,
|
|
nd(420));
|
|
// ipt_14.tpb_256.trp_0.ld_1.ns_956.dcid_7.l2w_70
|
|
if (key_size==4) return p(256, 14, BLOCK_LOAD_DIRECT, LOAD_CA,
|
|
nd(70));
|
|
// ipt_9.tpb_224.trp_1.ld_0.ns_188.dcid_2.l2w_765
|
|
if (key_size==8) return p(224, 9, BLOCK_LOAD_WARP_TRANSPOSE, LOAD_DEFAULT,
|
|
nd(765));
|
|
|
|
int ipt = 6 * 8 / (key_size + 4); if (ipt<1) ipt=1; if (ipt>6) ipt=6;
|
|
return p(128, ipt, BLOCK_LOAD_DIRECT, LOAD_DEFAULT, nd(450));
|
|
}
|
|
|
|
constexpr RleEncodePolicy operator()(const hardware_capability& hw) const {
|
|
return {RleAlgorithm::lookback, dispatch()};
|
|
}
|
|
};
|
|
|
|
} // namespace muh::tuning::rle_encode
|