From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47187 invoked by alias); 3 Jun 2019 18:21:19 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 47178 invoked by uid 89); 3 Jun 2019 18:21:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL,BAYES_00,BODY_8BITS,GARBLED_BODY,SPF_HELO_PASS autolearn=no version=3.3.1 spammy=enter, GOMP_task, studying, gomp_task X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Jun 2019 18:21:18 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A48AF19CF89; Mon, 3 Jun 2019 18:21:08 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C13961B7F; Mon, 3 Jun 2019 18:21:07 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x53IL4JY022078; Mon, 3 Jun 2019 20:21:05 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x53IL1UB022077; Mon, 3 Jun 2019 20:21:01 +0200 Date: Mon, 03 Jun 2019 18:21:00 -0000 From: Jakub Jelinek To: =?utf-8?B?6rmA6rec656Y?= Cc: gcc@gcc.gnu.org Subject: Re: [GSoC'19, libgomp work-stealing] Task parallelism runtime Message-ID: <20190603182101.GS19695@tucnak> Reply-To: Jakub Jelinek References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-IsSubscribed: yes X-SW-Source: 2019-06/txt/msg00009.txt.bz2 On Tue, Jun 04, 2019 at 03:01:13AM +0900, 김규래 wrote: > Hi, > I've been studying the libgomp task parallelism system. > I have a few questions. > First, Tracing the events shows that only the main thread calls GOMP_task. No, any thread can call GOMP_task, in particular the thread that encountered the #pragma omp task construct. The GOMP_task function then decides based on the clauses of the construct (passed in various ways through the arguments of that function) whether it will be included (executed by the encountering thread), or queued for later execution. In the latter case, it will be scheduled during a barrier (implicit or explicit), see gomp_barrier_handle_tasks called from the bar.[ch] code, or at other spots, e.g. during taskwait construct (GOMP_taskwait) or at the end of taskgroup (GOMP_taskgroup_end). > How do the other worker threads enter the libgomp runtime? If you never encounter a parallel, teams or target construct, then there is just one thread that does everything (well, the library is written such that if you by hand pthread_create, each such thread acts as a separate initial thread from OpenMP POV). Threads are created e.g. during parallel construct (GOMP_parallel), where for non-nested parallelism as the standard requires it reuses existing threads if possible or spawns new ones, see mainly team.c (gomp_team_start) for the function that spawns new threads or awakes the ones waiting for work, or gomp_thread_start in the same file for the function actually run by the libgomp library created threads. > I can't find the entry point of the worker threads from the event tracing and the assembly dump. > Second, How is the task priority set? By the user, through priority clause, passed to GOMP_task and then taken into account when handling tasks in the various queues. Jakub