Skip to content

Commit 1dbb3fa

Browse files
author
fengshuai03
committed
std:min and std::max should be change because of windows
1 parent 51a152b commit 1dbb3fa

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

paddle/fluid/platform/gpu_launch_config.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424
#include <hip/hip_runtime.h>
2525
#endif
2626

27-
#ifdef _WIN32
28-
#ifndef NOMINMAX
29-
#define NOMINMAX // msvc max/min macro conflict with std::min/max
30-
#endif // NOMINMAX
31-
#endif // _WIN32
32-
3327
#include <stddef.h>
3428
#include <algorithm>
3529
#include <string>
@@ -80,7 +74,7 @@ inline GpuLaunchConfig GetGpuLaunchConfig1D(
8074

8175
// Compute physical threads we need, should small than max sm threads
8276
const int physical_thread_count =
83-
std::min(max_physical_threads, theory_thread_count);
77+
(std::min)(max_physical_threads, theory_thread_count);
8478

8579
// Get compute_capability
8680
const int capability = context.GetComputeCapability();
@@ -93,9 +87,9 @@ inline GpuLaunchConfig GetGpuLaunchConfig1D(
9387

9488
// Need get from device
9589
const int thread_per_block =
96-
std::min(max_threads, context.GetMaxThreadsPerBlock());
90+
(std::min)(max_threads, context.GetMaxThreadsPerBlock());
9791
const int block_count =
98-
std::min(DivUp(physical_thread_count, thread_per_block), sm);
92+
(std::min)(DivUp(physical_thread_count, thread_per_block), sm);
9993

10094
GpuLaunchConfig config;
10195
config.theory_thread_count.x = theory_thread_count;
@@ -117,19 +111,20 @@ inline GpuLaunchConfig GetGpuLaunchConfig2D(
117111
y_dim));
118112

119113
const int kThreadsPerBlock = 256;
120-
int block_cols = std::min(x_dim, kThreadsPerBlock);
121-
int block_rows = std::max(kThreadsPerBlock / block_cols, 1);
114+
int block_cols = (std::min)(x_dim, kThreadsPerBlock);
115+
int block_rows = (std::max)(kThreadsPerBlock / block_cols, 1);
122116

123117
int max_physical_threads = context.GetMaxPhysicalThreadCount();
124-
const int max_blocks = std::max(max_physical_threads / kThreadsPerBlock, 1);
118+
const int max_blocks = (std::max)(max_physical_threads / kThreadsPerBlock, 1);
125119

126120
GpuLaunchConfig config;
127121
// Noticed, block size is not align to 32, if needed do it yourself.
128122
config.theory_thread_count = dim3(x_dim, y_dim, 1);
129123
config.thread_per_block = dim3(block_cols, block_rows, 1);
130124

131-
int grid_x = std::min(DivUp(x_dim, block_cols), max_blocks);
132-
int grid_y = std::min(max_blocks / grid_x, std::max(y_dim / block_rows, 1));
125+
int grid_x = (std::min)(DivUp(x_dim, block_cols), max_blocks);
126+
int grid_y =
127+
(std::min)(max_blocks / grid_x, (std::max)(y_dim / block_rows, 1));
133128

134129
config.block_per_grid = dim3(grid_x, grid_y, 1);
135130
return config;

0 commit comments

Comments
 (0)