* [Patch] libgomp/target.c: Minor cleanup
@ 2020-09-10 9:17 Tobias Burnus
2020-09-10 9:22 ` Jakub Jelinek
0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2020-09-10 9:17 UTC (permalink / raw)
To: gcc-patches, Jakub Jelinek
[-- Attachment #1: Type: text/plain, Size: 576 bytes --]
Hi Jakub, hello all,
when looking at target.c, I stumbled over that code:
size_t mapnum → unsigned
if (mapnum == 0)
...
return;
if (mapnum > 0 || ....)
...
I fail to see how the latter condition can ever become false;
hence, I removed the "if" and used the if-body unconditionally,
removing some now pointless assignments.
OK?
Tobias
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
[-- Attachment #2: tgt-cleanup.diff --]
[-- Type: text/x-patch, Size: 1342 bytes --]
libgomp/target.c: Minor cleanup
libgomp/ChangeLog:
* target.c (gomp_map_vars_internal): Remove always-true condition
and body unconditionally.
diff --git a/libgomp/target.c b/libgomp/target.c
index 3e292eb8c62..440aad6b048 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -676,28 +676,23 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
if (mapnum == 0)
{
tgt->tgt_start = 0;
tgt->tgt_end = 0;
return tgt;
}
tgt_align = sizeof (void *);
tgt_size = 0;
- cbuf.chunks = NULL;
- cbuf.chunk_cnt = -1;
+ cbuf.chunk_cnt = 0;
cbuf.use_cnt = 0;
- cbuf.buf = NULL;
- if (mapnum > 1 || pragma_kind == GOMP_MAP_VARS_TARGET)
- {
- size_t chunks_size = (mapnum + 1) * sizeof (struct gomp_coalesce_chunk);
- cbuf.chunks = (struct gomp_coalesce_chunk *) gomp_alloca (chunks_size);
- cbuf.chunk_cnt = 0;
- }
+ size_t chunks_size = (mapnum + 1) * sizeof (struct gomp_coalesce_chunk);
+ cbuf.chunks = (struct gomp_coalesce_chunk *) gomp_alloca (chunks_size);
+
if (pragma_kind == GOMP_MAP_VARS_TARGET)
{
size_t align = 4 * sizeof (void *);
tgt_align = align;
tgt_size = mapnum * sizeof (void *);
cbuf.chunk_cnt = 1;
cbuf.use_cnt = 1 + (mapnum > 1);
cbuf.chunks[0].start = 0;
cbuf.chunks[0].end = tgt_size;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] libgomp/target.c: Minor cleanup
2020-09-10 9:17 [Patch] libgomp/target.c: Minor cleanup Tobias Burnus
@ 2020-09-10 9:22 ` Jakub Jelinek
2020-09-10 9:39 ` Tobias Burnus
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2020-09-10 9:22 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc-patches
On Thu, Sep 10, 2020 at 11:17:34AM +0200, Tobias Burnus wrote:
> Hi Jakub, hello all,
>
> when looking at target.c, I stumbled over that code:
> size_t mapnum → unsigned
> if (mapnum == 0)
> ...
> return;
>
> if (mapnum > 0 || ....)
> ...
But it is not mapnum > 0 here but mapnum > 1
So, for mapnum == 1 and e.g. target enter data it doesn't need to create the
chunks stuff, for a single mapping there is nothing to merge together.
> diff --git a/libgomp/target.c b/libgomp/target.c
> index 3e292eb8c62..440aad6b048 100644
> --- a/libgomp/target.c
> +++ b/libgomp/target.c
> @@ -676,28 +676,23 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
> if (mapnum == 0)
> {
> tgt->tgt_start = 0;
> tgt->tgt_end = 0;
> return tgt;
> }
>
> tgt_align = sizeof (void *);
> tgt_size = 0;
> - cbuf.chunks = NULL;
> - cbuf.chunk_cnt = -1;
> + cbuf.chunk_cnt = 0;
> cbuf.use_cnt = 0;
> - cbuf.buf = NULL;
> - if (mapnum > 1 || pragma_kind == GOMP_MAP_VARS_TARGET)
> - {
> - size_t chunks_size = (mapnum + 1) * sizeof (struct gomp_coalesce_chunk);
> - cbuf.chunks = (struct gomp_coalesce_chunk *) gomp_alloca (chunks_size);
> - cbuf.chunk_cnt = 0;
> - }
> + size_t chunks_size = (mapnum + 1) * sizeof (struct gomp_coalesce_chunk);
> + cbuf.chunks = (struct gomp_coalesce_chunk *) gomp_alloca (chunks_size);
> +
> if (pragma_kind == GOMP_MAP_VARS_TARGET)
> {
> size_t align = 4 * sizeof (void *);
> tgt_align = align;
> tgt_size = mapnum * sizeof (void *);
> cbuf.chunk_cnt = 1;
> cbuf.use_cnt = 1 + (mapnum > 1);
> cbuf.chunks[0].start = 0;
> cbuf.chunks[0].end = tgt_size;
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] libgomp/target.c: Minor cleanup
2020-09-10 9:22 ` Jakub Jelinek
@ 2020-09-10 9:39 ` Tobias Burnus
0 siblings, 0 replies; 3+ messages in thread
From: Tobias Burnus @ 2020-09-10 9:39 UTC (permalink / raw)
To: Jakub Jelinek, Tobias Burnus; +Cc: gcc-patches
On 9/10/20 11:22 AM, Jakub Jelinek wrote:
> But it is not mapnum > 0 here but mapnum >1
Error: need more coffee (well, tea)
Thanks for both the reasoning and catching this oversight of mine.
Tobias
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-10 9:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 9:17 [Patch] libgomp/target.c: Minor cleanup Tobias Burnus
2020-09-10 9:22 ` Jakub Jelinek
2020-09-10 9:39 ` Tobias Burnus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).