Mesa (master): radeon/compute: Fix reported values for MAX_GLOBAL_SIZE and MAX_MEM_ALLOC_SIZE

Tom Stellard tstellar at kemper.freedesktop.org
Wed Aug 13 19:21:38 UTC 2014


Module: Mesa
Branch: master
Commit: 77ea58ca81eb3f5521d67c4459d3469df6d5ffd8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=77ea58ca81eb3f5521d67c4459d3469df6d5ffd8

Author: Tom Stellard <thomas.stellard at amd.com>
Date:   Thu Aug  7 15:21:59 2014 -0400

radeon/compute: Fix reported values for MAX_GLOBAL_SIZE and MAX_MEM_ALLOC_SIZE

There is a hard limit in older kernels of 256 MB for buffer allocations,
so report this value as MAX_MEM_ALLOC_SIZE and adjust MAX_GLOBAL_SIZE
to statisfy requirements of OpenCL.

CC: "10.2" <mesa-stable at lists.freedesktop.org>

---

 src/gallium/drivers/radeon/r600_pipe_common.c |   32 +++++++++++++++----------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index eb44d72..95abfb8 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -474,13 +474,21 @@ static int r600_get_compute_param(struct pipe_screen *screen,
 	case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE:
 		if (ret) {
 			uint64_t *max_global_size = ret;
-			/* XXX: This is what the proprietary driver reports, we
-			 * may want to use a different value. */
-			/* XXX: Not sure what to put here for SI. */
-			if (rscreen->chip_class >= SI)
-				*max_global_size = 2000000000;
-			else
-				*max_global_size = 201326592;
+			uint64_t max_mem_alloc_size;
+
+			r600_get_compute_param(screen,
+				PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE,
+				&max_mem_alloc_size);
+
+			/* In OpenCL, the MAX_MEM_ALLOC_SIZE must be at least
+			 * 1/4 of the MAX_GLOBAL_SIZE.  Since the
+			 * MAX_MEM_ALLOC_SIZE is fixed for older kernels,
+			 * make sure we never report more than
+			 * 4 * MAX_MEM_ALLOC_SIZE.
+			 */
+			*max_global_size = MIN2(4 * max_mem_alloc_size,
+				rscreen->info.gart_size +
+				rscreen->info.vram_size);
 		}
 		return sizeof(uint64_t);
 
@@ -504,13 +512,11 @@ static int r600_get_compute_param(struct pipe_screen *screen,
 		if (ret) {
 			uint64_t max_global_size;
 			uint64_t *max_mem_alloc_size = ret;
-			r600_get_compute_param(screen, PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE, &max_global_size);
-			/* OpenCL requres this value be at least
-			 * max(MAX_GLOBAL_SIZE / 4, 128 * 1024 *1024)
-			 * I'm really not sure what value to report here, but
-			 * MAX_GLOBAL_SIZE / 4 seems resonable.
+
+			/* XXX: The limit in older kernels is 256 MB.  We
+			 * should add a query here for newer kernels.
 			 */
-			*max_mem_alloc_size = max_global_size / 4;
+			*max_mem_alloc_size = 256 * 1024 * 1024;
 		}
 		return sizeof(uint64_t);
 




More information about the mesa-commit mailing list