From patchwork Fri May 4 12:32:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 908684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-477230-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mentor.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vPYJb1mQ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40crxn2Lr8z9s3D for ; Fri, 4 May 2018 22:32:27 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=JBpQ966v+eNv7Gm8Wr2I5rFDdvK9DuFG+L431lKCdkgqgBTN9u am1yCxMR/ILalIISbJFyfDCV9/7YEBoVOpdZafnZ0cIxDgXsKSE0bvCPa/kaXgMn 1j982YNd7OO17cAclzxN9NGizHvZ+AI3p/MKy9lskQPQFzPZ/nzWW4RW8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=oKZtlCPd6IXmPS06rwe+k0ww6OU=; b=vPYJb1mQlU6G/Cq9Dt2M Fme3DQr5UWK2PEAX1gvo5q00RRBYVCS7Vh4wmm/O4J3YagcNgcoylLVp1mx43Agb 3A2WgvzhTFKhUBK7hBeBSC87WXBYxX6G5HuU9fSnHUbiHDHNhvjqcDv0I5o26Uvn B/CCcMrUpKST8ewiMRKN8Lk= Received: (qmail 11943 invoked by alias); 4 May 2018 12:32:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 11929 invoked by uid 89); 4 May 2018 12:32:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=Hx-languages-length:1898 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 May 2018 12:32:18 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1fEZsm-0005gk-28 from Tom_deVries@mentor.com for gcc-patches@gcc.gnu.org; Fri, 04 May 2018 05:32:16 -0700 Received: from [172.30.73.40] (137.202.0.87) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Fri, 4 May 2018 13:32:12 +0100 To: GCC Patches From: Tom de Vries Subject: [og7, libgomp, openacc, nvptx, committed] Don't select too many workers Message-ID: <7e59359d-1c02-17be-1bd3-961260861890@mentor.com> Date: Fri, 4 May 2018 14:32:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) Hi, On the og7 branch for Titan V, we run into this error message in testsuite polybench for testcases covariance and lu: ... libgomp: The Nvidia accelerator has insufficient resources to launch 'x$_omp_fn$0' with num_workers = 27 and vector_length = 32; recompile the program with 'num_workers = x and vector_length = y' on that offloaded region or '-fopenacc-dim=-:x:y' where x * y <= 768. ... The problem here is that num_workers is chosen by libgomp, and instead of giving the error, it should reduce the num_workers. Fixed by this patch. Build x86_64 with nvptx accelerator, tested libgomp. Committed to og7 branch. Thanks, - Tom [libgomp, openacc, nvptx] Don't select too many workers 2018-05-04 Tom de Vries PR libgomp/85649 * plugin/plugin-nvptx.c (MIN, MAX): Redefine. (nvptx_exec): Choose num_workers such that device has sufficient resources. --- libgomp/plugin/plugin-nvptx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index 3c00555..e4d87f5 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -189,6 +189,12 @@ cuda_error (CUresult r) return desc; } +/* From gcc/system.h. */ +#undef MIN +#undef MAX +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) + static unsigned int instantiated_devices = 0; static pthread_mutex_t ptx_dev_lock = PTHREAD_MUTEX_INITIALIZER; @@ -802,7 +808,8 @@ nvptx_exec (void (*fn), size_t mapnum, void **hostaddrs, void **devaddrs, { int vectors = dims[GOMP_DIM_VECTOR] > 0 ? dims[GOMP_DIM_VECTOR] : warp_size; - int workers = threads_per_block / vectors; + int workers + = MIN (threads_per_block, targ_fn->max_threads_per_block) / vectors; for (i = 0; i != GOMP_DIM_MAX; i++) if (!dims[i])