FWD: Re: OpenACC subarray specifications in the GCC Fortran front end

Cesar Philippidis cesar@codesourcery.com
Thu Jul 24 22:44:00 GMT 2014


On 07/24/2014 06:11 AM, Thomas Schwinge wrote:

> OMP_LIST_DEVICEPTR remains to be converted, which can be done as a later
> follow-up patch.

Yes, that's the plan.

> I'd suggest to continue to handle all the data clauses...
> 
>>  
>>  /* Match OpenMP and OpenACC directive clauses. MASK is a bitmask of
>>     clauses that are allowed for a particular directive.  */
>>  
>>  static match
>>  gfc_match_omp_clauses (gfc_omp_clauses **cp, unsigned long long mask,
>> -		       bool first = true, bool needs_space = true)
>> +		       bool first = true, bool needs_space = true,
>> +		       bool openacc = false)
>>  {
>>    gfc_omp_clauses *c = gfc_get_omp_clauses ();
>>    locus old_loc;
>> @@ -533,181 +692,109 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, unsigned long long mask,
>>        if ((mask & OMP_CLAUSE_NUM_THREADS) && c->num_threads == NULL
>>  	  && gfc_match ("num_threads ( %e )", &c->num_threads) == MATCH_YES)
>>  	continue;
>> +      if ((mask & OMP_CLAUSE_NUM_GANGS) && c->num_gangs_expr == NULL
>> +	  && gfc_match ("num_gangs ( %e )", &c->num_gangs_expr) == MATCH_YES)
>> +	continue;
>> +      if ((mask & OMP_CLAUSE_NUM_WORKERS) && c->num_workers_expr == NULL
>> +	  && gfc_match ("num_workers ( %e )", &c->num_workers_expr)
>> +	  == MATCH_YES)
>> +	continue;
>> +      if ((mask & OMP_CLAUSE_TILE)
>> +	  && match_oacc_expr_list ("tile (", &c->tile_list, true) == MATCH_YES)
>> +	continue;
>> +      if ((mask & OMP_CLAUSE_SEQ) && !c->seq
>> +	  && gfc_match ("seq") == MATCH_YES)
>> +	{
>> +	  c->seq = true;
>> +	  needs_space = true;
>> +	  continue;
>> +	}
>> +      if ((mask & OMP_CLAUSE_INDEPENDENT) && !c->independent
>> +	  && gfc_match ("independent") == MATCH_YES)
>> +	{
>> +	  c->independent = true;
>> +	  needs_space = true;
>> +	  continue;
>> +	}
>> +      if ((mask & OMP_CLAUSE_AUTO) && !c->par_auto
>> +	        && gfc_match ("auto") == MATCH_YES)
>> +	{
>> +	  c->par_auto = true;
>> +	  needs_space = true;
>> +	  continue;
>> +	}
>> +      if ((mask & OMP_CLAUSE_WAIT) && !c->wait
>> +	        && gfc_match ("wait") == MATCH_YES)
>> +	{
>> +	  c->wait = true;
>> +	  match_oacc_expr_list (" (", &c->wait_list, false);
>> +	  continue;
>> +	}
>> +      /* Common, in the sense that no special handling is required,
>> +	 OpenACC and OpenMP data clauses.  */
>>        if ((mask & OMP_CLAUSE_PRIVATE)
>>  	  && gfc_match_omp_variable_list ("private (",
>>  					  &c->lists[OMP_LIST_PRIVATE], true)
>> -	     == MATCH_YES)
>> +	  == MATCH_YES)
>>  	continue;
>>        if ((mask & OMP_CLAUSE_FIRSTPRIVATE)
>>  	  && gfc_match_omp_variable_list ("firstprivate (",
>>  					  &c->lists[OMP_LIST_FIRSTPRIVATE],
>>  					  true)
>> -	     == MATCH_YES)
>> +	  == MATCH_YES)
>>  	continue;
>>        if ((mask & OMP_CLAUSE_LASTPRIVATE)
>>  	  && gfc_match_omp_variable_list ("lastprivate (",
>>  					  &c->lists[OMP_LIST_LASTPRIVATE],
>>  					  true)
>> -	     == MATCH_YES)
>> +	  == MATCH_YES)
>>  	continue;
>>        if ((mask & OMP_CLAUSE_COPYPRIVATE)
>>  	  && gfc_match_omp_variable_list ("copyprivate (",
>>  					  &c->lists[OMP_LIST_COPYPRIVATE],
>>  					  true)
>> -	     == MATCH_YES)
>> +	  == MATCH_YES)
>>  	continue;
>>        if ((mask & OMP_CLAUSE_SHARED)
>>  	  && gfc_match_omp_variable_list ("shared (",
>>  					  &c->lists[OMP_LIST_SHARED], true)
>> -	     == MATCH_YES)
>> -	continue;
>> -      if ((mask & OMP_CLAUSE_COPYIN)
>> -	  && gfc_match_omp_variable_list ("copyin (",
>> -					  &c->lists[OMP_LIST_COPYIN], true)
>> -	     == MATCH_YES)
>> -	continue;
>> -      if ((mask & OMP_CLAUSE_NUM_GANGS) && c->num_gangs_expr == NULL
>> -	  && gfc_match ("num_gangs ( %e )", &c->num_gangs_expr) == MATCH_YES)
>> -	continue;
>> -      if ((mask & OMP_CLAUSE_NUM_WORKERS) && c->num_workers_expr == NULL
>> -	  && gfc_match ("num_workers ( %e )", &c->num_workers_expr)
>>  	  == MATCH_YES)
>>  	continue;
>> -      if ((mask & OMP_CLAUSE_COPY)
>> -	  && gfc_match_omp_variable_list ("copy (",
>> -					  &c->lists[OMP_LIST_COPY], true)
>> -	     == MATCH_YES)
>> -	continue;
>> -      if ((mask & OMP_CLAUSE_OACC_COPYIN)
>> -	  && gfc_match_omp_variable_list ("copyin (",
>> -					  &c->lists[OMP_LIST_OACC_COPYIN], true)
>> -	     == MATCH_YES)
>> -	continue;
>> -      if ((mask & OMP_CLAUSE_COPYOUT)
>> -	  && gfc_match_omp_variable_list ("copyout (",
>> -					  &c->lists[OMP_LIST_COPYOUT], true)
>> -	     == MATCH_YES)
>> -	continue;
>> -[...]
> 
> ... in here, and either guard them by »if (openacc)« as apppropriate, or
> continue using the OMP_CLAUSE_OACC_COPYIN (which you axed).  (I
> understand that one to be the only conflicting one?)

