On Wed, Mar 08, 2023 at 04:21:46PM +0800, Hongyu Wang wrote:
> Hongyu Wang <wwwhhhyyy...@gmail.com> 于2023年3月8日周三 16:07写道:
> >
> > > I think the right spot to fix this would be instead in initialize_icvs,
> > > change the
> > >   icvs->wait_policy = 0;
> > > in there to
> > >   icvs->wait_policy = -1;
> > > That way it will be the default for all the devices, not just the
> > > initial one.
> >
> > It doesn't work, for the code that determines value of wait_policy:
> >
> > if (none != NULL && gomp_get_icv_flag (none->flags, GOMP_ICV_WAIT_POLICY))
> >   wait_policy = none->icvs.wait_policy;
> > else if (all != NULL && gomp_get_icv_flag (all->flags, 
> > GOMP_ICV_WAIT_POLICY))
> >   wait_policy = all->icvs.wait_policy;
> >
> > gomp_get_icv_flag (none->flags, GOMP_ICV_WAIT_POLICY) returns true only when
> > OMP_WAIT_POLICY is explicitly set, so the initial icvs->wait_policy
> > could not affect the global wait_policy that used to set
> > GOMP_SPINCOUNT.
> 
> Also the global variable wait_policy here is only used for setting
> spin_count related values that do not
> belong to any ICV, so there is no need to set icvs->wait_policy since
> for OMP_WAIT_POLICY_(DEV|ALL)
> itself only has value 0 for passive and value 1 for active.

Seems for many ICVs the default values are done through
gomp_default_icv_values, but that doesn't cover wait_policy.
For other vars, the defaults are provided through just initializers of
those vars on the var definitions, e.g.:
char *gomp_affinity_format_var = "level %L thread %i affinity %A";
So, I'd do the initialize_icvs change and change
static int wait_policy;
to
static int wait_policy = -1;

        Jakub

Reply via email to