Skip to content

Commit 630ed84

Browse files
committed
cache get_lds_size()
Signed-off-by: charlifu <[email protected]>
1 parent 12447b9 commit 630ed84

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

csrc/rocm/skinny_gemms.cu

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@
2828
#define LDS_SIZE 64 * 1024
2929
#endif
3030

31-
static int get_lds_size() {
32-
auto dprops = at::cuda::getCurrentDeviceProperties();
33-
std::string device_arch = dprops->gcnArchName;
34-
size_t substring = device_arch.find("gfx95");
35-
if (substring == std::string::npos) return 64 * 1024;
36-
return 160 * 1024;
31+
int get_lds_size() {
32+
static bool is_cached = false;
33+
static int result;
34+
if (is_cached == false) {
35+
auto dprops = at::cuda::getCurrentDeviceProperties();
36+
std::string device_arch = dprops->gcnArchName;
37+
size_t substring = device_arch.find("gfx95");
38+
result = (substring == std::string::npos ? 64 * 1024 : 160 * 1024);
39+
is_cached = true;
40+
}
41+
return result;
3742
}
3843

3944
#if defined(NDEBUG)

0 commit comments

Comments
 (0)