From patchwork Tue Sep 10 17:41:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1160507 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-508788-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Y4dpm+kM"; 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 46SXRq25y9z9s7T for ; Wed, 11 Sep 2019 03:42:47 +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:from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; q=dns; s=default; b=sSu V1mY/KNK7vLrFcnjjGL65BLB345Srsd8y8Oi8cRAJ13IAhYrotfrdkASbdpmuDNF SUwMC9xkPgIs27hbMIDpbCa9KxuGilWxCg/VMI5jwzqz49jr/mczL0+jdsFyIdsh S+F0AIyiR6UNwmr6zRgvPoa1lTYKdLTqu8LhR3lo= 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:from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=default; bh=vKhbs2veJ V0wBt+sCZI2M9wbHHM=; b=Y4dpm+kMwdu/v2CAyl3mJOM+Ft1hNsZlnhW5eG6eL Ggpi+n/vuh9BHyYUPbvwkl71drKYztMjyTeb4DmOzV7SOmLWLxSNlYXsP4cKzUjT UkqtXks2/0XVVYMwV7VbAqjlZD8AsJh3YG6kgfuVuavdK728uQFSFIKbmDHnnOk8 Jc= Received: (qmail 87685 invoked by alias); 10 Sep 2019 17:42:19 -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 87618 invoked by uid 89); 10 Sep 2019 17:42:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=leftover X-HELO: esa2.mentor.iphmx.com Received: from esa2.mentor.iphmx.com (HELO esa2.mentor.iphmx.com) (68.232.141.98) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Sep 2019 17:42:15 +0000 IronPort-SDR: tMZ4qEma/oVTru/IdH+JcekXi5dc3deR5/CnNHbcxOpymAS2HzXERSC1YgEjPhV6rc7LGjCOjH U2EoTARCLNLZ45kQalWKA6Po+VFjE6ywp+JEoEgS3UiR1GBUogr/cU4TADmyIMQfd3PEaDE4H3 ktvS5GWhxw73DWzKRaJrA02VJGkRwXPKzbZ8YlMlgSt2Qy+9TYwe36/M3QsRYp36+w9c1pNVSq S8mSJHHdCrqGt+VfVpeqC6boudQlzjL55zYpMeauPBUgdStIULJqSNxlbAw+Drzb0W1BpfW+Vm TB4= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 10 Sep 2019 09:42:05 -0800 IronPort-SDR: IEHWNGq+1U1uHAww6MbW7xMyb6si6ZmP1CD3jwX7gEodIrWUbXhoowFu+HVnDHfccRMMxu3mdC IrP+dZILSgB0V4ILVvG+5SiF9yM0rBGsHONxz9r7sYZFzPikZTCZiVWsLguPPtGeZ3K3zelPW5 JmgQ/C9b6aSVT27vcS9+tmCLU1PdzueDgrBf7arsAZUbP5bvFdSZXxlMjGt+dpsiT7pIy+l5i3 r74LSnDJjGBQZ/hppM6s1cE4DCodhsSaWmchy7yK813/AhVgSplc6DQyLMqb1HJxtRX6OIHnpM qQg= From: Julian Brown To: CC: Andrew Stubbs Subject: [PATCH] [og9] Clean up dead/write-only fields in GCN libgomp plugin Date: Tue, 10 Sep 2019 10:41:43 -0700 Message-ID: <20190910174143.46888-3-julian@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch cleans up some struct fields that are unused in the GCN plugin (leftover from the HSA plugin) that I noticed when working on debugging other problems. Tested with offloading to AMD GCN. I will apply to the openacc-gcc-9-branch shortly. Thanks, Julian ChangeLog gcc/ * config/gcn/mkoffload.c (process_asm): Remove omp_data_size, gridified_kernel_p, kernel_dependencies_count, kernel_dependencies from emitted hsa_kernel_description struct array. libgomp/ * plugin/plugin-gcn.c (GOMP_hsa_kernel_dispatch): Remove omp_data_memory, kernel_dispatch_count, debug, omp_level, children_dispatches and omp_num_threads fields. (hsa_kernel_description): Remove omp_data_size, gridified_kernel_p, kernel_dependencies_count, kernel_dependencies fields to match mkoffload output. (kernel_info): Remove omp_data_size, dependencies, dependencies_count, max_omp_data_size and gridified_kernel_p fields. (init_basic_kernel_info): Don't copy newly-deleted fields. (create_single_kernel_dispatch): Remove omp_data_size parameter. Remove write-only initialization of deleted GOMP_hsa_kernel_dispatch fields. (release_kernel_dispatch): Update debug output. Don't free deleted omp_data_memory field. (init_single_kernel): Remove max_omp_data_size parameter. Remove deleted fields from debug output. (print_kernel_dispatch): Don't print deleted fields. (create_kernel_dispatch): Remove omp_data_size parameter. (init_kernel): Update calls to init_single_kernel and create_kernel_dispatch. --- gcc/ChangeLog.openacc | 6 +++ gcc/config/gcn/mkoffload.c | 6 +-- libgomp/ChangeLog.openacc | 23 ++++++++++++ libgomp/plugin/plugin-gcn.c | 74 ++++--------------------------------- 4 files changed, 37 insertions(+), 72 deletions(-) diff --git a/gcc/ChangeLog.openacc b/gcc/ChangeLog.openacc index 7a3cc7f5491..8f3aee75449 100644 --- a/gcc/ChangeLog.openacc +++ b/gcc/ChangeLog.openacc @@ -1,3 +1,9 @@ +2019-09-10 Julian Brown + + * config/gcn/mkoffload.c (process_asm): Remove omp_data_size, + gridified_kernel_p, kernel_dependencies_count, kernel_dependencies + from emitted hsa_kernel_description struct array. + 2019-09-10 Andrew Stubbs * config/gcn/gcn.c (gcn_hsa_declare_function_name): Calculate diff --git a/gcc/config/gcn/mkoffload.c b/gcc/config/gcn/mkoffload.c index f26b9023969..593274bf054 100644 --- a/gcc/config/gcn/mkoffload.c +++ b/gcc/config/gcn/mkoffload.c @@ -332,10 +332,6 @@ process_asm (FILE *in, FILE *out, FILE *cfile) /* Dump out function idents. */ fprintf (cfile, "static const struct hsa_kernel_description {\n" " const char *name;\n" - " unsigned omp_data_size;\n" - " bool gridified_kernel_p;\n" - " unsigned kernel_dependencies_count;\n" - " const char **kernel_dependencies;\n" " int oacc_dims[3];\n" "} gcn_kernels[] = {\n "); dim.d[0] = dim.d[1] = dim.d[2] = 0; @@ -351,7 +347,7 @@ process_asm (FILE *in, FILE *out, FILE *cfile) break; } - fprintf (cfile, "%s{\"%s\", 0, 0, 0, NULL, {%d, %d, %d}}", comma, + fprintf (cfile, "%s{\"%s\", {%d, %d, %d}}", comma, fns[i], d[0], d[1], d[2]); free (fns[i]); diff --git a/libgomp/ChangeLog.openacc b/libgomp/ChangeLog.openacc index ac9780f8c10..355e406d4e3 100644 --- a/libgomp/ChangeLog.openacc +++ b/libgomp/ChangeLog.openacc @@ -1,3 +1,26 @@ +2019-09-10 Julian Brown + + * plugin/plugin-gcn.c (GOMP_hsa_kernel_dispatch): Remove + omp_data_memory, kernel_dispatch_count, debug, omp_level, + children_dispatches and omp_num_threads fields. + (hsa_kernel_description): Remove omp_data_size, gridified_kernel_p, + kernel_dependencies_count, kernel_dependencies fields to match + mkoffload output. + (kernel_info): Remove omp_data_size, dependencies, dependencies_count, + max_omp_data_size and gridified_kernel_p fields. + (init_basic_kernel_info): Don't copy newly-deleted fields. + (create_single_kernel_dispatch): Remove omp_data_size parameter. + Remove write-only initialization of deleted GOMP_hsa_kernel_dispatch + fields. + (release_kernel_dispatch): Update debug output. Don't free deleted + omp_data_memory field. + (init_single_kernel): Remove max_omp_data_size parameter. Remove deleted + fields from debug output. + (print_kernel_dispatch): Don't print deleted fields. + (create_kernel_dispatch): Remove omp_data_size parameter. + (init_kernel): Update calls to init_single_kernel and + create_kernel_dispatch. + 2019-09-10 Julian Brown * plugin/plugin-gcn.c (struct placeholder, struct asyncwait_info, diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c index b23a6be69bf..f7e3554f297 100644 --- a/libgomp/plugin/plugin-gcn.c +++ b/libgomp/plugin/plugin-gcn.c @@ -213,8 +213,6 @@ struct GOMP_hsa_kernel_dispatch { /* Pointer to a command queue associated with a kernel dispatch agent. */ void *queue; - /* Pointer to reserved memory for OMP data struct copying. */ - void *omp_data_memory; /* Pointer to a memory space used for kernel arguments passing. */ void *kernarg_address; /* Kernel object. */ @@ -225,16 +223,6 @@ struct GOMP_hsa_kernel_dispatch uint32_t private_segment_size; /* Group segment size. */ uint32_t group_segment_size; - /* Number of children kernel dispatches. */ - uint64_t kernel_dispatch_count; - /* Debug purpose argument. */ - uint64_t debug; - /* Levels-var ICV. */ - uint64_t omp_level; - /* Kernel dispatch structures created for children kernel dispatches. */ - struct GOMP_hsa_kernel_dispatch **children_dispatches; - /* Number of threads. */ - uint32_t omp_num_threads; }; /* Structure of the default kernargs segment, supporting gomp_print_*. @@ -536,10 +524,6 @@ hsa_error (const char *str, hsa_status_t status) struct hsa_kernel_description { const char *name; - unsigned omp_data_size; - bool gridified_kernel_p; - unsigned kernel_dependencies_count; - const char **kernel_dependencies; int oacc_dims[3]; /* Only present for GCN kernels. */ }; @@ -576,8 +560,6 @@ struct kernel_info /* Name of the kernel, required to locate it within the GCN object-code module. */ const char *name; - /* Size of memory space for OMP data. */ - unsigned omp_data_size; /* The specific agent the kernel has been or will be finalized for and run on. */ struct agent_info *agent; @@ -600,14 +582,6 @@ struct kernel_info uint32_t group_segment_size; /* Required size of private segment. */ uint32_t private_segment_size; - /* List of all kernel dependencies. */ - const char **dependencies; - /* Number of dependencies. */ - unsigned dependencies_count; - /* Maximum OMP data size necessary for kernel from kernel dispatches. */ - unsigned max_omp_data_size; - /* True if the kernel is gridified. */ - bool gridified_kernel_p; }; /* Information about a particular GCN module, its image and kernels. */ @@ -1866,10 +1840,6 @@ init_basic_kernel_info (struct kernel_info *kernel, kernel->agent = agent; kernel->module = module; kernel->name = d->name; - kernel->omp_data_size = d->omp_data_size; - kernel->gridified_kernel_p = d->gridified_kernel_p; - kernel->dependencies_count = d->kernel_dependencies_count; - kernel->dependencies = d->kernel_dependencies; if (pthread_mutex_init (&kernel->init_mutex, NULL)) { GOMP_PLUGIN_error ("Failed to initialize a GCN kernel mutex"); @@ -2316,20 +2286,12 @@ fail: /* Create kernel dispatch data structure for given KERNEL. */ static struct GOMP_hsa_kernel_dispatch * -create_single_kernel_dispatch (struct kernel_info *kernel, - unsigned omp_data_size) +create_single_kernel_dispatch (struct kernel_info *kernel) { struct agent_info *agent = kernel->agent; struct GOMP_hsa_kernel_dispatch *shadow = GOMP_PLUGIN_malloc_cleared (sizeof (struct GOMP_hsa_kernel_dispatch)); - shadow->omp_data_memory - = omp_data_size > 0 ? GOMP_PLUGIN_malloc (omp_data_size) : NULL; - unsigned dispatch_count = kernel->dependencies_count; - if (dispatch_count != 0) - GOMP_PLUGIN_fatal ("kernel->dependencies_count != 0"); - shadow->kernel_dispatch_count = 0; - shadow->object = kernel->object; hsa_signal_t sync_signal; @@ -2436,8 +2398,7 @@ gomp_print_output (struct kernel_info *kernel, struct kernargs *kernargs, static void release_kernel_dispatch (struct GOMP_hsa_kernel_dispatch *shadow) { - HSA_DEBUG ("Released kernel dispatch: %p has value: %lu (%p)\n", shadow, - shadow->debug, (void *) shadow->debug); + HSA_DEBUG ("Released kernel dispatch: %p\n", shadow); hsa_fns.hsa_memory_free_fn (shadow->kernarg_address); @@ -2445,8 +2406,6 @@ release_kernel_dispatch (struct GOMP_hsa_kernel_dispatch *shadow) s.handle = shadow->signal; hsa_fns.hsa_signal_destroy_fn (s); - free (shadow->omp_data_memory); - free (shadow); } @@ -2454,7 +2413,7 @@ release_kernel_dispatch (struct GOMP_hsa_kernel_dispatch *shadow) to calculate maximum necessary memory for OMP data allocation. */ static void -init_single_kernel (struct kernel_info *kernel, unsigned *max_omp_data_size) +init_single_kernel (struct kernel_info *kernel) { hsa_status_t status; struct agent_info *agent = kernel->agent; @@ -2499,12 +2458,6 @@ init_single_kernel (struct kernel_info *kernel, unsigned *max_omp_data_size) (unsigned) kernel->private_segment_size); HSA_DEBUG (" kernarg_segment_size: %u\n", (unsigned) kernel->kernarg_segment_size); - HSA_DEBUG (" omp_data_size: %u\n", kernel->omp_data_size); - HSA_DEBUG (" gridified_kernel_p: %u\n", kernel->gridified_kernel_p); - - if (kernel->omp_data_size > *max_omp_data_size) - *max_omp_data_size = kernel->omp_data_size; - return; failure: @@ -2530,25 +2483,16 @@ print_kernel_dispatch (struct GOMP_hsa_kernel_dispatch *dispatch, indent_stream (stderr, indent); fprintf (stderr, "queue: %p\n", dispatch->queue); indent_stream (stderr, indent); - fprintf (stderr, "omp_data_memory: %p\n", dispatch->omp_data_memory); - indent_stream (stderr, indent); fprintf (stderr, "kernarg_address: %p\n", dispatch->kernarg_address); indent_stream (stderr, indent); fprintf (stderr, "object: %lu\n", dispatch->object); indent_stream (stderr, indent); - fprintf (stderr, "signal: %lu\n", dispatch->signal); - indent_stream (stderr, indent); fprintf (stderr, "private_segment_size: %u\n", dispatch->private_segment_size); indent_stream (stderr, indent); fprintf (stderr, "group_segment_size: %u\n", dispatch->group_segment_size); indent_stream (stderr, indent); - fprintf (stderr, "children dispatches: %lu\n", - dispatch->kernel_dispatch_count); - indent_stream (stderr, indent); - fprintf (stderr, "omp_num_threads: %u\n", - dispatch->omp_num_threads); fprintf (stderr, "\n"); } @@ -2556,13 +2500,10 @@ print_kernel_dispatch (struct GOMP_hsa_kernel_dispatch *dispatch, dependencies. */ static struct GOMP_hsa_kernel_dispatch * -create_kernel_dispatch (struct kernel_info *kernel, unsigned omp_data_size) +create_kernel_dispatch (struct kernel_info *kernel) { struct GOMP_hsa_kernel_dispatch *shadow - = create_single_kernel_dispatch (kernel, omp_data_size); - shadow->omp_num_threads = 64; - shadow->debug = 0; - shadow->omp_level = kernel->gridified_kernel_p ? 1 : 0; + = create_single_kernel_dispatch (kernel); return shadow; } @@ -2587,7 +2528,7 @@ init_kernel (struct kernel_info *kernel) /* Precomputed maximum size of OMP data necessary for a kernel from kernel dispatch operation. */ - init_single_kernel (kernel, &kernel->max_omp_data_size); + init_single_kernel (kernel); if (!kernel->initialization_failed) { @@ -2831,8 +2772,7 @@ run_kernel (struct kernel_info *kernel, void *vars, if (!kernel->initialized) GOMP_PLUGIN_fatal ("Called kernel must be initialized"); - struct GOMP_hsa_kernel_dispatch *shadow - = create_kernel_dispatch (kernel, kernel->max_omp_data_size); + struct GOMP_hsa_kernel_dispatch *shadow = create_kernel_dispatch (kernel); hsa_queue_t *command_q = (aq ? aq->hsa_queue : kernel->agent->sync_queue); shadow->queue = command_q;