@@ -515,7 +515,7 @@ def replace_vars_inner(self, var_dict):
515
515
516
516
def add_to_usedef_set (self , use_set , def_set , start ):
517
517
assert start == True or start == False
518
- if config .DEBUG_OPENMP >= 1 :
518
+ if config .DEBUG_OPENMP >= 3 :
519
519
print ("add_to_usedef_set" , start , self .name , "is_dsa=" , is_dsa (self .name ))
520
520
521
521
def add_arg (arg , the_set ):
@@ -3360,6 +3360,7 @@ def get_loops_in_region(all_loops):
3360
3360
collapse_tags = get_tags_of_type (clauses , "QUAL.OMP.COLLAPSE" )
3361
3361
new_stmts_for_iterspace = []
3362
3362
collapse_iterspace_block = set ()
3363
+ iterspace_vars = []
3363
3364
if len (collapse_tags ) > 0 :
3364
3365
# Limit all_loops to just loops within the openmp region.
3365
3366
all_loops = get_loops_in_region (all_loops )
@@ -3469,7 +3470,6 @@ def get_loops_in_region(all_loops):
3469
3470
new_var_scope = last_loop_entry_block .body [0 ].target .scope
3470
3471
3471
3472
# -------- Add vars to remember cumulative product of iteration space sizes.
3472
- iterspace_vars = []
3473
3473
new_iterspace_var = new_var_scope .redefine ("new_iterspace0" , self .loc )
3474
3474
start_tags .append (openmp_tag ("QUAL.OMP.FIRSTPRIVATE" , new_iterspace_var .name ))
3475
3475
iterspace_vars .append (new_iterspace_var )
@@ -3873,8 +3873,7 @@ def _get_loop_kind(func_var, call_table):
3873
3873
start_tags .append (openmp_tag ("QUAL.OMP.FIRSTPRIVATE" , omp_start_var .name ))
3874
3874
start_tags .append (openmp_tag ("QUAL.OMP.FIRSTPRIVATE" , omp_lb_var .name ))
3875
3875
start_tags .append (openmp_tag ("QUAL.OMP.FIRSTPRIVATE" , omp_ub_var .name ))
3876
- tags_for_enclosing = [cmp_var .name , omp_lb_var .name , omp_start_var .name , omp_iv_var .name , types_mod_var .name , int64_var .name , itercount_var .name , omp_ub_var .name , const1_var .name , const1_latch_var .name ]
3877
- #tags_for_enclosing = [omp_lb_var.name, omp_start_var.name, omp_iv_var.name, types_mod_var.name, int64_var.name, itercount_var.name, omp_ub_var.name, const1_var.name, const1_latch_var.name]
3876
+ tags_for_enclosing = [cmp_var .name , omp_lb_var .name , omp_start_var .name , omp_iv_var .name , types_mod_var .name , int64_var .name , itercount_var .name , omp_ub_var .name , const1_var .name , const1_latch_var .name , get_itercount_var .name ] + [x .name for x in iterspace_vars ]
3878
3877
tags_for_enclosing = [openmp_tag ("QUAL.OMP.PRIVATE" , x ) for x in tags_for_enclosing ]
3879
3878
# Don't blindly copy code here...this isn't doing what the other spots are doing with privatization.
3880
3879
#self.add_private_to_enclosing(replace_vardict, tags_for_enclosing)
@@ -3891,15 +3890,6 @@ def some_for_directive(self, args, main_start_tag, main_end_tag, first_clause, g
3891
3890
start_tags = [openmp_tag (main_start_tag )]
3892
3891
end_tags = [openmp_tag (main_end_tag )]
3893
3892
clauses = self .some_data_clause_directive (args , start_tags , end_tags , first_clause , has_loop = True )
3894
- #sblk = self.blocks[self.blk_start]
3895
- #scope = sblk.scope
3896
- #eblk = self.blocks[self.blk_end]
3897
- #clauses, default_shared = self.flatten(args[first_clause:], sblk)
3898
-
3899
- #if config.DEBUG_OPENMP >= 1:
3900
- # print("visit", main_start_tag, args, type(args), default_shared)
3901
- # for clause in clauses:
3902
- # print("post-process clauses:", clause)
3903
3893
3904
3894
if "PARALLEL" in main_start_tag :
3905
3895
# ---- Back propagate THREAD_LIMIT to enclosed target region. ----
@@ -3969,6 +3959,18 @@ def for_simd_clause(self, args):
3969
3959
args , type (args ), args [0 ])
3970
3960
return args [0 ]
3971
3961
3962
+ def schedule_clause (self , args ):
3963
+ if config .DEBUG_OPENMP >= 1 :
3964
+ print ("visit schedule_clause" ,
3965
+ args , type (args ), args [0 ])
3966
+ return args [0 ]
3967
+
3968
+ def dist_schedule_clause (self , args ):
3969
+ if config .DEBUG_OPENMP >= 1 :
3970
+ print ("visit dist_schedule_clause" ,
3971
+ args , type (args ), args [0 ])
3972
+ return args [0 ]
3973
+
3972
3974
# Don't need a rule for parallel_for_simd_construct.
3973
3975
3974
3976
def parallel_for_simd_directive (self , args ):
@@ -4071,7 +4073,7 @@ def map_clause(self, args):
4071
4073
assert (len (args ) == 2 )
4072
4074
else :
4073
4075
map_type = "TOFROM" # is this default right? FIX ME
4074
- var_list = args
4076
+ var_list = args [ 0 ]
4075
4077
ret = []
4076
4078
for var in var_list :
4077
4079
ret .append (openmp_tag ("QUAL.OMP.MAP." + map_type , var ))
@@ -4267,7 +4269,7 @@ def teams_back_prop(self, clauses):
4267
4269
def check_distribute_nesting (self , dir_tag ):
4268
4270
if "DISTRIBUTE" in dir_tag and "TEAMS" not in dir_tag :
4269
4271
enclosing_regions = get_enclosing_region (self .func_ir , self .blk_start )
4270
- if len (enclosing_regions ) < 1 or "TEAMS" not in enclosing_regions [0 ].tags [0 ].name :
4272
+ if len (enclosing_regions ) < 1 or "TEAMS" not in enclosing_regions [- 1 ].tags [0 ].name :
4271
4273
raise NotImplementedError ("DISTRIBUTE must be nested under or combined with TEAMS." )
4272
4274
4273
4275
def teams_directive (self , args ):
@@ -4330,10 +4332,11 @@ def target_teams_directive(self, args):
4330
4332
def target_teams_distribute_directive (self , args ):
4331
4333
self .some_target_directive (args , "TARGET.TEAMS.DISTRIBUTE" , 3 , has_loop = True )
4332
4334
4335
+ def target_loop_directive (self , args ):
4336
+ self .some_target_directive (args , "TARGET.TEAMS.DISTRIBUTE.PARALLEL.LOOP" , 2 , has_loop = True )
4337
+
4333
4338
def target_teams_loop_directive (self , args ):
4334
4339
self .some_target_directive (args , "TARGET.TEAMS.DISTRIBUTE.PARALLEL.LOOP" , 3 , has_loop = True )
4335
- #self.some_target_directive(args, "TARGET.TEAMS.DISTRIBUTE.PARALLEL.LOOP.SIMD", 3, has_loop=True)
4336
- #self.some_target_directive(args, "TARGET.TEAMS.LOOP", 3, has_loop=True)
4337
4340
4338
4341
def target_teams_distribute_parallel_for_directive (self , args ):
4339
4342
self .some_target_directive (args , "TARGET.TEAMS.DISTRIBUTE.PARALLEL.LOOP" , 5 , has_loop = True )
@@ -4415,6 +4418,26 @@ def teams_distribute_directive(self, args):
4415
4418
def teams_distribute_simd_directive (self , args ):
4416
4419
self .some_distribute_directive (args , "TEAMS.DISTRIBUTE.SIMD" , 3 , has_loop = True )
4417
4420
4421
+ def teams_loop_directive (self , args ):
4422
+ self .some_distribute_directive (args , "TEAMS.DISTRIBUTE.PARALLEL.LOOP" , 2 , has_loop = True )
4423
+
4424
+ def loop_directive (self , args ):
4425
+ # TODO Add error checking that a clause that the parser accepts if we find that
4426
+ # loop can even take clauses, which we're not sure that it can.
4427
+ enclosing_regions = get_enclosing_region (self .func_ir , self .blk_start )
4428
+ if not enclosing_regions or len (enclosing_regions ) < 1 :
4429
+ self .some_for_directive (args , "DIR.OMP.PARALLEL.LOOP" , "DIR.OMP.END.PARALLEL.LOOP" , 1 , True )
4430
+ else :
4431
+ if "DISTRIBUTE" in enclosing_regions [- 1 ].tags [0 ].name :
4432
+ self .some_distribute_directive (args , "PARALLEL.LOOP" , 1 , has_loop = True )
4433
+ elif "TEAMS" in enclosing_regions [- 1 ].tags [0 ].name :
4434
+ self .some_distribute_directive (args , "DISTRIBUTE.PARALLEL.LOOP" , 1 , has_loop = True )
4435
+ else :
4436
+ if "TARGET" in enclosing_regions [- 1 ].tags [0 ].name :
4437
+ self .some_distribute_directive (args , "TEAMS.DISTRIBUTE.PARALLEL.LOOP" , 1 , has_loop = True )
4438
+ else :
4439
+ self .some_for_directive (args , "DIR.OMP.PARALLEL.LOOP" , "DIR.OMP.END.PARALLEL.LOOP" , 1 , True )
4440
+
4418
4441
def distribute_directive (self , args ):
4419
4442
self .some_distribute_directive (args , "DISTRIBUTE" , 1 , has_loop = True )
4420
4443
@@ -4453,8 +4476,6 @@ def some_distribute_directive(self, args, dir_tag, lexer_count, has_loop=False):
4453
4476
start_tags .append (openmp_tag ("QUAL.OMP.THREAD_LIMIT" , 0 ))
4454
4477
self .teams_back_prop (clauses )
4455
4478
elif "PARALLEL" in dir_tag :
4456
- if len (self .get_clauses_by_name (clauses , "QUAL.OMP.THREAD_LIMIT" )) == 0 :
4457
- start_tags .append (openmp_tag ("QUAL.OMP.THREAD_LIMIT" , 0 ))
4458
4479
self .parallel_back_prop (clauses )
4459
4480
4460
4481
if config .DEBUG_OPENMP >= 1 :
@@ -4796,13 +4817,6 @@ def target_teams_distribute_parallel_for_clause(self, args):
4796
4817
print (args [0 ][0 ])
4797
4818
return args [0 ]
4798
4819
4799
- def target_teams_loop_clause (self , args ):
4800
- if config .DEBUG_OPENMP >= 1 :
4801
- print ("visit target_teams_loop_clause" , args , type (args ), args [0 ])
4802
- if isinstance (args [0 ], list ):
4803
- print (args [0 ][0 ])
4804
- return args [0 ]
4805
-
4806
4820
# Don't need a rule for target_update_construct.
4807
4821
4808
4822
def target_update_directive (self , args ):
@@ -5514,12 +5528,15 @@ def NUMBER(self, args):
5514
5528
| teams_distribute_simd_construct
5515
5529
| teams_distribute_parallel_for_construct
5516
5530
| teams_distribute_parallel_for_simd_construct
5531
+ | loop_construct
5532
+ | teams_loop_construct
5517
5533
| target_construct
5518
5534
| target_teams_construct
5519
5535
| target_teams_distribute_construct
5520
5536
| target_teams_distribute_simd_construct
5521
5537
| target_teams_distribute_parallel_for_simd_construct
5522
5538
| target_teams_distribute_parallel_for_construct
5539
+ | target_loop_construct
5523
5540
| target_teams_loop_construct
5524
5541
| target_enter_data_construct
5525
5542
| target_exit_data_construct
@@ -5539,8 +5556,6 @@ def NUMBER(self, args):
5539
5556
| parallel_sections_construct
5540
5557
| master_construct
5541
5558
| ordered_construct
5542
- //teams_distribute_parallel_for_simd_clause: target_clause
5543
- // | teams_distribute_parallel_for_simd_clause
5544
5559
for_simd_construct: for_simd_directive
5545
5560
for_simd_directive: FOR SIMD [for_simd_clause*]
5546
5561
for_simd_clause: for_clause
@@ -5735,6 +5750,9 @@ def NUMBER(self, args):
5735
5750
target_teams_distribute_parallel_for_construct: target_teams_distribute_parallel_for_directive
5736
5751
teams_distribute_parallel_for_construct: teams_distribute_parallel_for_directive
5737
5752
teams_distribute_parallel_for_simd_construct: teams_distribute_parallel_for_simd_directive
5753
+ loop_construct: loop_directive
5754
+ teams_loop_construct: teams_loop_directive
5755
+ target_loop_construct: target_loop_directive
5738
5756
target_teams_loop_construct: target_teams_loop_directive
5739
5757
target_teams_construct: target_teams_directive
5740
5758
target_teams_distribute_construct: target_teams_distribute_directive
@@ -5903,30 +5921,10 @@ def NUMBER(self, args):
5903
5921
5904
5922
ompx_attribute: OMPX_ATTRIBUTE "(" PYTHON_NAME "(" number_list ")" ")"
5905
5923
OMPX_ATTRIBUTE: "ompx_attribute"
5906
- //target_teams_loop_directive: TARGET TEAMS LOOP [target_teams_loop_clause*]
5907
- target_teams_loop_directive: TARGET TEAMS LOOP [target_teams_distribute_parallel_for_simd_clause*]
5908
- target_teams_loop_clause: if_clause
5909
- | device_clause
5910
- | private_clause
5911
- | firstprivate_clause
5912
- // | in_reduction_clause
5913
- | map_clause
5914
- | is_device_ptr_clause
5915
- // | defaultmap_clause
5916
- | NOWAIT
5917
- | allocate_clause
5918
- | depend_with_modifier_clause
5919
- // | uses_allocators_clause
5920
- | num_teams_clause
5921
- | thread_limit_clause
5922
- | data_default_clause
5923
- | data_sharing_clause
5924
- // | reduction_default_only_clause
5925
- // | bind_clause
5926
- | collapse_clause
5927
- | ORDERED
5928
- | lastprivate_clause
5929
- | ompx_attribute
5924
+ loop_directive: LOOP [teams_distribute_parallel_for_clause*]
5925
+ teams_loop_directive: TEAMS LOOP [teams_distribute_parallel_for_clause*]
5926
+ target_loop_directive: TARGET LOOP [target_teams_distribute_parallel_for_clause*]
5927
+ target_teams_loop_directive: TARGET TEAMS LOOP [target_teams_distribute_parallel_for_clause*]
5930
5928
5931
5929
target_teams_directive: TARGET TEAMS [target_teams_clause*]
5932
5930
target_teams_clause: if_clause
@@ -6149,8 +6147,7 @@ def NUMBER(self, args):
6149
6147
for_directive: FOR [for_clause*]
6150
6148
for_clause: unique_for_clause | data_clause | NOWAIT
6151
6149
unique_for_clause: ORDERED
6152
- | sched_no_expr
6153
- | sched_expr
6150
+ | schedule_clause
6154
6151
| collapse_clause
6155
6152
LINEAR: "linear"
6156
6153
linear_clause: LINEAR "(" var_list ":" const_num_or_var ")"
0 commit comments