From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 2AA30396E05C for ; Fri, 13 May 2022 18:22:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2AA30396E05C Received: by mail-wm1-x331.google.com with SMTP id n126-20020a1c2784000000b0038e8af3e788so5189309wmn.1 for ; Fri, 13 May 2022 11:22:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DO+d99d8O1jdVKMtgA1RlzalRZ47EzLBV7rEnWY9d+M=; b=IKw39LEkijBC96p+Mkem1fjwpfFJbbL1dYKTpwhOWoj0qrsLXxexKlOag634pCB8Uv 3CpBNBQOhdTGsPmsgNtJZYo4p9TqE001orYDh0C7BAf9GFT0pr8/j8sSrC7dQr8UsQ1n dlz1nYuwPs8xbU1Uic/Xpq0BocpRX9Ac4NUackZ3yZ20xV1W5+tqQcicxxhwggQ0uyYf ecWaCfOBjMGFrrWKKkLAZLhABMfoKPXm7FvNqC5H8WymnHQx803xihwWn63POMaJ+JvP 4U8TOmhzCfrtAJLdBJLxXQPgWKAE32ley59niKdV/YdYMi90LI8ON0NIlXNnxFdhX9BK OkSQ== X-Gm-Message-State: AOAM5317DZ+6MrZ8XQvQl1yd17MclNyogJSyiauekU+8dF7e/rVka+ky 4ZU021w2xSJHUsmK+QPndH136FXRd99wBbzu6Po= X-Google-Smtp-Source: ABdhPJwH2B30oMcArqf2vjGBRMzdmCUUbiq8PKeTD34RNz/R6apbqtxXeQmhh1tdB0SqDY2hagNUMFhhhLITssqnoKs= X-Received: by 2002:a1c:4c06:0:b0:394:65c4:bd03 with SMTP id z6-20020a1c4c06000000b0039465c4bd03mr5786416wmf.8.1652466172913; Fri, 13 May 2022 11:22:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Mohamed Atef Date: Fri, 13 May 2022 20:22:41 +0200 Message-ID: Subject: Re: libgompd: ADD OMPD support and global ICV functions To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Fri, 13 May 2022 18:22:57 -0000 =D9=81=D9=8A =D8=A7=D9=84=D8=AC=D9=85=D8=B9=D8=A9=D8=8C =D9=A1=D9=A3 =D9=85= =D8=A7=D9=8A=D9=88=D8=8C =D9=A2=D9=A0=D9=A2=D9=A2 =D9=A3:=D9=A1=D9=A4 =D9= =85 Jakub Jelinek =D9=83=D8=AA=D8=A8: > On Tue, May 10, 2022 at 07:40:41AM +0200, Mohamed Atef wrote: > > --- a/libgomp/env.c > > +++ b/libgomp/env.c > > @@ -33,6 +33,7 @@ > > #ifndef LIBGOMP_OFFLOADED_ONLY > > #include "libgomp_f.h" > > #include "oacc-int.h" > > +#include "ompd-support.h" > > #include > > #include > > #include > > @@ -89,6 +90,7 @@ void **gomp_places_list; > > unsigned long gomp_places_list_len; > > uintptr_t gomp_def_allocator =3D omp_default_mem_alloc; > > int gomp_debug_var; > > +bool gompd_enabled; > > unsigned int gomp_num_teams_var; > > int gomp_nteams_var; > > int gomp_teams_thread_limit_var; > > @@ -418,6 +420,33 @@ parse_target_offload (const char *name, enum > gomp_target_offload_t *offload) > > gomp_error ("Invalid value for environment variable > OMP_TARGET_OFFLOAD"); > > } > > > > +/* Parse OMPD_DEBUG environment variable. */ > > s/OMPD_/OMP_/ > > > + > > +static void > > +parse_debug (const char *name, bool *debug_value) > > +{ > > + const char *env; > > + bool ret =3D false; > > + env =3D getenv (name); > > + if (env =3D=3D NULL) > > + return; > > + while (isspace ((unsigned char) *env)) > > + ++env; > > + if (strncasecmp (env, "enabled", 7) =3D=3D 0) > > + { > > + env +=3D 7; > > + ret =3D true; > > + } > > disabled is a valid OMP_DEBUG value, so it needs to be supported too. > > > + while (isspace ((unsigned char) *env)) > > + ++env; > > + if (ret && *env =3D=3D '\0') > > + { > > + *debug_value =3D ret; > > + return; > > + } > > + gomp_error ("Invalid value for environment variable OMP_DEBUG"); > > +} > > + > > /* Parse environment variable set to a boolean or list of > omp_proc_bind_t > > enum values. Return true if one was present and it was successfull= y > > parsed. */ > > @@ -1483,6 +1512,9 @@ initialize_env (void) > > =3D thread_limit_var > INT_MAX ? UINT_MAX : thread_limit_var; > > } > > parse_int_secure ("GOMP_DEBUG", &gomp_debug_var, true); > > + parse_debug ("OMP_DEBUG", &gompd_enabled); > > + if (gompd_enabled) > > + gompd_load (); > > #ifndef HAVE_SYNC_BUILTINS > > gomp_mutex_init (&gomp_managed_threads_lock); > > #endif > > diff --git a/libgomp/libgomp.map b/libgomp/libgomp.map > > index 2ac58094169..46feba394f5 100644 > > --- a/libgomp/libgomp.map > > +++ b/libgomp/libgomp.map > > @@ -13,7 +13,7 @@ OMP_1.0 { > > #ifdef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT > > # If the assembler used lacks the .symver directive or the > linker > > # doesn't support GNU symbol versioning, we have the same symbol = in > > - # two versions, which Sun ld chokes on. > > + # two versions, which Sun ld chokes on. > > omp_init_lock; > > omp_init_nest_lock; > > omp_destroy_lock; > > @@ -226,6 +226,14 @@ OMP_5.1 { > > omp_get_teams_thread_limit_; > > } OMP_5.0.2; > > > > +OMP_5.0.3 { > > + global: > > + ompd_dll_locations; > > + ompd_dll_locations_valid; > > + ompd_bp_parallel_begin; > > + ompd_bp_parallel_end; > > +} OMP_5.0.2; > > + > > This should use OMP_5.1 rather than OMP_5.0.2. > > > GOMP_1.0 { > > global: > > GOMP_atomic_end; > > diff --git a/libgomp/libgompd.map b/libgomp/libgompd.map > > new file mode 100644 > > index 00000000000..fc1b219cdde > > --- /dev/null > > +++ b/libgomp/libgompd.map > > @@ -0,0 +1,21 @@ > > +OMPD_5.1 { > > + global: > > + ompd_initialize; > > + ompd_get_api_version; > > + ompd_get_version_string; > > + ompd_process_initialize; > > + ompd_device_initialize; > > + ompd_rel_address_space_handle; > > + ompd_finalize; > > + ompd_enumerate_icvs; > > + ompd_get_icv_from_scope; > > + ompd_get_icv_string_from_scope; > > + ompd_get_thread_handle; > > + ompd_get_thread_in_parallel; > > + ompd_rel_thread_handle; > > + ompd_thread_handle_compare; > > + ompd_get_thread_id; > > + ompd_get_device_from_thread; > > + ompd_bp_thread_begin; > > + ompd_bp_thread_end; > > local: > *; > is missing here. > > > +}; > > + > > +#ifdef __ELF__ > > +#define ompd_dll_locations_valid() \ > > + __asm__ __volatile__ (".globl ompd_dll_locations_valid\n\t" \ > > + "ompd_dll_locations_valid:") > > +#else > > +extern void ompd_dll_locations_valid (void) __GOMPD_NOTHROW; > > +#endif /* __ELF__ */ > > As I've tried to explain, this #ifdef __ELF__ doesn't belong > to the public header, which should contain just > extern void ompd_dll_locations_valid (void) __GOMPD_NOTHROW; > The #define should be in some internal header that is included > after the public one. > I will put the #define in ompd-support.h is that okay? And i will put ompd_bp_* labels there too. > > > +#ifdef __ELF__ > > +#define ompd_bp_parallel_begin() \ > > + __asm__ __volatile__ (".globl ompd_bp_parallel_begin\n\t" \ > > + "ompd_bp_parallel_begin:") > > +#define ompd_bp_parallel_end() \ > > + __asm__ __volatile__ (".globl ompd_bp_parallel_end\n\t" \ > > + "ompd_bp_parallel_end:") > > +#define ompd_bp_task_begin() \ > > + __asm__ __volatile__ (".globl ompd_bp_task_begin\n\t" \ > > + "ompd_bp_task_begin:") > > +#define ompd_bp_task_end() \ > > + __asm__ __volatile__ (".globl ompd_bp_task_end\n\t" \ > > + "ompd_bp_task_end:") > > +#define ompd_bp_thread_begin() \ > > + __asm__ __volatile__ (".globl ompd_bp_thread_begin\n\t" \ > > + "ompd_bp_thread_begin:") > > +#define ompd_bp_thread_end() \ > > + __asm__ __volatile__ (".globl ompd_bp_thread_end\n\t" \ > > + "ompd_bp_thread_end:") > > +#define ompd_bp_device_begin() \ > > + __asm__ __volatile__ (".globl ompd_bp_device_begin\n\t" \ > > + "ompd_bp_device_end:") > > +#define ompd_bp_device_end() \ > > + __asm__ __volatile__ (".globl ompd_bp_device_end\n\t" \ > > + "ompd_bp_device_end:") > > +#else > > Similarly here. > > > +extern void ompd_bp_parallel_begin (void) __GOMPD_NOTHROW; > > +extern void ompd_bp_parallel_end (void) __GOMPD_NOTHROW; > > + > > +extern void ompd_bp_task_begin (void) __GOMPD_NOTHROW; > > +extern void ompd_bp_task_end (void) __GOMPD_NOTHROW; > > + > > +extern void ompd_bp_thread_begin (void) __GOMPD_NOTHROW; > > +extern void ompd_bp_thread_end (void) __GOMPD_NOTHROW; > > + > > +extern void ompd_bp_device_begin (void) __GOMPD_NOTHROW; > > +extern void ompd_bp_device_end (void) __GOMPD_NOTHROW; > > +#endif /* __ELF__ */ > > > @@ -74,7 +75,7 @@ gomp_thread_start (void *xdata) > > struct gomp_thread_pool *pool; > > void (*local_fn) (void *); > > void *local_data; > > - > > + ompd_bp_thread_begin (); > > Please keep the vertical space after the var declarations. > > > #if defined HAVE_TLS || defined USE_EMUTLS > > thr =3D &gomp_tls_data; > > #else > > @@ -321,6 +322,7 @@ gomp_team_start (void (*fn) (void *), void *data, > unsigned nthreads, > > unsigned flags, struct gomp_team *team, > > struct gomp_taskgroup *taskgroup) > > { > > + ompd_bp_parallel_begin (); > > struct gomp_thread_start_data *start_data =3D NULL; > > struct gomp_thread *thr, *nthr; > > struct gomp_task *task; > > Please put ompd_bp_* after the var declarations + vertical space, > unless there are already function calls (very cheap inline > calls like gomp_thread () don't count). > > > @@ -1011,6 +1013,7 @@ gomp_team_end (void) > > pool->last_team =3D team; > > gomp_release_thread_pool (pool); > > } > > + ompd_bp_parallel_end (); > > } > > > > #ifdef LIBGOMP_USE_PTHREADS > > > Jakub > >