Mesa (main): radeonsi: align pipe_resource & sampler_view allocations to a cache line
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Oct 13 03:56:22 UTC 2021
Module: Mesa
Branch: main
Commit: c85ce2531e12adaabbd44cbceffdf81e65d1ca14
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c85ce2531e12adaabbd44cbceffdf81e65d1ca14
Author: Marek Olšák <marek.olsak at amd.com>
Date: Sun Jun 27 17:57:56 2021 -0400
radeonsi: align pipe_resource & sampler_view allocations to a cache line
It eliminates "False Sharing" for atomic operations. (see wikipedia)
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11618>
---
src/gallium/drivers/radeonsi/si_buffer.c | 14 ++++++--------
src/gallium/drivers/radeonsi/si_state.c | 4 ++--
src/gallium/drivers/radeonsi/si_texture.c | 6 +++---
3 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_buffer.c b/src/gallium/drivers/radeonsi/si_buffer.c
index 98925a33c6a..1c45c534488 100644
--- a/src/gallium/drivers/radeonsi/si_buffer.c
+++ b/src/gallium/drivers/radeonsi/si_buffer.c
@@ -218,12 +218,12 @@ static void si_resource_destroy(struct pipe_screen *screen, struct pipe_resource
util_range_destroy(&buffer->valid_buffer_range);
radeon_bo_reference(((struct si_screen*)screen)->ws, &buffer->buf, NULL);
util_idalloc_mt_free(&sscreen->buffer_ids, buffer->b.buffer_id_unique);
- FREE(buffer);
+ FREE_CL(buffer);
} else if (buf->flags & SI_RESOURCE_AUX_PLANE) {
struct si_auxiliary_texture *tex = (struct si_auxiliary_texture *)buf;
radeon_bo_reference(((struct si_screen*)screen)->ws, &tex->buffer, NULL);
- FREE(tex);
+ FREE_CL(tex);
} else {
struct si_texture *tex = (struct si_texture *)buf;
struct si_resource *resource = &tex->buffer;
@@ -234,7 +234,7 @@ static void si_resource_destroy(struct pipe_screen *screen, struct pipe_resource
si_resource_reference(&tex->cmask_buffer, NULL);
}
radeon_bo_reference(((struct si_screen*)screen)->ws, &resource->buf, NULL);
- FREE(tex);
+ FREE_CL(tex);
}
}
@@ -560,9 +560,7 @@ static void si_buffer_subdata(struct pipe_context *ctx, struct pipe_resource *bu
static struct si_resource *si_alloc_buffer_struct(struct pipe_screen *screen,
const struct pipe_resource *templ)
{
- struct si_resource *buf;
-
- buf = MALLOC_STRUCT(si_resource);
+ struct si_resource *buf = MALLOC_STRUCT_CL(si_resource);
buf->b.b = *templ;
buf->b.b.next = NULL;
@@ -594,7 +592,7 @@ static struct pipe_resource *si_buffer_create(struct pipe_screen *screen,
if (!si_alloc_resource(sscreen, buf)) {
threaded_resource_deinit(&buf->b.b);
- FREE(buf);
+ FREE_CL(buf);
return NULL;
}
@@ -644,7 +642,7 @@ static struct pipe_resource *si_buffer_from_user_memory(struct pipe_screen *scre
buf->buf = ws->buffer_from_ptr(ws, user_memory, templ->width0);
if (!buf->buf) {
threaded_resource_deinit(&buf->b.b);
- FREE(buf);
+ FREE_CL(buf);
return NULL;
}
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 03ed99ce56c..f77e7f48cfa 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -4321,7 +4321,7 @@ struct pipe_sampler_view *si_create_sampler_view_custom(struct pipe_context *ctx
unsigned force_level)
{
struct si_context *sctx = (struct si_context *)ctx;
- struct si_sampler_view *view = CALLOC_STRUCT(si_sampler_view);
+ struct si_sampler_view *view = CALLOC_STRUCT_CL(si_sampler_view);
struct si_texture *tex = (struct si_texture *)texture;
unsigned base_level, first_level, last_level;
unsigned char state_swizzle[4];
@@ -4455,7 +4455,7 @@ static void si_sampler_view_destroy(struct pipe_context *ctx, struct pipe_sample
struct si_sampler_view *view = (struct si_sampler_view *)state;
pipe_resource_reference(&state->texture, NULL);
- FREE(view);
+ FREE_CL(view);
}
static bool wrap_mode_uses_border_color(unsigned wrap, bool linear_filter)
diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c
index f17fe14309a..d335128c3ab 100644
--- a/src/gallium/drivers/radeonsi/si_texture.c
+++ b/src/gallium/drivers/radeonsi/si_texture.c
@@ -896,7 +896,7 @@ static struct si_texture *si_texture_create_object(struct pipe_screen *screen,
return NULL;
}
- tex = CALLOC_STRUCT(si_texture);
+ tex = CALLOC_STRUCT_CL(si_texture);
if (!tex)
goto error;
@@ -1129,7 +1129,7 @@ static struct si_texture *si_texture_create_object(struct pipe_screen *screen,
return tex;
error:
- FREE(tex);
+ FREE_CL(tex);
return NULL;
}
@@ -1584,7 +1584,7 @@ static struct pipe_resource *si_texture_from_handle(struct pipe_screen *screen,
return NULL;
if (whandle->plane >= util_format_get_num_planes(whandle->format)) {
- struct si_auxiliary_texture *tex = CALLOC_STRUCT(si_auxiliary_texture);
+ struct si_auxiliary_texture *tex = CALLOC_STRUCT_CL(si_auxiliary_texture);
if (!tex)
return NULL;
tex->b.b = *templ;
More information about the mesa-commit
mailing list