From 8c691c8de00383f3397b2a936cb8c0f0dc7df5a6 Mon Sep 17 00:00:00 2001 From: Luo Tao Date: Fri, 2 Mar 2018 20:28:51 +0800 Subject: [PATCH] fix only shared variables could be declared as static in the device code --- paddle/fluid/framework/dim.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/paddle/fluid/framework/dim.h b/paddle/fluid/framework/dim.h index 8d288120e..58b75ba4b 100644 --- a/paddle/fluid/framework/dim.h +++ b/paddle/fluid/framework/dim.h @@ -158,7 +158,13 @@ HOSTDEVICE int64_t& indexer<0>(Dim<0>& dim, int idx) { #else PADDLE_ASSERT(false); #endif +#if (defined __CUDA_ARCH__) && (CUDA_VERSION < 8000) + // On CUDA versions previous to 8.0, only __shared__ variables + // could be declared as static in the device code. + int64_t head = 0; +#else static int64_t head = 0; +#endif return head; } @@ -184,7 +190,13 @@ HOSTDEVICE int64_t indexer<0>(const Dim<0>& dim, int idx) { #else PADDLE_ASSERT(false); #endif +#if (defined __CUDA_ARCH__) && (CUDA_VERSION < 8000) + // On CUDA versions previous to 8.0, only __shared__ variables + // could be declared as static in the device code. + int64_t head = 0; +#else static int64_t head = 0; +#endif return head; } -- GitLab