00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 static const char *source_file = __FILE__;
00106
00107
00108
00109 #include "defs.h"
00110 #include "glob.h"
00111 #include "stab.h"
00112 #include "strtab.h"
00113 #include "errors.h"
00114 #include "targ_const.h"
00115 #include "config_targ.h"
00116 #include "const.h"
00117 #include "pu_info.h"
00118 #include "wn.h"
00119 #include "wn_util.h"
00120 #include "f90_utils.h"
00121 #include "targ_sim.h"
00122
00123
00124
00125 #include "i_cvrt.h"
00126
00127
00128
00129 #include "cwh_defines.h"
00130 #include "cwh_addr.h"
00131 #include "cwh_expr.h"
00132 #include "cwh_stk.h"
00133 #include "cwh_block.h"
00134 #include "cwh_types.h"
00135 #include "cwh_preg.h"
00136 #include "cwh_stab.h"
00137 #include "cwh_auxst.h"
00138 #include "cwh_stmt.h"
00139 #include "cwh_directive.h"
00140 #include "cwh_directive.i"
00141
00142 static int task_var_count;
00143 static int task_nest_count;
00144 static int task_lastthread_count;
00145 static int task_affinity_count;
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 extern INTPTR
00159 fei_task_var( INTPTR sym_idx,
00160 INT32 context)
00161 {
00162 STB_pkt *p;
00163 WN *wn;
00164 #ifdef KEY
00165 int op_code = 0;
00166 #else
00167 int op_code;
00168 #endif
00169 ST *st;
00170 p = cast_to_STB(sym_idx);
00171 DevAssert((p->form == is_ST),("Odd object ref"));
00172
00173 st = (ST *)p->item;
00174 if (Has_Base_Block(st)) {
00175 ST * base = ST_base(st);
00176 if (ST_is_temp_var(base))
00177 if (ST_sclass(base) == SCLASS_AUTO)
00178 if (!ST_is_return_var(base))
00179
00180
00181
00182 return(sym_idx);
00183 }
00184
00185 switch((CONTEXT_TYPE) context) {
00186 case Context_Omp_Private:
00187 case Context_Private:
00188
00189
00190
00191 wn = WN_CreatePragma(WN_PRAGMA_LOCAL, (ST *)p->item, 0, 0);
00192 if ((CONTEXT_TYPE) context == Context_Omp_Private)
00193 WN_set_pragma_omp(wn);
00194 cwh_stk_push(wn, WN_item);
00195 task_var_count++;
00196 break;
00197 case Context_Omp_Shared:
00198 case Context_Shared:
00199 wn = WN_CreatePragma(WN_PRAGMA_SHARED, (ST *)p->item, 0, 0);
00200 if ((CONTEXT_TYPE) context == Context_Omp_Shared)
00201 WN_set_pragma_omp(wn);
00202 cwh_stk_push(wn, WN_item);
00203 task_var_count++;
00204 break;
00205 case Context_Omp_Lastprivate:
00206 case Context_Lastlocal:
00207 wn = WN_CreatePragma(WN_PRAGMA_LASTLOCAL, (ST *)p->item, 0, 0);
00208 if ((CONTEXT_TYPE) context == Context_Omp_Lastprivate)
00209 WN_set_pragma_omp(wn);
00210 cwh_stk_push(wn, WN_item);
00211 task_var_count++;
00212 break;
00213 case Context_Omp_Firstprivate:
00214 case Context_Getfirst:
00215 wn = WN_CreatePragma(WN_PRAGMA_FIRSTPRIVATE, (ST *)p->item, 0, 0);
00216 if ((CONTEXT_TYPE) context == Context_Omp_Firstprivate)
00217 WN_set_pragma_omp(wn);
00218 cwh_stk_push(wn, WN_item);
00219 task_var_count++;
00220 break;
00221 case Context_Affinity:
00222 case Context_Omp_Affinity:
00223 wn = WN_CreateXpragma( WN_PRAGMA_AFFINITY, (ST_IDX) NULL, 1);
00224 if ((CONTEXT_TYPE) context == Context_Omp_Affinity)
00225 WN_set_pragma_omp(wn);
00226 WN_kid0(wn) = cwh_addr_address_ST( (ST *)p->item, 0 );
00227 cwh_stk_push(wn, WN_item);
00228 cwh_stk_push(WN_COPY_Tree(wn), WN_item);
00229 task_affinity_count++;
00230 break;
00231 case Context_Nest:
00232 case Context_Omp_Nest:
00233
00234
00235 task_nest_count++;
00236 break;
00237 case Context_Lastthread:
00238 wn = WN_CreatePragma(WN_PRAGMA_LASTTHREAD, (ST *)p->item, 0, 0);
00239 cwh_stk_push(wn, WN_item);
00240 task_lastthread_count++;
00241 break;
00242 case Context_Omp_Copyin:
00243 wn = WN_CreatePragma(WN_PRAGMA_COPYIN, (ST *)p->item, 0, 0);
00244 WN_set_pragma_omp(wn);
00245 cwh_stk_push(wn, WN_item);
00246 task_var_count++;
00247 break;
00248
00249 case Context_Omp_Copyprivate:
00250 wn = WN_CreatePragma(WN_PRAGMA_COPYPRIVATE, (ST *)p->item, 0, 0);
00251 WN_set_pragma_omp(wn);
00252 cwh_stk_push(wn, WN_item);
00253 task_var_count++;
00254 break;
00255 case Context_Omp_Reduction_Max:
00256 case Context_Omp_Reduction_Min:
00257 case Context_Omp_Reduction_Band:
00258 case Context_Omp_Reduction_Bor:
00259 case Context_Omp_Reduction_Bneqv:
00260 case Context_Omp_Reduction_Plus:
00261 case Context_Omp_Reduction_Mult:
00262 case Context_Omp_Reduction_Minus:
00263 case Context_Omp_Reduction_And:
00264 case Context_Omp_Reduction_Or:
00265 case Context_Omp_Reduction_Eqv:
00266 case Context_Omp_Reduction_Neqv:
00267 switch((CONTEXT_TYPE) context) {
00268 case Context_Omp_Reduction_Max:
00269 op_code = OPR_MAX;
00270 break;
00271 case Context_Omp_Reduction_Min:
00272 op_code = OPR_MIN;
00273 break;
00274 case Context_Omp_Reduction_Band:
00275 op_code = OPR_BAND;
00276 break;
00277 case Context_Omp_Reduction_Bor:
00278 op_code = OPR_BIOR;
00279 break;
00280 case Context_Omp_Reduction_Bneqv:
00281 op_code = OPR_BXOR;
00282 break;
00283 case Context_Omp_Reduction_Plus:
00284 op_code = OPR_ADD;
00285 break;
00286 case Context_Omp_Reduction_Mult:
00287 op_code = OPR_MPY;
00288 break;
00289 case Context_Omp_Reduction_Minus:
00290 op_code = OPR_SUB;
00291 break;
00292 case Context_Omp_Reduction_And:
00293 op_code = OPR_LAND;
00294 break;
00295 case Context_Omp_Reduction_Or:
00296 op_code = OPR_LIOR;
00297 break;
00298 case Context_Omp_Reduction_Eqv:
00299 op_code = OPR_EQ;
00300 break;
00301 case Context_Omp_Reduction_Neqv:
00302 op_code = OPR_NE;
00303 break;
00304 }
00305 wn = WN_CreatePragma(WN_PRAGMA_REDUCTION, (ST *)p->item, 0, op_code);
00306 WN_set_pragma_omp(wn);
00307 cwh_stk_push(wn, WN_item);
00308 task_var_count++;
00309 break;
00310 default:
00311 DevAssert((0), ("Unimplemented fei_task_var type"));
00312 break;
00313 }
00314 return sym_idx;
00315 }
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 static WN *
00330 cwh_region(REGION_KIND kind)
00331 {
00332 WN *body,*pragmas,*exits,*region;
00333
00334
00335
00336 body = WN_CreateBlock ();
00337 pragmas = WN_CreateBlock ();
00338 exits = WN_CreateBlock ();
00339 region = WN_CreateRegion (kind,
00340 body,
00341 pragmas,
00342 exits,
00343 -1,
00344 0);
00345 cwh_block_append(region);
00346
00347
00348
00349
00350 cwh_block_push_region(region);
00351 cwh_block_set_current(pragmas);
00352
00353 return(body);
00354 }
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374 extern WN *
00375 cwh_mp_region( WN_PRAGMA_ID wn_pragma_id,
00376 int threadcount,
00377 int datacount,
00378 int ontocount,
00379 int reductioncount,
00380 int chunkcount,
00381 int is_omp)
00382 {
00383
00384 WN *body;
00385 WN *wn, *wn1;
00386 WN *affinity_block=NULL;
00387
00388
00389
00390 body = cwh_region(REGION_KIND_MP);
00391
00392
00393 cwh_stmt_add_pragma(wn_pragma_id, is_omp,(ST_IDX) NULL, nested_do_descriptor.current,
00394 nested_do_descriptor.depth);
00395
00396
00397
00398 if (chunkcount) {
00399 wn = cwh_expr_operand(NULL);
00400 cwh_stmt_add_xpragma(WN_PRAGMA_CHUNKSIZE,is_omp,wn);
00401 }
00402
00403 while (reductioncount) {
00404
00405 wn1 = cwh_expr_address(f_NONE);
00406
00407 if (WNOPR(wn1)==OPR_LDA) {
00408 cwh_stmt_add_pragma(WN_PRAGMA_REDUCTION,is_omp,WN_st(wn1),WN_lda_offset(wn1));
00409
00410 } else if (WNOPR(wn1) == OPR_LDID) {
00411 cwh_stmt_add_pragma(WN_PRAGMA_REDUCTION,is_omp,WN_st(wn1),WN_load_offset(wn1));
00412
00413 } else {
00414
00415 DevAssert((WN_operator(wn1)==OPR_ARRAY),("Odd reduction expression"));
00416 cwh_stmt_add_xpragma(WN_PRAGMA_REDUCTION,is_omp,wn1) ;
00417 }
00418
00419 reductioncount--;
00420 }
00421 if (ontocount) {
00422
00423
00424 WN *onto_block = WN_CreateBlock();
00425 while (ontocount) {
00426
00427 wn = WN_CreateXpragma( WN_PRAGMA_ONTO, (ST_IDX) NULL, 1);
00428 if (is_omp) WN_set_pragma_omp(wn);
00429 WN_kid0(wn) = cwh_expr_operand(NULL);
00430 WN_Set_Linenum (wn, USRCPOS_srcpos(current_srcpos) );
00431 WN_INSERT_BlockFirst(onto_block, wn);
00432 ontocount--;
00433 }
00434 cwh_block_append(onto_block);
00435 }
00436 if (threadcount || datacount) {
00437
00438 cwh_directive_set_LNO_flags();
00439 }
00440
00441 while (threadcount) {
00442
00443
00444
00445
00446 if (affinity_block==NULL) affinity_block=WN_CreateBlock();
00447 wn = WN_CreateXpragma( WN_PRAGMA_THREAD_AFFINITY, (ST_IDX) NULL, 1);
00448 if (is_omp)
00449 WN_set_pragma_omp(wn);
00450 WN_kid0(wn) = cwh_expr_operand(NULL);
00451 WN_Set_Linenum (wn, USRCPOS_srcpos(current_srcpos) );
00452 WN_INSERT_BlockLast(affinity_block,wn);
00453
00454 wn = WN_CreateXpragma( WN_PRAGMA_THREAD_AFFINITY, (ST_IDX) NULL, 1);
00455 WN_kid0(wn) = cwh_expr_operand(NULL);
00456 cwh_directive_add_pragma_to_loop(wn,is_omp);
00457 threadcount--;
00458 }
00459 while (datacount) {
00460
00461
00462
00463
00464 WN *array_exp;
00465 ST *st;
00466 PREG_det preg;
00467 if (affinity_block==NULL) affinity_block=WN_CreateBlock();
00468 wn = WN_CreateXpragma( WN_PRAGMA_DATA_AFFINITY, (ST_IDX) NULL, 1);
00469 if (is_omp) WN_set_pragma_omp(wn);
00470 WN_kid0(wn) = cwh_expr_operand(NULL);
00471 WN_Set_Linenum (wn, USRCPOS_srcpos(current_srcpos) );
00472 WN_INSERT_BlockLast(affinity_block,wn);
00473
00474 wn = WN_CreateXpragma( WN_PRAGMA_DATA_AFFINITY, (ST_IDX) NULL, 1);
00475 WN_kid0(wn) = array_exp = cwh_expr_operand(NULL);
00476 cwh_directive_add_pragma_to_loop(wn,is_omp);
00477
00478
00479
00480 DevAssert((WNOPR(array_exp)==OPR_ILOAD),("Odd expr in data affinity"));
00481 array_exp=WN_kid0(array_exp);
00482 DevAssert((WNOPR(array_exp)==OPR_ARRAY), ("Odd expr in data affinity"));
00483 wn = WN_kid0(array_exp);
00484 DevAssert((WNOPR(wn)==OPR_LDA || WNOPR(wn)==OPR_LDID),("Not a regular array in data affinity"));
00485 st = WN_st(wn);
00486 preg = cwh_auxst_distr_preg(st);
00487
00488 wn = WN_CreateXpragma( WN_PRAGMA_DATA_AFFINITY, (ST_IDX) NULL, 1);
00489 if (is_omp) WN_set_pragma_omp(wn);
00490 WN_kid0(wn) = WN_CreateLdid ( OPC_I4I4LDID, preg.preg, preg.preg_st, preg.preg_ty);
00491 WN_Set_Linenum (wn, USRCPOS_srcpos(current_srcpos) );
00492 WN_INSERT_BlockLast(affinity_block,wn);
00493
00494 wn = WN_CreateXpragma( WN_PRAGMA_DATA_AFFINITY, (ST_IDX) NULL, 1);
00495 WN_kid0(wn) = WN_CreateLdid ( OPC_I4I4LDID, preg.preg, preg.preg_st, preg.preg_ty);
00496 cwh_directive_add_pragma_to_loop(wn,is_omp);
00497 datacount--;
00498 }
00499 #if 0
00500 while (ontocount) {
00501
00502 wn = WN_CreateXpragma( WN_PRAGMA_ONTO, (ST_IDX) NULL, 1);
00503 if (is_omp) WN_set_pragma_omp(wn);
00504 WN_kid0(wn) = cwh_expr_operand(NULL);
00505 cwh_block_append(wn);
00506 ontocount--;
00507 }
00508 #endif
00509
00510 while(task_affinity_count) {
00511 wn = cwh_stk_pop_WN();
00512 WN_Set_Linenum (wn, USRCPOS_srcpos(current_srcpos) );
00513 WN_INSERT_BlockFirst(affinity_block,wn);
00514 wn = cwh_stk_pop_WN();
00515 WN_Set_Linenum (wn, USRCPOS_srcpos(current_srcpos));
00516 cwh_block_append_given_id(wn,Top_of_Loop_Block,TRUE);
00517 task_affinity_count--;
00518 }
00519
00520
00521
00522 while (task_var_count) {
00523 wn = cwh_stk_pop_WN();
00524
00525 if ((WN_operator(wn) == OPR_PRAGMA) &&
00526 (WN_pragma(wn) == WN_PRAGMA_LOCAL))
00527 cwh_block_add_to_enclosing_regions(WN_PRAGMA_LOCAL,WN_st(wn));
00528 else
00529 cwh_block_append(wn);
00530 task_var_count--;
00531 }
00532
00533
00534 if (task_lastthread_count==1) {
00535
00536 wn = cwh_stk_pop_WN();
00537 cwh_block_append(wn);
00538 task_lastthread_count=0;
00539 }
00540
00541 if (affinity_block) {
00542 cwh_block_append(affinity_block);
00543 }
00544
00545 return(body);
00546 }
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562 extern int
00563 fei_parallel_region ( INTPTR ifexpr,
00564 INTPTR maxcpus,
00565 INT32 context_start,
00566 INT32 context_end,
00567 INT32 lineno,
00568 INT32 flags )
00569 {
00570
00571
00572
00573
00574 WN *body;
00575
00576 nested_do_descriptor.depth = 0;
00577 body = cwh_mp_region(WN_PRAGMA_PARALLEL_BEGIN,0,0,0,0,0,0);
00578
00579
00580
00581
00582 cwh_directive_load_value_pragma(ifexpr,WN_PRAGMA_IF);
00583 cwh_directive_load_value_pragma(maxcpus,WN_PRAGMA_NUMTHREADS);
00584
00585 cwh_directive_set_PU_flags(FALSE);
00586
00587
00588
00589 cwh_block_set_current(body);
00590 return(context_start);
00591 }
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604 extern void
00605 fei_endparallel_region ( INT32 task_x,
00606 INT32 lineno )
00607 {
00608 cwh_directive_pop_and_nowait(FALSE,FALSE);
00609 }
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 extern int
00626 fei_doparallel ( INT32 induc_symx,
00627 INT32 work_dist,
00628 INTPTR work_dist_opnd,
00629 INT32 lineno )
00630 {
00631
00632 WN *body;
00633
00634
00635
00636
00637 nested_do_descriptor.depth = 1;
00638 task_nest_count = 0;
00639 nested_do_descriptor.current = 0;
00640 nested_do_descriptor.explicit_end = TRUE;
00641 nested_do_descriptor.type = WN_PRAGMA_PDO_BEGIN;
00642 body = cwh_mp_region(WN_PRAGMA_PDO_BEGIN,0,0,0,0,0,0);
00643
00644
00645
00646 nested_do_descriptor.depth = 0;
00647
00648
00649
00650 cwh_directive_work_dist(work_dist,work_dist_opnd);
00651
00652
00653
00654 cwh_stmt_add_pragma(WN_PRAGMA_NOWAIT);
00655
00656
00657 cwh_block_set_current(body);
00658
00659 parallel_do_count = 1;
00660
00661 cwh_directive_set_PU_flags(FALSE);
00662
00663 return(0);
00664 }
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679 extern void
00680 fei_task_endloop ( INT32 taskloop_x,
00681 INT32 lineno,
00682 INT32 nowait )
00683 {
00684 WN *wn ;
00685
00686 if (! nowait) {
00687
00688 wn = WN_CreatePragma(WN_PRAGMA_BARRIER,(ST_IDX) NULL,0,0);
00689 cwh_directive_barrier_insert(wn, 0);
00690 }
00691 }
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706 extern void
00707 fei_doall ( INTPTR ifexpr,
00708 INTPTR maxcpus,
00709 INT32 context_start,
00710 INT32 context_end,
00711 INT32 induc_symx,
00712 INT32 work_dist,
00713 INTPTR work_dist_opnd,
00714 INT32 flags,
00715 INT32 lineno )
00716 {
00717 WN *body;
00718
00719 nested_do_descriptor.depth = 1;
00720 task_nest_count = 0;
00721 nested_do_descriptor.current = 0;
00722 nested_do_descriptor.explicit_end = FALSE;
00723 nested_do_descriptor.type = WN_PRAGMA_DOACROSS;
00724 body = cwh_mp_region(WN_PRAGMA_DOACROSS,0,0,0,0,0,0);
00725
00726
00727
00728 cwh_directive_load_value_pragma(ifexpr,WN_PRAGMA_IF);
00729 cwh_directive_load_value_pragma(maxcpus,WN_PRAGMA_NUMTHREADS);
00730 cwh_directive_work_dist(work_dist,work_dist_opnd);
00731
00732
00733 cwh_block_set_current(body);
00734
00735 parallel_do_count = 1;
00736
00737 cwh_directive_set_PU_flags(FALSE);
00738 }
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751 static void
00752 cwh_doacross(INTPTR task_if_idx,
00753 int schedtype,
00754 int threadcount,
00755 int datacount,
00756 int ontocount,
00757 int reductioncount,
00758 int chunkcount,
00759 WN_PRAGMA_ID pragma_id,
00760 int is_omp)
00761 {
00762 WN *body;
00763
00764 nested_do_descriptor.depth = task_nest_count;
00765 task_nest_count = 0;
00766 nested_do_descriptor.current = 0;
00767 nested_do_descriptor.explicit_end = FALSE;
00768 nested_do_descriptor.type = pragma_id;
00769 body = cwh_mp_region(pragma_id,threadcount,datacount,
00770 ontocount,reductioncount,chunkcount,is_omp);
00771
00772
00773
00774 cwh_directive_load_value_pragma(task_if_idx,WN_PRAGMA_IF);
00775
00776 if (schedtype != WN_PRAGMA_SCHEDTYPE_UNKNOWN) {
00777 cwh_stmt_add_pragma(WN_PRAGMA_MPSCHEDTYPE, FALSE,(ST_IDX) NULL, schedtype);
00778 }
00779
00780
00781 cwh_block_set_current(body);
00782
00783 if (nested_do_descriptor.depth) {
00784 parallel_do_count =nested_do_descriptor.depth;
00785 } else {
00786 parallel_do_count = 1;
00787 }
00788
00789 cwh_directive_set_PU_flags((nested_do_descriptor.depth > 1));
00790 }
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802 extern void
00803 fei_doacross(INTPTR task_if_idx,
00804 int schedtype,
00805 int threadcount,
00806 int datacount,
00807 int ontocount,
00808 int reductioncount,
00809 int chunkcount)
00810 {
00811 cwh_doacross(task_if_idx,schedtype,threadcount,datacount,ontocount,
00812 reductioncount,chunkcount,WN_PRAGMA_DOACROSS,0);
00813 }
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825 extern void
00826 fei_paralleldo( INTPTR task_if_idx,
00827 int schedtype,
00828 int threadcount,
00829 int datacount,
00830 int ontocount,
00831 int reductioncount,
00832 int chunkcount )
00833 {
00834 cwh_doacross(task_if_idx,schedtype,threadcount,datacount,ontocount,
00835 reductioncount,chunkcount,WN_PRAGMA_PARALLEL_DO,0);
00836 }
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849 static void
00850 cwh_parallel (INTPTR task_if_idx,
00851 int defaultt,
00852 int is_omp)
00853 {
00854 WN *body;
00855
00856 task_nest_count = 0;
00857 body = cwh_mp_region(WN_PRAGMA_PARALLEL_BEGIN,0,0,0,0,0,is_omp);
00858
00859
00860
00861 cwh_directive_load_value_pragma(task_if_idx,WN_PRAGMA_IF);
00862
00863 if (defaultt) {
00864
00865 DevAssert((defaultt > 0 && defaultt < MAX_PRAGMA_DEFAULT),("Odd defaultt"));
00866 cwh_stmt_add_pragma(WN_PRAGMA_DEFAULT,FALSE,(ST_IDX) NULL,defaultt);
00867 }
00868
00869
00870 cwh_block_set_current(body);
00871
00872 cwh_directive_set_PU_flags(FALSE);
00873
00874 }
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886 extern void
00887 fei_parallel (INTPTR task_if_idx)
00888 {
00889 cwh_parallel (task_if_idx, 0, 0);
00890 }
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902 extern void
00903 fei_endparallel (void)
00904 {
00905 cwh_directive_pop_and_nowait(FALSE,FALSE);
00906 }
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918 extern void
00919 fei_pdo ( int sched_type,
00920 int ordered,
00921 int thread_count,
00922 int data_count,
00923 int onto_count,
00924 int reduction_count,
00925 int chunk_count )
00926 {
00927
00928 WN *body,*wn;
00929
00930 nested_do_descriptor.depth = task_nest_count;
00931 task_nest_count = 0;
00932 nested_do_descriptor.current = 0;
00933 nested_do_descriptor.explicit_end = TRUE;
00934 nested_do_descriptor.type = WN_PRAGMA_PDO_BEGIN;
00935 body = cwh_mp_region(WN_PRAGMA_PDO_BEGIN,thread_count,data_count,
00936 onto_count,reduction_count, chunk_count,0);
00937
00938 if (sched_type != WN_PRAGMA_SCHEDTYPE_UNKNOWN) {
00939 cwh_stmt_add_pragma(WN_PRAGMA_MPSCHEDTYPE, FALSE,(ST_IDX) NULL, sched_type);
00940 }
00941
00942 if (ordered) {
00943
00944 wn = WN_CreatePragma(WN_PRAGMA_ORDERED, (ST_IDX) NULL, 0, 0);
00945 cwh_block_append(wn);
00946 }
00947
00948
00949 cwh_block_set_current(body);
00950
00951 if (nested_do_descriptor.depth) {
00952 parallel_do_count =nested_do_descriptor.depth;
00953 } else {
00954 parallel_do_count = 1;
00955 }
00956
00957 cwh_directive_set_PU_flags(nested_do_descriptor.depth > 1);
00958
00959 }
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972 extern void
00973 fei_endpdo ( int nowait )
00974 {
00975 cwh_directive_pop_and_nowait(nowait,FALSE);
00976 }
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986 extern void
00987 fei_singleprocess( void )
00988 {
00989 WN *body;
00990
00991 body = cwh_mp_region(WN_PRAGMA_SINGLE_PROCESS_BEGIN,0,0,0,0,0,0);
00992
00993
00994 cwh_block_set_current(body);
00995
00996
00997
00998 cwh_directive_set_PU_flags(FALSE);
00999
01000 }
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010 extern void
01011 fei_endsingleprocess ( int nowait )
01012 {
01013 cwh_directive_pop_and_nowait(nowait,FALSE);
01014 }
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027 extern void
01028 fei_criticalsection ( int var_count )
01029 {
01030 WN *wn;
01031
01032 if (var_count==0) {
01033 cwh_stmt_add_pragma(WN_PRAGMA_CRITICAL_SECTION_BEGIN);
01034
01035 } else {
01036
01037 DevAssert((var_count==1),("too many critical section vars"));
01038 wn = cwh_expr_address(f_NONE);
01039 cwh_stmt_add_xpragma(WN_PRAGMA_CRITICAL_SECTION_BEGIN,FALSE,wn);
01040 }
01041
01042 wn = WN_CreateBarrier( FALSE, 0 );
01043 cwh_block_append(wn);
01044 }
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056 extern void
01057 fei_endcriticalsection ( void )
01058 {
01059 WN *wn;
01060 wn = WN_CreateBarrier( TRUE, 0 );
01061 cwh_block_append(wn);
01062 cwh_stmt_add_pragma(WN_PRAGMA_CRITICAL_SECTION_END);
01063 }
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075 extern void
01076 fei_barrier ( void )
01077 {
01078 WN *wn;
01079
01080 wn = WN_CreatePragma(WN_PRAGMA_BARRIER,(ST_IDX) NULL,0,0);
01081 cwh_directive_barrier_insert(wn, 0);
01082 }
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094 extern void
01095 fei_section ( void )
01096 {
01097 cwh_stmt_add_pragma(WN_PRAGMA_SECTION);
01098 }
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112 extern void
01113 fei_psection ( void )
01114 {
01115 WN *body;
01116 body = cwh_mp_region(WN_PRAGMA_PSECTION_BEGIN,0,0,0,0,0,0);
01117
01118 cwh_block_set_current(body);
01119 cwh_directive_set_PU_flags(FALSE);
01120 }
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132 extern void
01133 fei_endpsection ( int nowait )
01134 {
01135 cwh_directive_pop_and_nowait(nowait,FALSE);
01136 }
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150 extern void
01151 fei_copy_in ( int list_count )
01152 {
01153 int i;
01154 ST *st;
01155 WN *wn;
01156 BOOL create_xpragma;
01157 ITEM *split_st;
01158
01159 for(i=0; i< list_count; i++) {
01160 create_xpragma = TRUE;
01161 if (cwh_stk_get_class()==ST_item || cwh_stk_get_class() == ST_item_whole_array) {
01162
01163
01164 st = cwh_stk_pop_ST();
01165
01166 if (ST_sclass(st) == SCLASS_COMMON && ST_base_idx(st) == ST_st_idx(st)) {
01167 create_xpragma = FALSE;
01168
01169
01170
01171
01172 split_st=cwh_auxst_next_element(st,(ST_IDX) NULL,l_SPLITLIST);
01173
01174 if (split_st) {
01175 while(split_st) {
01176 cwh_stmt_add_pragma(WN_PRAGMA_COPYIN, FALSE, I_element(split_st));
01177 split_st=cwh_auxst_next_element(st,split_st,l_SPLITLIST);
01178 }
01179 } else {
01180 cwh_stmt_add_pragma(WN_PRAGMA_COPYIN, FALSE, st);
01181 }
01182 } else {
01183
01184 cwh_stk_push(st,ST_item);
01185 }
01186 }
01187
01188
01189
01190 if (create_xpragma) {
01191 wn = cwh_expr_address(f_NONE);
01192 cwh_stmt_add_xpragma(WN_PRAGMA_COPYIN,FALSE,wn);
01193 }
01194 }
01195 cwh_directive_set_PU_flags(FALSE);
01196
01197 }
01198
01199 void
01200 fei_dynamic ( int list_count )
01201 {
01202 int i;
01203 ST *st;
01204 for(i=0; i< list_count; i++) {
01205 st = cwh_stk_pop_ST();
01206 cwh_stmt_add_pragma(WN_PRAGMA_DYNAMIC, FALSE,st);
01207 }
01208 }
01209
01210 void
01211 fei_redistribute ( INTPTR array,
01212 int dim,
01213 int distribution,
01214 int cyclic_exists,
01215 int onto_exists )
01216 {
01217
01218 static WN *redistribute_block;
01219 static int onto_count;
01220 INT cyclic_constant;
01221 BOOL cyclic_is_constant;
01222 ST *st;
01223 TY_IDX ty;
01224 STB_pkt *p;
01225 WN *wn, *wn1, *wn_for_cyclic_expr=NULL;
01226 WN *lb,*ub,*s1;
01227 PREG_det preg;
01228
01229 p = cast_to_STB(array);
01230 st = (ST *)p->item;
01231 ty = ST_type(st);
01232
01233
01234 if (TY_kind(ty) == KIND_POINTER) {
01235 ty = TY_pointed(ty);
01236 }
01237
01238 if (dim==1) {
01239 onto_count=0;
01240 redistribute_block=WN_CreateBlock();
01241 }
01242
01243
01244
01245
01246 cyclic_constant = 1;
01247 cyclic_is_constant=TRUE;
01248 if (cyclic_exists) {
01249
01250 wn1 = cwh_expr_operand(NULL);
01251 if(WN_operator(wn1)==OPR_INTCONST) {
01252 cyclic_constant = WN_const_val(wn1);
01253 } else {
01254
01255 cyclic_is_constant=FALSE;
01256 wn_for_cyclic_expr = WN_CreateXpragma(WN_PRAGMA_REDISTRIBUTE, st, 1);
01257 WN_kid0(wn_for_cyclic_expr) = wn1;
01258 }
01259 }
01260
01261 lb = cwh_types_bound_WN(ty,dim-1,LOW);
01262 ub = cwh_types_bound_WN(ty,dim-1,UPPER);
01263 s1 = WN_Intconst(MTYPE_I4,1);
01264 wn = WN_CreateXpragma(WN_PRAGMA_REDISTRIBUTE, st, 1);
01265 WN_kid0(wn) = cwh_addr_extent(lb,ub,s1);
01266 WN_INSERT_BlockFirst(redistribute_block, wn);
01267 if (wn_for_cyclic_expr) {
01268
01269 WN_INSERT_BlockFirst(redistribute_block, wn_for_cyclic_expr);
01270 }
01271
01272
01273
01274 wn = WN_CreatePragma (WN_PRAGMA_REDISTRIBUTE,st,0,0);
01275 WN_pragma_index(wn) = TY_AR_ndims(Ty_Table[ty])-dim;
01276
01277 switch(distribution) {
01278 case Block_Dist:
01279 WN_pragma_distr_type(wn)=DISTRIBUTE_BLOCK;
01280 break;
01281 case Star_Dist:
01282 WN_pragma_distr_type(wn)=DISTRIBUTE_STAR;
01283 break;
01284 case Cyclic_Dist:
01285 if (cyclic_is_constant) {
01286 WN_pragma_distr_type(wn)=DISTRIBUTE_CYCLIC_CONST;
01287 WN_pragma_preg(wn) = cyclic_constant;
01288 } else {
01289 WN_pragma_distr_type(wn)=DISTRIBUTE_CYCLIC_EXPR;
01290 }
01291 break;
01292 default:
01293 DevAssert((0),("fei_redistribute: unexpected distribution"));
01294 }
01295 WN_INSERT_BlockFirst(redistribute_block, wn);
01296
01297
01298
01299 if (onto_exists) onto_count++;
01300
01301
01302
01303
01304
01305 if (dim==TY_AR_ndims(Ty_Table[ty])) {
01306
01307
01308 preg = cwh_auxst_distr_preg(st);
01309 wn = cwh_load_distribute_temp();
01310 wn = WN_CreateStid( OPC_I4STID, preg.preg, preg.preg_st, preg.preg_ty, wn);
01311 WN_INSERT_BlockLast(redistribute_block, wn);
01312
01313
01314 if (preg_for_distribute.preg==-1) {
01315 preg_for_distribute=cwh_preg_next_preg(MTYPE_I4, NULL, NULL);
01316 }
01317 wn = cwh_load_distribute_temp();
01318 wn = WN_CreateStid( OPC_I4STID, preg_for_distribute.preg,
01319 preg_for_distribute.preg_st, preg_for_distribute.preg_ty, wn);
01320 WN_INSERT_BlockLast(redistribute_block, wn);
01321
01322
01323 while(onto_count--) {
01324 wn1 = cwh_expr_operand(NULL);
01325 wn = WN_CreateXpragma(WN_PRAGMA_ONTO,st,1);
01326 WN_kid0(wn) = wn1;
01327 WN_INSERT_BlockLast(redistribute_block, wn);
01328 }
01329
01330 cwh_block_append(redistribute_block);
01331 cwh_directive_set_LNO_flags();
01332 }
01333 }
01334
01335 static void
01336 cwh_reorder ( int expressions, WN_PRAGMA_ID wn_pragma_id )
01337 {
01338 int *order;
01339 ST **st_list;
01340 int i;
01341 WN *wn;
01342
01343 order= (int *) malloc(sizeof(int)*expressions);
01344 st_list= (ST **)malloc(sizeof(ST *)*expressions);
01345
01346
01347
01348 for(i=expressions; i> 0; i--) {
01349 wn = cwh_expr_operand(NULL);
01350 DevAssert((WN_operator(wn)==OPR_INTCONST),("cwh_reorder: expected constant"));
01351 DevAssert((WN_const_val(wn)<=expressions),("cwh_reorder: constant out of bounds"));
01352 order[WN_const_val(wn)-1]=i;
01353 }
01354
01355
01356 for(i=expressions-1; i>=0; i--) {
01357 st_list[i] = cwh_stk_pop_ST();
01358 }
01359
01360
01361 for(i=0; i<expressions; i++) {
01362 cwh_stmt_add_pragma(wn_pragma_id, FALSE,st_list[i], order[i],i+1);
01363 }
01364 free(order);
01365 free(st_list);
01366 }
01367
01368 void fei_interchange ( int expressions )
01369 {
01370 cwh_reorder(expressions,WN_PRAGMA_INTERCHANGE);
01371 }
01372
01373
01374 void fei_blockable ( int expressions )
01375 {
01376 cwh_reorder(expressions,WN_PRAGMA_BLOCKABLE);
01377 }
01378
01379
01380
01381
01382
01383
01384
01385 void fei_fission ( void )
01386 {
01387 WN *wn;
01388 wn = cwh_expr_operand(NULL);
01389 DevAssert((WN_operator(wn)==OPR_INTCONST),("fei_fission: expected constant"));
01390 cwh_stmt_add_pragma(WN_PRAGMA_FISSION,FALSE,(ST_IDX) NULL,WN_const_val(wn),0);
01391
01392 }
01393 #ifdef KEY
01394
01395
01396
01397
01398
01399
01400 void fei_forall ( void )
01401 {
01402 WN *wn;
01403 cwh_stmt_add_pragma(WN_PRAGMA_FORALL,FALSE,(ST_IDX) NULL,0,0);
01404
01405 }
01406 #endif
01407
01408
01409
01410
01411
01412
01413 extern void
01414 fei_flush(int list_count)
01415 {
01416 WN *sync;
01417
01418 sync = WN_Create_Intrinsic(OPC_VINTRINSIC_CALL,INTRN_SYNCHRONIZE,0,NULL);
01419 cwh_directive_barrier_insert(sync,list_count) ;
01420 }
01421
01422
01423
01424
01425
01426
01427
01428 void
01429 fei_fuse (int level)
01430 {
01431 WN *wn;
01432 wn = cwh_expr_operand(NULL);
01433 DevAssert((WN_operator(wn)==OPR_INTCONST),("fei_fuse: expected constant"));
01434 cwh_stmt_add_pragma(WN_PRAGMA_FUSE,FALSE,(ST_IDX) NULL,WN_const_val(wn), level);
01435 }
01436
01437
01438
01439
01440
01441
01442
01443 void
01444 fei_assert ( int assertion, int list_count )
01445 {
01446
01447
01448
01449
01450
01451 WN *arg;
01452
01453 DevAssert((map_asserts[assertion].fe_enum == assertion),
01454 ("map_asserts table bad"));
01455
01456 switch(assertion) {
01457 case MIPS_ASSERT_CONCURRENTCALL:
01458 case MIPS_ASSERT_NOCONCURRENTCALL:
01459 case MIPS_ASSERT_NOEQUIVALENCEHAZARD:
01460 case MIPS_ASSERT_BOUNDSVIOLATIONS:
01461 case MIPS_ASSERT_NOBOUNDSVIOLATIONS:
01462 case MIPS_ASSERT_EQUIVALENCEHAZARD:
01463 case MIPS_ASSERT_TEMPORARIESFORCONSTANTARGUMENTS:
01464 case MIPS_ASSERT_NOTEMPORARIESFORCONSTANTARGUMENTS:
01465 case MIPS_ASSERT_BENIGN:
01466 case MIPS_ASSERT_NOINTERCHANGE:
01467 case MIPS_ASSERT_USECOMPRESS:
01468 case MIPS_ASSERT_USEEXPAND:
01469 case MIPS_ASSERT_USECONTROLLEDSTORE:
01470 case MIPS_ASSERT_USEGATHER:
01471 case MIPS_ASSERT_USESCATTER:
01472 cwh_stmt_add_pragma(map_asserts[assertion].wn_pragma_id);
01473 break;
01474
01475 case MIPS_ASSERT_ARGUMENTALIASING:
01476 Set_PU_args_aliased (Pu_Table[ST_pu(Procedure_ST)]);
01477 cwh_stmt_add_pragma(map_asserts[assertion].wn_pragma_id);
01478 break;
01479
01480 case MIPS_ASSERT_NOARGUMENTALIASING:
01481 Clear_PU_args_aliased (Pu_Table[ST_pu(Procedure_ST)]);
01482 cwh_stmt_add_pragma(map_asserts[assertion].wn_pragma_id);
01483 break;
01484
01485 case MIPS_ASSERT_DO:
01486 case MIPS_ASSERT_DOPREFER:
01487 while (list_count) {
01488 arg = cwh_expr_operand(NULL);
01489 cwh_stmt_add_pragma(map_asserts[assertion].wn_pragma_id,
01490 FALSE,
01491 (ST_IDX) NULL,
01492 WN_const_val(arg));
01493 list_count--;
01494 }
01495 break;
01496
01497 case MIPS_ASSERT_PERMUTATION:
01498 while (list_count) {
01499 arg = cwh_expr_address(f_NONE);
01500 cwh_stmt_add_pragma(map_asserts[assertion].wn_pragma_id,
01501 FALSE,
01502 WN_st(arg),
01503 WN_load_offset(arg));
01504 list_count--;
01505 }
01506 break;
01507
01508 default:
01509 DevWarn("fei_assert: assertion not implemented");
01510 while (list_count) {
01511 cwh_stk_pop_whatever();
01512 list_count--;
01513 }
01514 break;
01515 }
01516 }
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527 extern void
01528 fei_fill_symbol(INT32 count, INT32 C_value )
01529 {
01530 cwh_directive_fill_align(count,C_value,WN_PRAGMA_FILL);
01531 }
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543 extern void
01544 fei_align_symbol (INT32 count,INT32 C_value )
01545 {
01546 cwh_directive_fill_align(count,C_value,WN_PRAGMA_ALIGN);
01547 }
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558 static void
01559 cwh_directive_fill_align(INT32 count,INT32 C_value, WN_PRAGMA_ID pragma )
01560 {
01561 ST *st;
01562 PU & pu = Pu_Table[ST_pu(Procedure_ST)];
01563 BOOL pu_is_l2 = (CURRENT_SYMTAB == 1+GLOBAL_SYMTAB) ;
01564
01565 while (count-- > 0) {
01566
01567 st = cwh_stk_pop_ST();
01568 Set_ST_is_fill_align(st);
01569
01570 if ((ST_level(st) != GLOBAL_SYMTAB) ||
01571 ((ST_level(st) == GLOBAL_SYMTAB) && pu_is_l2)) {
01572
01573
01574
01575
01576 Set_PU_needs_fill_align_lowering (pu);
01577 }
01578 cwh_stmt_add_pragma(pragma,FALSE,st,0,C_value);
01579 }
01580 }
01581
01582 void
01583 fei_unroll( void )
01584 {
01585 WN *wn1;
01586 wn1 = cwh_expr_operand(NULL);
01587 DevAssert((WN_operator(wn1)==OPR_INTCONST),("fei_unroll: expected constant"));
01588
01589 if (WN_const_val(wn1) != 0) {
01590 cwh_stmt_add_pragma(WN_PRAGMA_UNROLL, FALSE,(ST_IDX) NULL, WN_const_val(wn1), -1);
01591 }
01592 WN_Delete(wn1);
01593 }
01594
01595 void
01596 fei_page_place( void )
01597 {
01598
01599
01600 WN *wn1,*wn2,*wn3;
01601 wn3 = cwh_expr_operand(NULL);
01602 wn2 = cwh_expr_operand(NULL);
01603 wn1 = cwh_expr_address(f_NONE);
01604
01605 cwh_stmt_add_xpragma(WN_PRAGMA_PAGE_PLACE,FALSE,wn1);
01606 cwh_stmt_add_xpragma(WN_PRAGMA_PAGE_PLACE,FALSE,wn2);
01607 cwh_stmt_add_xpragma(WN_PRAGMA_PAGE_PLACE,FALSE,wn3);
01608
01609 cwh_directive_set_LNO_flags();
01610
01611 }
01612
01613 void
01614 fei_prefetch_ref_disable ( INTPTR array,
01615 int size )
01616 {
01617 STB_pkt *p;
01618 ST *st;
01619
01620 p = cast_to_STB(array);
01621 DevAssert((p->form == is_ST),("Odd object ref"));
01622 st = (ST *)p->item;
01623 if (size==-1) size=0;
01624 cwh_stmt_add_pragma(WN_PRAGMA_PREFETCH_REF_DISABLE,FALSE,st,0,size);
01625 }
01626
01627
01628 void
01629 fei_prefetch_ref ( int stride,
01630 int level,
01631 int kind,
01632 int size )
01633 {
01634 INT lev1,lev2;
01635 INT str1,str2,itemp;
01636 WN * wn;
01637 WN * t;
01638
01639
01640 if (size == -1) size = 0;
01641 cwh_stmt_add_pragma(WN_PRAGMA_PREFETCH_REF,
01642 FALSE,
01643 (ST_IDX) NULL,
01644 0,
01645 size);
01646
01647
01648 if (level == 2) {
01649 t = cwh_expr_operand(NULL);
01650 lev2 = WN_const_val(t);
01651 t = cwh_expr_operand(NULL);
01652 lev1 = WN_const_val(t);
01653 } else if (level == 1) {
01654 t = cwh_expr_operand(NULL);
01655 lev1 = WN_const_val(t);
01656 lev2 = 0;
01657 } else {
01658 lev1 = 2;
01659 lev2 = 0;
01660 }
01661
01662
01663 if (stride == 2) {
01664 t = cwh_expr_operand(NULL);
01665 str2 = WN_const_val(t);
01666 t = cwh_expr_operand(NULL);
01667 str1 = WN_const_val(t);
01668 } else if (stride == 1) {
01669 t = cwh_expr_operand(NULL);
01670 str1 = WN_const_val(t);
01671 str2 = 0;
01672 } else {
01673 str1 = 1;
01674 str2 = 0;
01675 }
01676
01677 if (lev1 == 2) {
01678
01679 itemp = str1;
01680 str1 = str2;
01681 str2 = itemp;
01682 }
01683
01684
01685 wn = cwh_expr_address(f_NONE);
01686 wn = WN_CreatePrefetch ( 0, 0, wn );
01687 WN_pf_set_confidence(wn, 3);
01688 WN_pf_set_manual(wn);
01689 if (kind == 0) {
01690 WN_pf_set_read(wn);
01691 } else {
01692 WN_pf_set_write(wn);
01693 }
01694
01695 WN_pf_set_stride_1L(wn, str1);
01696 WN_pf_set_stride_2L(wn, str2);
01697
01698 cwh_block_append(wn);
01699 }
01700
01701
01702 void
01703 fei_prefetch(int n1,
01704 int n2 )
01705 {
01706 cwh_stmt_add_pragma(WN_PRAGMA_PREFETCH,FALSE,(ST_IDX) NULL,n1,n2);
01707 }
01708
01709 #ifdef KEY
01710 static ST *cwh_create_str_st(char *string);
01711
01712 void
01713 fei_options(char *n1)
01714 {
01715 ST *st = cwh_create_str_st(n1);
01716 cwh_stmt_add_options_pragma(st);
01717 }
01718 #endif
01719
01720 void
01721 fei_prefetch_manual( int n )
01722 {
01723 cwh_stmt_add_pragma(WN_PRAGMA_PREFETCH_MANUAL,FALSE,(ST_IDX) NULL,n,0);
01724 }
01725
01726 void
01727 fei_regionbegin ( void )
01728 {
01729 WN *body = cwh_region(REGION_KIND_PRAGMA);
01730 cwh_block_set_current(body);
01731 }
01732
01733 void
01734 fei_regionend ( void )
01735 {
01736
01737 (void) cwh_block_pop_region();
01738 }
01739
01740
01741 void
01742 fei_section_gp ( int list_count )
01743 {
01744 int i;
01745 ST *st;
01746 for (i=0; i<list_count; i++) {
01747 st = cwh_stk_pop_ST();
01748
01749 if (Has_Base_Block(st) && (ST_sclass(ST_base(st))==SCLASS_COMMON)) {
01750
01751 st = ST_base(st);
01752 }
01753 Set_ST_gprel(st);
01754 }
01755 }
01756
01757 void
01758 fei_section_nongp ( int list_count )
01759 {
01760 int i;
01761 ST *st;
01762 for (i=0; i<list_count; i++) {
01763 st = cwh_stk_pop_ST();
01764
01765 if (Has_Base_Block(st) && (ST_sclass(ST_base(st))==SCLASS_COMMON)) {
01766
01767 st = ST_base(st);
01768 }
01769 Set_ST_not_gprel(st);
01770 }
01771 }
01772
01773 void
01774 fei_blocking_size ( void )
01775 {
01776 WN *wn1,*wn2;
01777 wn1 = cwh_expr_operand(NULL);
01778 wn2 = cwh_expr_operand(NULL);
01779 DevAssert((WN_operator(wn1)==OPR_INTCONST),("fei_blocking_size: expected constant"));
01780 DevAssert((WN_operator(wn2)==OPR_INTCONST),("fei_blocking_size: expected constant"));
01781
01782 cwh_stmt_add_pragma(WN_PRAGMA_BLOCKING_SIZE,
01783 FALSE,
01784 (ST_IDX) NULL,
01785 WN_const_val(wn2),
01786 WN_const_val(wn1));
01787
01788 }
01789
01790 void
01791 fei_purple_conditional ( void )
01792 {
01793 WN *save, *wn1;
01794 save = cwh_block_set_region_pragmas();
01795 wn1 = cwh_expr_operand(NULL);
01796 cwh_stmt_add_xpragma(WN_PRAGMA_PURPLE_CONDITIONAL,FALSE,wn1);
01797 cwh_block_set_current(save);
01798
01799 }
01800
01801 void
01802 fei_purple_unconditional ( void )
01803 {
01804 WN *save ;
01805 save = cwh_block_set_region_pragmas();
01806 cwh_stmt_add_pragma(WN_PRAGMA_PURPLE_UNCONDITIONAL);
01807 cwh_block_set_current(save);
01808 }
01809
01810 void
01811 fei_opaque ( void )
01812 {
01813 WN *save ;
01814 save = cwh_block_set_region_pragmas();
01815 cwh_stmt_add_pragma(WN_PRAGMA_OPAQUE);
01816 cwh_block_set_current(save);
01817 }
01818
01819 void
01820 fei_concurrentize ( int state )
01821 {
01822 WN_PRAGMA_ID id;
01823
01824 if (state) {
01825 id = WN_PRAGMA_KAP_CONCURRENTIZE ;
01826 }
01827 else {
01828 id = WN_PRAGMA_KAP_NOCONCURRENTIZE;
01829 }
01830 cwh_stmt_add_pragma(id);
01831 }
01832
01833 int
01834 fei_par_case ( INT32 task_x, INT32 lineno )
01835 {
01836 WN *body;
01837
01838 if (task_x == 0) {
01839 body = cwh_mp_region(WN_PRAGMA_PSECTION_BEGIN,0,0,0,0,0,0);
01840
01841
01842 cwh_block_set_current(body);
01843
01844 cwh_directive_set_PU_flags(FALSE);
01845
01846 } else {
01847 cwh_stmt_add_pragma(WN_PRAGMA_SECTION);
01848 }
01849 return (1);
01850 }
01851
01852
01853 void
01854 fei_par_endcase ( INT32 task_x, INT32 lineno )
01855 {
01856 (void) cwh_block_pop_region();
01857 }
01858
01859
01860
01861
01862 int
01863 fei_guard ( INT32 guard_num, INT32 lineno )
01864 {
01865 WN *wn;
01866
01867 cwh_stmt_add_pragma(WN_PRAGMA_CRITICAL_SECTION_BEGIN);
01868
01869 wn = WN_CreateBarrier (FALSE,0);
01870 cwh_block_append(wn);
01871 return (1);
01872 }
01873
01874 void
01875 fei_endguard (INT32 task_x, INT32 guard_num, INT32 lineno )
01876 {
01877 WN *wn;
01878 wn = WN_CreateBarrier (TRUE,0);
01879 cwh_block_append(wn);
01880
01881 cwh_stmt_add_pragma(WN_PRAGMA_CRITICAL_SECTION_END);
01882 }
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892 void
01893 fei_parallelsections_open_mp(INTPTR task_if_idx,
01894 INTPTR task_num_threads_idx,
01895 int defaultt)
01896 {
01897 WN *body;
01898
01899 task_nest_count = 0;
01900 body = cwh_mp_region(WN_PRAGMA_PARALLEL_SECTIONS,0,0,0,0,0,1);
01901
01902
01903
01904 cwh_directive_load_value_pragma(task_if_idx,WN_PRAGMA_IF,TRUE);
01905 cwh_directive_load_value_pragma(task_num_threads_idx, WN_PRAGMA_NUMTHREADS, TRUE);
01906
01907 if (defaultt) {
01908
01909 DevAssert((defaultt > 0 && defaultt < MAX_PRAGMA_DEFAULT),("Odd defaultt"));
01910 cwh_stmt_add_pragma(WN_PRAGMA_DEFAULT,TRUE,(ST_IDX) NULL,defaultt);
01911 }
01912
01913
01914
01915 cwh_block_set_current(body);
01916
01917 cwh_directive_set_PU_flags(FALSE);
01918 }
01919
01920
01921
01922
01923
01924
01925
01926
01927 void
01928 fei_paralleldo_open_mp (INTPTR task_if_idx,
01929 INTPTR task_num_threads_idx,
01930 int defaultt,
01931 int ordered,
01932 int scheduletype,
01933 INTPTR schedulechunk,
01934 int threadcount,
01935 int datacount,
01936 int ontocount)
01937 {
01938 WN *body;
01939
01940 nested_do_descriptor.depth = task_nest_count;
01941 task_nest_count = 0;
01942 nested_do_descriptor.current = 0;
01943 nested_do_descriptor.explicit_end = TRUE;
01944 nested_do_descriptor.type = WN_PRAGMA_PARALLEL_DO;
01945 body = cwh_mp_region(WN_PRAGMA_PARALLEL_DO,threadcount,datacount,ontocount,
01946 0,0,1);
01947
01948
01949
01950 cwh_directive_load_value_pragma(task_if_idx,WN_PRAGMA_IF,TRUE);
01951 cwh_directive_load_value_pragma(task_num_threads_idx, WN_PRAGMA_NUMTHREADS, TRUE);
01952
01953 if (defaultt) {
01954
01955 DevAssert((defaultt > 0 && defaultt < MAX_PRAGMA_DEFAULT),("Odd defaultt"));
01956 cwh_stmt_add_pragma(WN_PRAGMA_DEFAULT,TRUE,(ST_IDX) NULL,defaultt);
01957 }
01958
01959 if (scheduletype != WN_PRAGMA_SCHEDTYPE_UNKNOWN) {
01960
01961 cwh_stmt_add_pragma(WN_PRAGMA_MPSCHEDTYPE, TRUE, (ST_IDX) NULL, scheduletype);
01962 cwh_directive_load_value_pragma(schedulechunk,WN_PRAGMA_CHUNKSIZE,TRUE);
01963 }
01964
01965
01966
01967 if (ordered) {
01968 cwh_stmt_add_pragma(WN_PRAGMA_ORDERED,TRUE);
01969 }
01970
01971
01972 cwh_block_set_current(body);
01973
01974
01975 if (nested_do_descriptor.depth) {
01976 parallel_do_count =nested_do_descriptor.depth;
01977 } else {
01978 parallel_do_count = 1;
01979 }
01980
01981
01982
01983 cwh_directive_set_PU_flags(nested_do_descriptor.depth > 1);
01984 }
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994 void
01995 fei_single_open_mp (void)
01996 {
01997 WN *body;
01998
01999 body = cwh_mp_region(WN_PRAGMA_SINGLE_PROCESS_BEGIN,0,0,0,0,0,1);
02000
02001 cwh_block_set_current(body);
02002
02003 cwh_directive_set_PU_flags(FALSE);
02004 }
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014 void
02015 fei_sections_open_mp(void)
02016 {
02017 WN *body;
02018 body = cwh_mp_region(WN_PRAGMA_PSECTION_BEGIN,0,0,0,0,0,1);
02019
02020 cwh_block_set_current(body);
02021
02022 cwh_directive_set_PU_flags(FALSE);
02023
02024 }
02025
02026
02027
02028
02029
02030
02031
02032
02033 void
02034 fei_do_open_mp (int ordered,
02035 int scheduletype,
02036 INTPTR schedulechunk,
02037 int threadcount,
02038 int datacount,
02039 int ontocount)
02040 {
02041 WN *body;
02042
02043 nested_do_descriptor.depth = task_nest_count;
02044 task_nest_count = 0;
02045 nested_do_descriptor.current = 0;
02046 nested_do_descriptor.explicit_end = TRUE;
02047 nested_do_descriptor.type = WN_PRAGMA_PDO_BEGIN;
02048 body = cwh_mp_region(WN_PRAGMA_PDO_BEGIN,threadcount,datacount,ontocount,
02049 0,0,1);
02050
02051 if (scheduletype != WN_PRAGMA_SCHEDTYPE_UNKNOWN) {
02052
02053 cwh_stmt_add_pragma(WN_PRAGMA_MPSCHEDTYPE, TRUE,(ST_IDX) NULL, scheduletype);
02054 cwh_directive_load_value_pragma(schedulechunk,WN_PRAGMA_CHUNKSIZE,TRUE);
02055 }
02056
02057 if (ordered) {
02058 cwh_stmt_add_pragma(WN_PRAGMA_ORDERED, TRUE);
02059 }
02060
02061
02062 cwh_block_set_current(body);
02063
02064
02065 if (nested_do_descriptor.depth) {
02066 parallel_do_count =nested_do_descriptor.depth;
02067 } else {
02068 parallel_do_count = 1;
02069 }
02070
02071 cwh_directive_set_PU_flags(nested_do_descriptor.depth > 1);
02072 }
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082 void
02083 fei_workshare_open_mp (void)
02084 {
02085 WN *body;
02086
02087 body = cwh_mp_region(WN_PRAGMA_PWORKSHARE_BEGIN,0,0,0,0,0,1);
02088
02089 cwh_block_set_current(body);
02090
02091 cwh_directive_set_PU_flags(FALSE);
02092 }
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103 extern void
02104 fei_endworkshare_open_mp ( INT32 nowait )
02105 {
02106 cwh_directive_pop_and_nowait(nowait,TRUE);
02107 }
02108
02109
02110
02111
02112
02113
02114
02115 extern void
02116 fei_endparallelworkshare_open_mp ( void )
02117 {
02118 cwh_directive_pop_and_nowait(FALSE,TRUE);
02119 }
02120
02121
02122
02123
02124
02125
02126
02127 void
02128 fei_parallelworkshare_open_mp(INTPTR task_if_idx,
02129 INTPTR task_num_threads_idx,
02130 INT32 defaultt)
02131 {
02132 WN *body;
02133
02134 task_nest_count = 0;
02135 body = cwh_mp_region(WN_PRAGMA_PARALLEL_WORKSHARE,0,0,0,0,0,TRUE);
02136
02137
02138
02139 cwh_directive_load_value_pragma(task_if_idx,WN_PRAGMA_IF, TRUE);
02140 cwh_directive_load_value_pragma(task_num_threads_idx, WN_PRAGMA_NUMTHREADS, TRUE);
02141
02142 if (defaultt) {
02143
02144 DevAssert((defaultt > 0 && defaultt < MAX_PRAGMA_DEFAULT),("Odd defaultt"));
02145 cwh_stmt_add_pragma(WN_PRAGMA_DEFAULT,TRUE,(ST_IDX) NULL,defaultt);
02146 }
02147
02148
02149 cwh_block_set_current(body);
02150
02151 cwh_directive_set_PU_flags(FALSE);
02152 }
02153
02154
02155
02156
02157
02158
02159
02160 void
02161 fei_parallel_open_mp(INTPTR task_if_idx,
02162 INTPTR task_num_threads_idx,
02163 int defaultt)
02164 {
02165 WN *body;
02166
02167 task_nest_count = 0;
02168 body = cwh_mp_region(WN_PRAGMA_PARALLEL_BEGIN,0,0,0,0,0,TRUE);
02169
02170
02171
02172 cwh_directive_load_value_pragma(task_if_idx,WN_PRAGMA_IF, TRUE);
02173 cwh_directive_load_value_pragma(task_num_threads_idx, WN_PRAGMA_NUMTHREADS, TRUE);
02174
02175 if (defaultt) {
02176
02177 DevAssert((defaultt > 0 && defaultt < MAX_PRAGMA_DEFAULT),("Odd defaultt"));
02178 cwh_stmt_add_pragma(WN_PRAGMA_DEFAULT,FALSE,(ST_IDX) NULL,defaultt);
02179 }
02180
02181
02182 cwh_block_set_current(body);
02183
02184 cwh_directive_set_PU_flags(FALSE);
02185 }
02186
02187
02188
02189
02190
02191
02192
02193
02194 static ST *
02195 cwh_create_str_st(char *string)
02196 {
02197 TCON tcon;
02198 TY_IDX ty;
02199 ST *st;
02200
02201 tcon = Host_To_Targ_String ( MTYPE_STRING,
02202 string,
02203 strlen(string));
02204 ty = Be_Type_Tbl(MTYPE_I1);
02205 st = Gen_String_Sym ( &tcon, ty, FALSE );
02206
02207 return (st);
02208 }
02209
02210
02211
02212
02213
02214
02215
02216 extern void
02217 fei_critical_open_mp ( char *name )
02218 {
02219 WN *wn;
02220 ST *st = NULL;
02221
02222 if (name != NULL)
02223 st = cwh_create_str_st(name);
02224
02225 cwh_stmt_add_pragma(WN_PRAGMA_CRITICAL_SECTION_BEGIN, TRUE, st);
02226
02227 wn = WN_CreateBarrier( FALSE, 0 );
02228 WN_set_pragma_omp(wn);
02229 cwh_block_append(wn);
02230
02231 cwh_directive_set_PU_flags(FALSE);
02232 }
02233
02234
02235
02236
02237
02238
02239
02240 extern void
02241 fei_endcritical_open_mp ( char *name )
02242 {
02243 WN *wn;
02244 ST *st;
02245
02246 wn = WN_CreateBarrier( TRUE, 0 );
02247 WN_set_pragma_omp(wn);
02248 cwh_block_append(wn);
02249
02250 st = NULL;
02251
02252 if (name != NULL)
02253 st = cwh_create_str_st(name);
02254
02255 cwh_stmt_add_pragma(WN_PRAGMA_CRITICAL_SECTION_END, TRUE,st);
02256 }
02257
02258
02259
02260
02261
02262
02263
02264 extern void
02265 fei_barrier_open_mp ( void )
02266 {
02267 WN *wn;
02268
02269 wn = WN_CreatePragma(WN_PRAGMA_BARRIER,(ST_IDX) NULL,0,0);
02270 WN_set_pragma_omp(wn);
02271 cwh_directive_barrier_insert(wn, 0);
02272 }
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284 extern void
02285 fei_section_open_mp ( void )
02286 {
02287 cwh_stmt_add_pragma(WN_PRAGMA_SECTION,TRUE);
02288 }
02289
02290
02291
02292
02293
02294
02295
02296
02297 extern void
02298 fei_master_open_mp ( void )
02299 {
02300 WN *body;
02301
02302 body = cwh_mp_region(WN_PRAGMA_MASTER_BEGIN,0,0,0,0,0,1);
02303
02304
02305 cwh_block_set_current(body);
02306
02307
02308
02309 cwh_directive_set_PU_flags(FALSE);
02310 }
02311
02312
02313
02314
02315
02316
02317
02318
02319 extern void
02320 fei_endmaster_open_mp ( void )
02321 {
02322 cwh_directive_pop_and_nowait(FALSE,TRUE);
02323 }
02324
02325
02326
02327
02328
02329
02330
02331
02332 extern void
02333 fei_ordered_open_mp ( void )
02334 {
02335 WN *wn;
02336
02337 cwh_stmt_add_pragma(WN_PRAGMA_ORDERED_BEGIN,TRUE);
02338
02339 wn = WN_CreateBarrier( FALSE, 0 );
02340 WN_set_pragma_omp(wn);
02341 cwh_block_append(wn);
02342 }
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352 extern void
02353 fei_endsingle_open_mp ( int nowait )
02354 {
02355 WN *region, *wn ;
02356 WN * pragma_blk ;
02357 WN * old_blk ;
02358 WN_PRAGMA_ID p ;
02359
02360 region = cwh_block_pop_region();
02361
02362 pragma_blk = WN_region_pragmas(region);
02363 old_blk = cwh_block_exchange_current(pragma_blk);
02364
02365 while (task_var_count) {
02366 wn = cwh_stk_pop_WN();
02367
02368 #if 0
02369 if ((WN_operator(wn) == OPR_PRAGMA) &&
02370 (WN_pragma(wn) == WN_PRAGMA_COPYPRIVATE))
02371 #else
02372 if (WN_operator(wn) == OPR_PRAGMA)
02373 #endif
02374 cwh_block_append(wn);
02375 task_var_count--;
02376 }
02377
02378 if (nowait)
02379 p = WN_PRAGMA_NOWAIT;
02380 else
02381 p = WN_PRAGMA_END_MARKER;
02382
02383 wn = WN_CreatePragma (p, (ST_IDX) NULL, 0, 0);
02384
02385 WN_set_pragma_omp(wn);
02386 cwh_block_append(wn);
02387
02388 cwh_block_set_current(old_blk);
02389 }
02390
02391
02392
02393
02394
02395
02396
02397
02398
02399
02400 extern void
02401 fei_enddo_open_mp ( int nowait )
02402 {
02403 cwh_directive_pop_and_nowait(nowait,TRUE);
02404 }
02405
02406
02407
02408
02409
02410
02411
02412
02413
02414
02415 extern void
02416 fei_endsections_open_mp ( int nowait )
02417 {
02418 cwh_directive_pop_and_nowait(nowait,TRUE);
02419 }
02420
02421
02422
02423
02424
02425
02426
02427
02428 extern void
02429 fei_endordered_open_mp ( void )
02430 {
02431 WN *wn;
02432
02433 wn = WN_CreateBarrier( TRUE, 0 );
02434 WN_set_pragma_omp(wn);
02435 cwh_block_append(wn);
02436
02437 cwh_stmt_add_pragma(WN_PRAGMA_ORDERED_END,TRUE);
02438 }
02439
02440
02441
02442
02443
02444
02445
02446
02447 extern void
02448 fei_endparalleldo_open_mp ( void )
02449 {
02450 (void) cwh_block_pop_region();
02451 }
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463 extern void
02464 fei_endparallel_open_mp ( void )
02465 {
02466 cwh_directive_pop_and_nowait(FALSE,TRUE);
02467 }
02468
02469
02470
02471
02472
02473
02474
02475
02476 extern void
02477 fei_endparallelsections_open_mp( void )
02478 {
02479 cwh_directive_pop_and_nowait(FALSE,TRUE);
02480 }
02481
02482
02483
02484
02485
02486
02487
02488
02489 extern void
02490 fei_flush_open_mp(int list_count)
02491 {
02492 WN *sync;
02493
02494 sync = WN_Create_Intrinsic(OPC_VINTRINSIC_CALL,INTRN_SYNCHRONIZE,0,NULL);
02495 cwh_directive_barrier_insert(sync,list_count) ;
02496 }
02497
02498
02499
02500
02501
02502
02503
02504 extern void
02505 fei_atomic_open_mp(void)
02506 {
02507 cwh_stmt_add_pragma(WN_PRAGMA_ATOMIC,TRUE);
02508 cwh_directive_set_PU_flags(FALSE);
02509 }
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521 extern void
02522 cwh_directive_add_do_loop_directive(WN *directive)
02523 {
02524 if (!do_loop_directive_block) {
02525 do_loop_directive_block = WN_CreateBlock();
02526 }
02527 WN_INSERT_BlockLast(do_loop_directive_block,directive);
02528 }
02529
02530
02531
02532
02533
02534
02535
02536
02537
02538
02539
02540 extern void
02541 cwh_directive_insert_do_loop_directives(void)
02542 {
02543 if (do_loop_directive_block) {
02544 cwh_block_append(do_loop_directive_block);
02545 do_loop_directive_block = NULL;
02546 }
02547 }
02548
02549
02550
02551
02552
02553
02554
02555
02556
02557
02558
02559
02560
02561
02562 extern void
02563 cwh_directive_barrier_insert(WN *ins, int args)
02564 {
02565 WN *wn1;
02566 WN *wn2;
02567 ST *st;
02568
02569 wn1 = WN_CreateBarrier(TRUE, args);
02570 wn2 = WN_CreateBarrier(FALSE, args);
02571 if (args) {
02572 while(args--) {
02573
02574 st = cwh_stk_pop_ST();
02575
02576
02577
02578
02579
02580 if (Barrier_Lvalues_On) {
02581
02582 WN_kid(wn1,args) = cwh_addr_address_ST(st, 0, 0);
02583 WN_kid(wn2,args) = cwh_addr_address_ST(st, 0, 0);
02584 }
02585 else {
02586 WN_kid(wn1,args) = WN_CreateIdname(0,st);
02587 WN_kid(wn2,args) = WN_CreateIdname(0,st);
02588 }
02589 }
02590 }
02591 cwh_block_append(wn1);
02592 if (ins != NULL)
02593 cwh_block_append(ins);
02594 cwh_block_append(wn2);
02595 }
02596
02597
02598
02599
02600
02601
02602
02603
02604
02605
02606 static void
02607 cwh_directive_pragma_to_region(WN * prag, WN * region)
02608 {
02609 WN * pr_blk ;
02610 WN * ol_blk ;
02611
02612 pr_blk = WN_region_pragmas(region);
02613 ol_blk = cwh_block_exchange_current(pr_blk);
02614 cwh_block_append(prag);
02615
02616 cwh_block_set_current(ol_blk);
02617 }
02618
02619
02620
02621
02622
02623
02624
02625
02626
02627
02628
02629
02630 #ifdef KEY
02631 extern void
02632 cwh_directive_set_PU_flags(BOOL nested)
02633 #else
02634 static void
02635 cwh_directive_set_PU_flags(BOOL nested)
02636 #endif
02637 {
02638 Set_PU_has_mp (Get_Current_PU ());
02639 Set_FILE_INFO_has_mp (File_info);
02640 Set_PU_uplevel (Get_Current_PU ());
02641
02642 if (nested)
02643 cwh_directive_set_LNO_flags() ;
02644 }
02645
02646
02647
02648
02649
02650
02651
02652
02653
02654 static void
02655 cwh_directive_set_LNO_flags(void)
02656 {
02657 Set_PU_mp_needs_lno (Get_Current_PU());
02658 Set_FILE_INFO_needs_lno (File_info);
02659 }
02660
02661
02662
02663
02664
02665
02666
02667
02668
02669
02670
02671 static void
02672 cwh_directive_pop_and_nowait( BOOL nowait, BOOL is_omp)
02673 {
02674 WN *region, *wn ;
02675 WN_PRAGMA_ID p ;
02676
02677 region = cwh_block_pop_region();
02678
02679 if (nowait)
02680 p = WN_PRAGMA_NOWAIT;
02681 else
02682 p = WN_PRAGMA_END_MARKER;
02683
02684 wn = WN_CreatePragma (p, (ST_IDX) NULL, 0, 0);
02685
02686 if (is_omp)
02687 WN_set_pragma_omp(wn);
02688
02689 cwh_directive_pragma_to_region(wn,region);
02690 }
02691
02692
02693
02694
02695
02696
02697
02698
02699
02700 static void
02701 cwh_directive_add_pragma_to_loop(WN * wn, BOOL is_omp)
02702 {
02703 if (is_omp)
02704 WN_set_pragma_omp(wn);
02705 WN_Set_Linenum (wn, USRCPOS_srcpos(current_srcpos));
02706 cwh_block_append_given_id(wn,Top_of_Loop_Block,FALSE);
02707 }
02708
02709
02710
02711
02712
02713
02714
02715
02716
02717
02718 static void
02719 cwh_directive_work_dist(INT32 work_dist, INTPTR work_dist_opnd)
02720 {
02721 WN * wn1 ;
02722 STB_pkt *p;
02723
02724 switch(work_dist) {
02725 case 0:
02726 break;
02727
02728 case 1:
02729 cwh_stmt_add_pragma(WN_PRAGMA_MPSCHEDTYPE,FALSE,(ST_IDX) NULL, WN_PRAGMA_SCHEDTYPE_DYNAMIC);
02730 wn1 = WN_CreateIntconst ( OPC_I4INTCONST, 1);
02731 cwh_stmt_add_xpragma(WN_PRAGMA_CHUNKSIZE,FALSE,wn1);
02732 break;
02733
02734 case 2:
02735 break;
02736
02737 case 3:
02738 cwh_stmt_add_pragma(WN_PRAGMA_MPSCHEDTYPE, FALSE,(ST_IDX) NULL, WN_PRAGMA_SCHEDTYPE_GSS);
02739 break;
02740
02741 case 4:
02742 DevAssert((0), ("Unimplemented numchunks"));
02743 break;
02744
02745 case 5:
02746 DevAssert((work_dist_opnd!=0),("Expected chunk value"));
02747 cwh_directive_load_value_pragma(work_dist_opnd,WN_PRAGMA_CHUNKSIZE);
02748 break;
02749
02750 default:
02751 DevAssert((0), ("Unknown work distr"));
02752 break;
02753 }
02754 }
02755
02756
02757
02758
02759
02760
02761
02762
02763
02764
02765
02766
02767
02768 static void
02769 cwh_directive_load_value_pragma(INTPTR item, WN_PRAGMA_ID pragma, BOOL is_omp)
02770 {
02771 WN * wn1 ;
02772 STB_pkt *p;
02773
02774 if (item) {
02775
02776 p = cast_to_STB(item);
02777 DevAssert((p->form == is_ST),("Odd item"));
02778
02779 wn1 = cwh_addr_load_ST((ST *)p->item, 0, 0);
02780 cwh_stmt_add_xpragma(pragma,is_omp,wn1);
02781 }
02782 }
02783
02784
02785
02786
02787
02788
02789
02790
02791
02792
02793
02794
02795
02796 extern void
02797 fei_copyin_bound(INTPTR sym_idx)
02798 {
02799 STB_pkt *p;
02800 WN *wn;
02801 ST *st;
02802
02803 p = cast_to_STB(sym_idx);
02804 DevAssert((p->form == is_ST),("Odd object ref"));
02805
02806 st = cast_to_ST(p->item);
02807
02808 if (ST_sym_class(st) == CLASS_VAR &&
02809 !ST_auxst_xpragma_copyin(st)) {
02810
02811 wn = WN_CreateXpragma ( WN_PRAGMA_COPYIN_BOUND, (ST_IDX) NULL, 1 );
02812 WN_kid0(wn) = cwh_addr_load_ST(st,0,0);
02813 cwh_block_append(wn);
02814 Set_ST_auxst_xpragma_copyin(st,TRUE);
02815 }
02816 }