From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 299103850848 for ; Thu, 23 Jun 2022 15:48:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 299103850848 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.92,216,1650960000"; d="scan'208";a="77642986" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 23 Jun 2022 07:48:05 -0800 IronPort-SDR: 6998T5sUnL86J6equHdf87eLbd0ovAeiCcH2Ea3AwUsHlIRo2RgEUENv6KYskoVr8gcq5Xbr2k TaW+gkgVAuutVCiYzqXnOuUQkW4R/E9QVBoAwTYcwhWcmww8ikmuYPC+kznVrqCWSkNMOp0DGu DgmnqJ1Avht720E64C8bJPVhux5KmgXdTWZ1ni1a47XhrZcd1FpYt5/OGxk1gK7bCjeq8slccV d5LDA/LaYOF3/7NXKvbd/WC1g3ym6X7l50xqQOF6236kqZTt4BjSPBWzYp7xBpWqFzFlIYFF1O 250= Content-Type: multipart/mixed; boundary="------------nld5hXNdyQiPhatKDMqbzIWg" Message-ID: <13568991-7359-9149-04fa-cde2245f108c@codesourcery.com> Date: Thu, 23 Jun 2022 23:47:59 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Content-Language: en-US From: Chung-Lin Tang Subject: [PATCH, libgomp] Fix chunk_size<1 for dynamic schedule To: gcc-patches , Catherine Moore , Tobias Burnus X-ClientProxiedBy: svr-orw-mbx-14.mgc.mentorg.com (147.34.90.214) To svr-orw-mbx-10.mgc.mentorg.com (147.34.90.210) X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2022 15:48:14 -0000 --------------nld5hXNdyQiPhatKDMqbzIWg Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit Hi Jakub, with the way that chunk_size < 1 is handled for gomp_iter_dynamic_next: (1) chunk_size <= -1: wraps into large unsigned value, seems to work though. (2) chunk_size == 0: infinite loop The (2) behavior is obviously not desired. This patch fixes this by changing the chunk_size initialization in gomp_loop_init to "max(1,chunk_size)" The OMP_SCHEDULE parsing in libgomp/env.c has also been adjusted to reject negative values. Tested without regressions, and a new testcase for the infinite loop behavior added. Okay for trunk? Thanks, Chung-Lin libgomp/ChangeLog: * env.c (parse_schedule): Make negative values invalid for chunk_size. * loop.c (gomp_loop_init): For non-STATIC schedule and chunk_size <= 0, set initialized chunk_size to 1. * testsuite/libgomp.c/loop-28.c: New test. --------------nld5hXNdyQiPhatKDMqbzIWg Content-Type: text/plain; charset="UTF-8"; name="chunk_size.patch" Content-Disposition: attachment; filename="chunk_size.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2xpYmdvbXAvZW52LmMgYi9saWJnb21wL2Vudi5jCmluZGV4IDFjNGVl ODk0NTE1Li5kZmYwNzYxN2UxNSAxMDA2NDQKLS0tIGEvbGliZ29tcC9lbnYuYworKysgYi9s aWJnb21wL2Vudi5jCkBAIC0xODIsNiArMTgyLDggQEAgcGFyc2Vfc2NoZWR1bGUgKHZvaWQp CiAgICAgZ290byBpbnZ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