The upstream release tree, every tracked file byte for byte, from https://github.com/VecSzn/PolyStrata at tag v0.1.45-poly.1, commit d0cd84dc6bd009d1d9e2191e4e28cc76b80f1ee3. Nothing added, removed or edited; git diff against this commit is the whole story of the fork. Verified: the commit's tree hash equals the upstream commit's tree hash.
37 lines
1.6 KiB
C++
37 lines
1.6 KiB
C++
// strata/core/emulate.hpp - STRATA_EMULATE_CC: another GPU generation's code paths, run on this card (tests only).
|
|
//
|
|
// A build whose device code is PTX for an older architecture (CMAKE_CUDA_ARCHITECTURES=86-virtual) runs on a newer
|
|
// card through the driver's JIT, and every kernel then sees __CUDA_ARCH__ = 860. What the host decides from the
|
|
// device must agree with that, or it picks paths and shared-memory sizes the device code was not built for:
|
|
// STRATA_EMULATE_CC=75|80|86|89 makes each such query (compute capability, shared memory per block) answer as that
|
|
// card would. Speed under it says nothing about the real card; results do - the kernels are the real card's.
|
|
#pragma once
|
|
|
|
#include <cstdlib>
|
|
|
|
namespace strata {
|
|
|
|
/// the emulated compute capability as 10 * major + minor, or 0 (off)
|
|
inline int emulated_cc() {
|
|
static const int cc = [] {
|
|
const char* e = std::getenv("STRATA_EMULATE_CC");
|
|
const int v = e ? std::atoi(e) : 0;
|
|
return v >= 75 && v < 120 ? v : 0;
|
|
}();
|
|
return cc;
|
|
}
|
|
inline int cc_major_of(int real_major) { return emulated_cc() ? emulated_cc() / 10 : real_major; }
|
|
inline int cc_minor_of(int real_minor) { return emulated_cc() ? emulated_cc() % 10 : real_minor; }
|
|
/// cudaDevAttrMaxSharedMemoryPerBlockOptin as the emulated card reports it: 64 KB on Turing, 163 KB on the A100,
|
|
/// 99 KB on the other Ampere and Ada cards
|
|
inline int smem_optin_of(int real) {
|
|
switch (emulated_cc()) {
|
|
case 0: return real;
|
|
case 75: return 65536;
|
|
case 80: return 166912;
|
|
default: return real < 101376 ? real : 101376;
|
|
}
|
|
}
|
|
|
|
} // namespace strata
|