I moved all of the data clause matching back to gfc_match_omp_clauses,
and I guarded the copyin clause with the openacc flag. It looks like the
private clause may also require a special memory mapping, so I left the
openacc flag in place.

>>  static void
>>  resolve_omp_clauses (gfc_code *code, locus *where,
>> -		     gfc_omp_clauses *omp_clauses, gfc_namespace *ns)
>> +		     gfc_omp_clauses *omp_clauses, gfc_namespace *ns,
>> +		     bool openacc = false)
>>  {
>>    gfc_omp_namelist *n;
>>    gfc_expr_list *el;
>> @@ -2794,7 +2893,7 @@ resolve_omp_clauses (gfc_code *code, locus *where,
>>  	&& list != OMP_LIST_LASTPRIVATE
>>  	&& list != OMP_LIST_ALIGNED
>>  	&& list != OMP_LIST_DEPEND
>> -	&& list != OMP_LIST_MAP
>> +	&& (list != OMP_LIST_MAP || openacc)
>>  	&& list != OMP_LIST_FROM
>>  	&& list != OMP_LIST_TO)
>>        for (n = omp_clauses->lists[list]; n; n = n->next)
>> @@ -2941,53 +3040,59 @@ resolve_omp_clauses (gfc_code *code, locus *where,
>>  	  case OMP_LIST_TO:
>>  	  case OMP_LIST_FROM:
>>  	    for (; n != NULL; n = n->next)
>> +	      {
>>  [...]
>> +		else if (openacc)
>> +		  resolve_oacc_data_clauses (n->sym, *where,
>> +					     clause_names[list]);
>> +	      }
> 
> Is that special case only for deviceptr?

I haven't looked at it in detail yet, but I plan to do so when I tackle
the device related clauses.

Is this patch OK to commit to gomp-4_0-branch?

Thanks,
Cesar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: subarrays-mappings-gcc-b.diff
Type: text/x-patch
Size: 30518 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20140724/ca5a8898/attachment.bin>


More information about the Fortran mailing list