From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 75461385E006; Fri, 27 Mar 2020 19:32:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75461385E006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1585337523; bh=GCiQMTF6K/0PCkN7D4fACE5DReZ4TKW+xed//UwTk/Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YllsgPuD6Eo73uoVIZ5cy31yv+VH4FPEH8IU6D+ReXpT2sMGeyT+E6EAuwBVSC648 jIjqTH3hHQDJQv5WvD3NMZhPg0P0V8cpg4dXFacgLFw+XbP2OBIlMXwKQxum/+0kHJ cAlqYximYJzUdMEvOZ3TH3oIhbuNeRPEPOVi70p0= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libgomp/94290] [gfortran] OpenMP target teams distribute default firstprivate causes failure to map back values from device Date: Fri, 27 Mar 2020 19:32:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgomp X-Bugzilla-Version: 9.2.0 X-Bugzilla-Keywords: openmp X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: resolution bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2020 19:32:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94290 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Jakub Jelinek --- This is a test bug. Please see https://www.openmp.org/spec-html/5.0/openmpse22.html#x116-4340002.14 When you have a combined or composite constructs, clauses that apply to just one of the constructs generally are applied to the construct which allows t= hem, while clauses that can be applied to multiple constructs have more complica= ted clause distribution rules in that section. When you have combined !$omp target teams default(firstprivate) map(from:a) then the default clause, as it applies to teams only and not target, goes to teams, and map clauses go to target. So, it is like !$omp target map(from:a) !$omp teams default(firstprivate) Now, if you reference a in the teams region, there is no data sharing claus= e on the teams construct for a, and the default is firstprivate, which means an implicit firstprivate(a) clause is added to the teams construct. The target construct has a map clause, so a on that construct is mapped rather than privatized, which means that each team will have its own privatized copy of= a, and the uninitialized original mapped a is then copied back. Either don't use default(firstprivate) on the combined constructs because y= ou really want sharing for those vars, or you can use !$omp target teams default(firstprivate) map(from:a) shared(a) While OpenMP has a restriction that the same list item can't be specified in mapping and data sharing clauses, my understanding is that this applies aft= er the clauses are distributed among the constituent constructs, and as target construct doesn't allow shared clause and teams construct doesn't allow map clause, each goes to one of them and should do what you want. Adding shared(a, b, c, d) clause to both combined directives in your testca= se fixes it. You can even just add shared(d), though in that case the a, b, c arrays are mapped to the device and then copied from that to each of the te= ams private copies.=