From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120553 invoked by alias); 29 May 2015 16:36:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 120542 invoked by uid 89); 29 May 2015 16:36:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL,BAYES_40,KAM_ASCII_DIVIDERS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 29 May 2015 16:36:55 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57004) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1YyNHB-0007Yq-Fu for gcc-patches@gnu.org; Fri, 29 May 2015 12:36:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyNH6-0002BQ-C1 for gcc-patches@gnu.org; Fri, 29 May 2015 12:36:53 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:50532) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyNH6-0002Ae-6P for gcc-patches@gnu.org; Fri, 29 May 2015 12:36:48 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YyNH5-0006Om-B5 from Bernd_Schmidt@mentor.com ; Fri, 29 May 2015 09:36:47 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Fri, 29 May 2015 17:36:45 +0100 Message-ID: <55689592.6000203@codesourcery.com> Date: Fri, 29 May 2015 17:20:00 -0000 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: CC: Jakub Jelinek Subject: [gomp4] Initialize some extra variables at the entry to an OpenACC offloaded region Content-Type: multipart/mixed; boundary="------------070600080406080803090504" X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 X-SW-Source: 2015-05/txt/msg02805.txt.bz2 --------------070600080406080803090504 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 212 This initializes worker count and worker id variables; these will be used in a followup patch to allocate arrays in gang-local memory to be used for synchronizing threads. Committed to gomp-4_0-branch. Bernd --------------070600080406080803090504 Content-Type: text/x-patch; name="initvars.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="initvars.diff" Content-length: 2677 Index: gcc/ChangeLog.gomp =================================================================== --- gcc/ChangeLog.gomp (revision 223870) +++ gcc/ChangeLog.gomp (working copy) @@ -1,5 +1,10 @@ 2015-05-29 Bernd Schmidt + * omp-low.c (struct omp_context): Add worker_var and worker_count + fields. + (oacc_init_count_vars): New function. + (lower_omp_target): Call it. + * config/nvptx/nvptx.md (UNSPECV_BARSYNC): New constant. (oacc_threadbarrier): New expander. (threadbarrier_insn): New pattern. Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c (revision 223869) +++ gcc/omp-low.c (working copy) @@ -243,6 +243,11 @@ typedef struct omp_context tree ganglocal_ptr; tree ganglocal_size; tree ganglocal_size_host; + + /* For OpenACC offloaded regions, variables holding the worker id and count + of workers. */ + tree worker_var; + tree worker_count; } omp_context; /* A structure holding the elements of: @@ -12300,6 +12305,35 @@ lower_omp_taskreg (gimple_stmt_iterator } } +/* A subroutine of lower_omp_target. Build variables holding the + worker count and index for use inside in ganglocal memory allocations. */ + +static void +oacc_init_count_vars (omp_context *ctx, tree clauses ATTRIBUTE_UNUSED) +{ + tree gettid = builtin_decl_explicit (BUILT_IN_GOACC_TID); + tree getntid = builtin_decl_explicit (BUILT_IN_GOACC_NTID); + tree worker_var, worker_count; + tree u1 = fold_convert (unsigned_type_node, integer_one_node); + tree u0 = fold_convert (unsigned_type_node, integer_zero_node); + if (ctx->gwv_this & MASK_WORKER) + { + worker_var = create_tmp_var (unsigned_type_node, ".worker"); + worker_count = create_tmp_var (unsigned_type_node, ".workercount"); + gimple call1 = gimple_build_call (gettid, 1, u1); + gimple_call_set_lhs (call1, worker_var); + gimple_seq_add_stmt (&ctx->ganglocal_init, call1); + gimple call2 = gimple_build_call (getntid, 1, u1); + gimple_call_set_lhs (call2, worker_count); + gimple_seq_add_stmt (&ctx->ganglocal_init, call2); + } + else + worker_var = u0, worker_count = u1; + + ctx->worker_var = worker_var; + ctx->worker_count = worker_count; +} + /* Lower the GIMPLE_OMP_TARGET in the current statement in GSI_P. CTX holds context information for the directive. */ @@ -12465,6 +12499,9 @@ lower_omp_target (gimple_stmt_iterator * irlist = NULL; orlist = NULL; + if (is_gimple_omp_oacc (stmt)) + oacc_init_count_vars (ctx, clauses); + if (has_reduction) { lower_rec_input_clauses (clauses, &irlist, &orlist, ctx, NULL); --------------070600080406080803090504--