Skip to content

Commit 85c7760

Browse files
authored
Merge pull request #8716 from luotao1/cuda_version
fix only shared variables could be declared as static in the device code
2 parents df801a1 + 8c691c8 commit 85c7760

File tree

1 file changed

+12
-0
lines changed
  • paddle/fluid/framework

1 file changed

+12
-0
lines changed

paddle/fluid/framework/dim.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,13 @@ HOSTDEVICE int64_t& indexer<0>(Dim<0>& dim, int idx) {
158158
#else
159159
PADDLE_ASSERT(false);
160160
#endif
161+
#if (defined __CUDA_ARCH__) && (CUDA_VERSION < 8000)
162+
// On CUDA versions previous to 8.0, only __shared__ variables
163+
// could be declared as static in the device code.
164+
int64_t head = 0;
165+
#else
161166
static int64_t head = 0;
167+
#endif
162168
return head;
163169
}
164170

@@ -184,7 +190,13 @@ HOSTDEVICE int64_t indexer<0>(const Dim<0>& dim, int idx) {
184190
#else
185191
PADDLE_ASSERT(false);
186192
#endif
193+
#if (defined __CUDA_ARCH__) && (CUDA_VERSION < 8000)
194+
// On CUDA versions previous to 8.0, only __shared__ variables
195+
// could be declared as static in the device code.
196+
int64_t head = 0;
197+
#else
187198
static int64_t head = 0;
199+
#endif
188200
return head;
189201
}
190202

0 commit comments

Comments
 (0)