[Mesa-dev] [PATCH 13/22] r600g, radeonsi: consolidate get_compute_param

Marek Olšák maraeo at gmail.com
Wed Jan 22 12:13:05 PST 2014


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/r600/r600_pipe.c          | 162 --------------------------
 src/gallium/drivers/r600/r600_pipe.h          |   3 -
 src/gallium/drivers/radeon/r600_pipe_common.c | 157 +++++++++++++++++++++++++
 src/gallium/drivers/radeon/r600_pipe_common.h |   1 +
 src/gallium/drivers/radeonsi/si_pipe.c        | 100 ----------------
 src/gallium/drivers/radeonsi/si_pipe.h        |   1 -
 src/gallium/drivers/radeonsi/si_shader.c      |   2 +-
 7 files changed, 159 insertions(+), 267 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index aa6ebc0..d95e717 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -508,167 +508,6 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e
 	return 0;
 }
 
-const char * r600_llvm_gpu_string(enum radeon_family family)
-{
-	const char * gpu_family;
-
-	switch (family) {
-	case CHIP_R600:
-	case CHIP_RV630:
-	case CHIP_RV635:
-	case CHIP_RV670:
-		gpu_family = "r600";
-		break;
-	case CHIP_RV610:
-	case CHIP_RV620:
-	case CHIP_RS780:
-	case CHIP_RS880:
-		gpu_family = "rs880";
-		break;
-	case CHIP_RV710:
-		gpu_family = "rv710";
-		break;
-	case CHIP_RV730:
-		gpu_family = "rv730";
-		break;
-	case CHIP_RV740:
-	case CHIP_RV770:
-		gpu_family = "rv770";
-		break;
-	case CHIP_PALM:
-	case CHIP_CEDAR:
-		gpu_family = "cedar";
-		break;
-	case CHIP_SUMO:
-	case CHIP_SUMO2:
-		gpu_family = "sumo";
-		break;
-	case CHIP_REDWOOD:
-		gpu_family = "redwood";
-		break;
-	case CHIP_JUNIPER:
-		gpu_family = "juniper";
-		break;
-	case CHIP_HEMLOCK:
-	case CHIP_CYPRESS:
-		gpu_family = "cypress";
-		break;
-	case CHIP_BARTS:
-		gpu_family = "barts";
-		break;
-	case CHIP_TURKS:
-		gpu_family = "turks";
-		break;
-	case CHIP_CAICOS:
-		gpu_family = "caicos";
-		break;
-	case CHIP_CAYMAN:
-        case CHIP_ARUBA:
-		gpu_family = "cayman";
-		break;
-	default:
-		gpu_family = "";
-		fprintf(stderr, "Chip not supported by r600 llvm "
-			"backend, please file a bug at " PACKAGE_BUGREPORT "\n");
-		break;
-	}
-	return gpu_family;
-}
-
-
-static int r600_get_compute_param(struct pipe_screen *screen,
-        enum pipe_compute_cap param,
-        void *ret)
-{
-	struct r600_screen *rscreen = (struct r600_screen *)screen;
-	//TODO: select these params by asic
-	switch (param) {
-	case PIPE_COMPUTE_CAP_IR_TARGET: {
-		const char *gpu = r600_llvm_gpu_string(rscreen->b.family);
-		if (ret) {
-			sprintf(ret, "%s-r600--", gpu);
-		}
-		return (8 + strlen(gpu)) * sizeof(char);
-	}
-	case PIPE_COMPUTE_CAP_GRID_DIMENSION:
-		if (ret) {
-			uint64_t * grid_dimension = ret;
-			grid_dimension[0] = 3;
-		}
-		return 1 * sizeof(uint64_t);
-
-	case PIPE_COMPUTE_CAP_MAX_GRID_SIZE:
-		if (ret) {
-			uint64_t * grid_size = ret;
-			grid_size[0] = 65535;
-			grid_size[1] = 65535;
-			grid_size[2] = 1;
-		}
-		return 3 * sizeof(uint64_t) ;
-
-	case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE:
-		if (ret) {
-			uint64_t * block_size = ret;
-			block_size[0] = 256;
-			block_size[1] = 256;
-			block_size[2] = 256;
-		}
-		return 3 * sizeof(uint64_t);
-
-	case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK:
-		if (ret) {
-			uint64_t * max_threads_per_block = ret;
-			*max_threads_per_block = 256;
-		}
-		return sizeof(uint64_t);
-
-	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. */
-			*max_global_size = 201326592;
-		}
-		return sizeof(uint64_t);
-
-	case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE:
-		if (ret) {
-			uint64_t * max_input_size = ret;
-			*max_input_size = 1024;
-		}
-		return sizeof(uint64_t);
-
-	case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE:
-		if (ret) {
-			uint64_t * max_local_size = ret;
-			/* XXX: This is what the proprietary driver reports, we
-			 * may want to use a different value. */
-			*max_local_size = 32768;
-		}
-		return sizeof(uint64_t);
-
-	case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE:
-		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.
-			 */
-			*max_mem_alloc_size = max_global_size / 4;
-		}
-		return sizeof(uint64_t);
-
-	default:
-		fprintf(stderr, "unknown PIPE_COMPUTE_CAP %d\n", param);
-		return 0;
-	}
-}
-
 static void r600_destroy_screen(struct pipe_screen* pscreen)
 {
 	struct r600_screen *rscreen = (struct r600_screen *)pscreen;
@@ -719,7 +558,6 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
 	rscreen->b.b.destroy = r600_destroy_screen;
 	rscreen->b.b.get_param = r600_get_param;
 	rscreen->b.b.get_shader_param = r600_get_shader_param;
-	rscreen->b.b.get_compute_param = r600_get_compute_param;
 	if (rscreen->b.info.chip_class >= EVERGREEN) {
 		rscreen->b.b.is_format_supported = evergreen_is_format_supported;
 	} else {
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index bdaeb32..c8754f3 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -539,9 +539,6 @@ void r600_decompress_depth_textures(struct r600_context *rctx,
 void r600_decompress_color_textures(struct r600_context *rctx,
 				    struct r600_samplerview_state *textures);
 
-/* r600_pipe.c */
-const char * r600_llvm_gpu_string(enum radeon_family family);
-
 /* r600_shader.c */
 int r600_pipe_shader_create(struct pipe_context *ctx,
 			    struct r600_pipe_shader *shader,
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index 7447eea..931c91c 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -247,6 +247,162 @@ static int r600_get_video_param(struct pipe_screen *screen,
 	}
 }
 
+const char *r600_get_llvm_processor_name(enum radeon_family family)
+{
+	switch (family) {
+	case CHIP_R600:
+	case CHIP_RV630:
+	case CHIP_RV635:
+	case CHIP_RV670:
+		return "r600";
+	case CHIP_RV610:
+	case CHIP_RV620:
+	case CHIP_RS780:
+	case CHIP_RS880:
+		return "rs880";
+	case CHIP_RV710:
+		return "rv710";
+	case CHIP_RV730:
+		return "rv730";
+	case CHIP_RV740:
+	case CHIP_RV770:
+		return "rv770";
+	case CHIP_PALM:
+	case CHIP_CEDAR:
+		return "cedar";
+	case CHIP_SUMO:
+	case CHIP_SUMO2:
+		return "sumo";
+	case CHIP_REDWOOD:
+		return "redwood";
+	case CHIP_JUNIPER:
+		return "juniper";
+	case CHIP_HEMLOCK:
+	case CHIP_CYPRESS:
+		return "cypress";
+	case CHIP_BARTS:
+		return "barts";
+	case CHIP_TURKS:
+		return "turks";
+	case CHIP_CAICOS:
+		return "caicos";
+	case CHIP_CAYMAN:
+        case CHIP_ARUBA:
+		return "cayman";
+
+	case CHIP_TAHITI: return "tahiti";
+	case CHIP_PITCAIRN: return "pitcairn";
+	case CHIP_VERDE: return "verde";
+	case CHIP_OLAND: return "oland";
+#if HAVE_LLVM <= 0x0303
+	default: return "SI";
+#else
+	case CHIP_HAINAN: return "hainan";
+	case CHIP_BONAIRE: return "bonaire";
+	case CHIP_KABINI: return "kabini";
+	case CHIP_KAVERI: return "kaveri";
+	case CHIP_HAWAII: return "hawaii";
+	default: return "";
+#endif
+	}
+}
+
+static int r600_get_compute_param(struct pipe_screen *screen,
+        enum pipe_compute_cap param,
+        void *ret)
+{
+	struct r600_common_screen *rscreen = (struct r600_common_screen *)screen;
+
+	//TODO: select these params by asic
+	switch (param) {
+	case PIPE_COMPUTE_CAP_IR_TARGET: {
+		const char *gpu = r600_get_llvm_processor_name(rscreen->family);
+		if (ret) {
+			sprintf(ret, "%s-r600--", gpu);
+		}
+		return (8 + strlen(gpu)) * sizeof(char);
+	}
+	case PIPE_COMPUTE_CAP_GRID_DIMENSION:
+		if (ret) {
+			uint64_t *grid_dimension = ret;
+			grid_dimension[0] = 3;
+		}
+		return 1 * sizeof(uint64_t);
+
+	case PIPE_COMPUTE_CAP_MAX_GRID_SIZE:
+		if (ret) {
+			uint64_t *grid_size = ret;
+			grid_size[0] = 65535;
+			grid_size[1] = 65535;
+			grid_size[2] = 1;
+		}
+		return 3 * sizeof(uint64_t) ;
+
+	case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE:
+		if (ret) {
+			uint64_t *block_size = ret;
+			block_size[0] = 256;
+			block_size[1] = 256;
+			block_size[2] = 256;
+		}
+		return 3 * sizeof(uint64_t);
+
+	case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK:
+		if (ret) {
+			uint64_t *max_threads_per_block = ret;
+			*max_threads_per_block = 256;
+		}
+		return sizeof(uint64_t);
+
+	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;
+		}
+		return sizeof(uint64_t);
+
+	case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE:
+		if (ret) {
+			uint64_t *max_local_size = ret;
+			/* Value reported by the closed source driver. */
+			*max_local_size = 32768;
+		}
+		return sizeof(uint64_t);
+
+	case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE:
+		if (ret) {
+			uint64_t *max_input_size = ret;
+			/* Value reported by the closed source driver. */
+			*max_input_size = 1024;
+		}
+		return sizeof(uint64_t);
+
+	case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE:
+		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.
+			 */
+			*max_mem_alloc_size = max_global_size / 4;
+		}
+		return sizeof(uint64_t);
+
+	default:
+		fprintf(stderr, "unknown PIPE_COMPUTE_CAP %d\n", param);
+		return 0;
+	}
+}
+
 static uint64_t r600_get_timestamp(struct pipe_screen *screen)
 {
 	struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
@@ -432,6 +588,7 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen,
 
 	rscreen->b.get_name = r600_get_name;
 	rscreen->b.get_vendor = r600_get_vendor;
+	rscreen->b.get_compute_param = r600_get_compute_param;
 	rscreen->b.get_paramf = r600_get_paramf;
 	rscreen->b.get_driver_query_info = r600_get_driver_query_info;
 	rscreen->b.get_timestamp = r600_get_timestamp;
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index 2e7deaf..975a8a1 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -337,6 +337,7 @@ void r600_screen_clear_buffer(struct r600_common_screen *rscreen, struct pipe_re
 			      unsigned offset, unsigned size, unsigned value);
 struct pipe_resource *r600_resource_create_common(struct pipe_screen *screen,
 						  const struct pipe_resource *templ);
+const char *r600_get_llvm_processor_name(enum radeon_family family);
 
 /* r600_query.c */
 void r600_query_init(struct r600_common_context *rctx);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 0c046bc..2656fdd 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -219,26 +219,6 @@ fail:
  * pipe_screen
  */
 
-const char *si_get_llvm_processor_name(enum radeon_family family)
-{
-	switch (family) {
-		case CHIP_TAHITI: return "tahiti";
-		case CHIP_PITCAIRN: return "pitcairn";
-		case CHIP_VERDE: return "verde";
-		case CHIP_OLAND: return "oland";
-#if HAVE_LLVM <= 0x0303
-		default: return "SI";
-#else
-		case CHIP_HAINAN: return "hainan";
-		case CHIP_BONAIRE: return "bonaire";
-		case CHIP_KABINI: return "kabini";
-		case CHIP_KAVERI: return "kaveri";
-		case CHIP_HAWAII: return "hawaii";
-		default: return "";
-#endif
-	}
-}
-
 static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
 {
 	struct si_screen *sscreen = (struct si_screen *)pscreen;
@@ -426,85 +406,6 @@ static int si_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enu
 	return 0;
 }
 
-static int si_get_compute_param(struct pipe_screen *screen,
-        enum pipe_compute_cap param,
-        void *ret)
-{
-	struct si_screen *sscreen = (struct si_screen *)screen;
-	//TODO: select these params by asic
-	switch (param) {
-	case PIPE_COMPUTE_CAP_IR_TARGET: {
-		const char *gpu = si_get_llvm_processor_name(sscreen->b.family);
-	        if (ret) {
-			sprintf(ret, "%s-r600--", gpu);
-		}
-		return (8 + strlen(gpu)) * sizeof(char);
-	}
-	case PIPE_COMPUTE_CAP_GRID_DIMENSION:
-		if (ret) {
-			uint64_t * grid_dimension = ret;
-			grid_dimension[0] = 3;
-		}
-		return 1 * sizeof(uint64_t);
-	case PIPE_COMPUTE_CAP_MAX_GRID_SIZE:
-		if (ret) {
-			uint64_t * grid_size = ret;
-			grid_size[0] = 65535;
-			grid_size[1] = 65535;
-			grid_size[2] = 1;
-		}
-		return 3 * sizeof(uint64_t) ;
-
-	case PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE:
-		if (ret) {
-			uint64_t * block_size = ret;
-			block_size[0] = 256;
-			block_size[1] = 256;
-			block_size[2] = 256;
-		}
-		return 3 * sizeof(uint64_t);
-	case PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK:
-		if (ret) {
-			uint64_t * max_threads_per_block = ret;
-			*max_threads_per_block = 256;
-		}
-		return sizeof(uint64_t);
-
-	case PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE:
-		if (ret) {
-			uint64_t *max_global_size = ret;
-			/* XXX: Not sure what to put here. */
-			*max_global_size = 2000000000;
-		}
-		return sizeof(uint64_t);
-	case PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE:
-		if (ret) {
-			uint64_t *max_local_size = ret;
-			/* Value reported by the closed source driver. */
-			*max_local_size = 32768;
-		}
-		return sizeof(uint64_t);
-	case PIPE_COMPUTE_CAP_MAX_INPUT_SIZE:
-		if (ret) {
-			uint64_t *max_input_size = ret;
-			/* Value reported by the closed source driver. */
-			*max_input_size = 1024;
-		}
-		return sizeof(uint64_t);
-	case PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE:
-		if (ret) {
-			uint64_t max_global_size;
-			uint64_t *max_mem_alloc_size = ret;
-			si_get_compute_param(screen, PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE, &max_global_size);
-			*max_mem_alloc_size = max_global_size / 4;
-		}
-		return sizeof(uint64_t);
-	default:
-		fprintf(stderr, "unknown PIPE_COMPUTE_CAP %d\n", param);
-		return 0;
-	}
-}
-
 static void si_destroy_screen(struct pipe_screen* pscreen)
 {
 	struct si_screen *sscreen = (struct si_screen *)pscreen;
@@ -540,7 +441,6 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
 	sscreen->b.b.destroy = si_destroy_screen;
 	sscreen->b.b.get_param = si_get_param;
 	sscreen->b.b.get_shader_param = si_get_shader_param;
-	sscreen->b.b.get_compute_param = si_get_compute_param;
 	sscreen->b.b.is_format_supported = si_is_format_supported;
 
 	if (!r600_common_screen_init(&sscreen->b, ws)) {
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index e137bfc..d7d701b 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -169,7 +169,6 @@ void si_upload_index_buffer(struct si_context *sctx,
 /* si_pipe.c */
 void si_flush(struct pipe_context *ctx, struct pipe_fence_handle **fence,
 	       unsigned flags);
-const char *si_get_llvm_processor_name(enum radeon_family family);
 
 /* si_translate.c */
 void si_translate_index_buffer(struct si_context *sctx,
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 5c6f128..6497ef7 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1899,7 +1899,7 @@ int si_compile_llvm(struct si_context *sctx, struct si_pipe_shader *shader,
 			shader->selector ? shader->selector->tokens : NULL);
 	memset(&binary, 0, sizeof(binary));
 	radeon_llvm_compile(mod, &binary,
-		si_get_llvm_processor_name(sctx->screen->b.family), dump);
+		r600_get_llvm_processor_name(sctx->screen->b.family), dump);
 	if (dump && ! binary.disassembled) {
 		fprintf(stderr, "SI CODE:\n");
 		for (i = 0; i < binary.code_size; i+=4 ) {
-- 
1.8.3.2



More information about the mesa-dev mailing list