[PATCH] OpenACC routines -- fortran front end

Cesar Philippidis cesar@codesourcery.com
Tue Nov 22 19:59:00 GMT 2016


On 11/18/2016 04:29 AM, Jakub Jelinek wrote:
> On Fri, Nov 11, 2016 at 03:44:07PM -0800, Cesar Philippidis wrote:
>> --- a/gcc/fortran/gfortran.h
>> +++ b/gcc/fortran/gfortran.h
>> @@ -314,6 +314,15 @@ enum save_state
>>  { SAVE_NONE = 0, SAVE_EXPLICIT, SAVE_IMPLICIT
>>  };
>>  
>> +/* Flags to keep track of ACC routine states.  */
>> +enum oacc_function
>> +{ OACC_FUNCTION_NONE = 0,
> 
> Please add a newline after {.
> 
>>    if (clauses)
>>      {
>>        unsigned mask = 0;
>>  
>>        if (clauses->gang)
>> -	level = GOMP_DIM_GANG, mask |= GOMP_DIM_MASK (level);
>> +	{
>> +	  level = GOMP_DIM_GANG, mask |= GOMP_DIM_MASK (level);
>> +	  ret = OACC_FUNCTION_GANG;
>> +	}
>>        if (clauses->worker)
>> -	level = GOMP_DIM_WORKER, mask |= GOMP_DIM_MASK (level);
>> +	{
>> +	  level = GOMP_DIM_WORKER, mask |= GOMP_DIM_MASK (level);
>> +	  ret = OACC_FUNCTION_WORKER;
>> +	}
>>        if (clauses->vector)
>> -	level = GOMP_DIM_VECTOR, mask |= GOMP_DIM_MASK (level);
>> +	{
>> +	  level = GOMP_DIM_VECTOR, mask |= GOMP_DIM_MASK (level);
>> +	  ret = OACC_FUNCTION_VECTOR;
>> +	}
> 
> As you have {}s around, please use
> 	level = GOMP_DIM_*;
> 	mask |= GOMP_DIM_MASK (level);
> 	ret = OACC_FUNCTION_*;
> 
>>        if (clauses->seq)
>>  	level = GOMP_DIM_MAX, mask |= GOMP_DIM_MASK (level);
>>  
>>        if (mask != (mask & -mask))
>> -	gfc_error ("Multiple loop axes specified for routine");
>> +	ret = OACC_FUNCTION_NONE;
>>      }
>>  
>> -  if (level < 0)
>> -    level = GOMP_DIM_MAX;
>> -
>> -  return level;
>> +  return ret;
>>  }
>>  
>>  match
>>  gfc_match_oacc_routine (void)
>>  {
>>    locus old_loc;
>> -  gfc_symbol *sym = NULL;
>>    match m;
>> +  gfc_intrinsic_sym *isym = NULL;
>> +  gfc_symbol *sym = NULL;
>>    gfc_omp_clauses *c = NULL;
>>    gfc_oacc_routine_name *n = NULL;
>> +  oacc_function dims = OACC_FUNCTION_NONE;
>> +  bool seen_error = false;
>>  
>>    old_loc = gfc_current_locus;
>>  
>> @@ -2287,45 +2314,52 @@ gfc_match_oacc_routine (void)
>>    if (m == MATCH_YES)
>>      {
>>        char buffer[GFC_MAX_SYMBOL_LEN + 1];
>> -      gfc_symtree *st;
>> +      gfc_symtree *st = NULL;
>>  
>>        m = gfc_match_name (buffer);
>>        if (m == MATCH_YES)
>>  	{
>> -	  st = gfc_find_symtree (gfc_current_ns->sym_root, buffer);
>> +	  if ((isym = gfc_find_function (buffer)) == NULL
>> +	      && (isym = gfc_find_subroutine (buffer)) == NULL)
>> +	    {
>> +	      st = gfc_find_symtree (gfc_current_ns->sym_root, buffer);
>> +	      if (st == NULL && gfc_current_ns->proc_name->attr.contained
> 
> Please add a newline before &&.
> 
>> +		  && gfc_current_ns->parent)
>> +		st = gfc_find_symtree (gfc_current_ns->parent->sym_root,
>> +				       buffer);
>> +	    }
> 
>> @@ -5934,6 +6033,21 @@ gfc_resolve_oacc_blocks (gfc_code *code, gfc_namespace *ns)
>>    ctx.private_iterators = new hash_set<gfc_symbol *>;
>>    ctx.previous = omp_current_ctx;
>>    ctx.is_openmp = false;
>> +
>> +  if (code->ext.omp_clauses->gang)
>> +    dims = OACC_FUNCTION_GANG;
>> +  if (code->ext.omp_clauses->worker)
>> +    dims = OACC_FUNCTION_WORKER;
>> +  if (code->ext.omp_clauses->vector)
>> +    dims = OACC_FUNCTION_VECTOR;
>> +  if (code->ext.omp_clauses->seq)
>> +    dims = OACC_FUNCTION_SEQ;
> 
> Shouldn't these be else if ?
>> +
>> +  if (dims == OACC_FUNCTION_NONE && ctx.previous != NULL
> 
> Again, as the whole condition doesn't fit on one line, please
> put && on a new line.
>> +      && !ctx.previous->is_openmp)
>> +    dims = ctx.previous->dims;

I've address those issues in this patch. Is it ok for trunk?

Cesar

-------------- next part --------------
A non-text attachment was scrubbed...
Name: routine-fortran-fe-20161122.diff
Type: text/x-patch
Size: 19151 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20161122/49063cea/attachment.bin>


More information about the Fortran mailing list