Skip to content

Commit 8a5aa7e

Browse files
authored
Merge pull request #127 from ThePortlandGroup/nv_stage
Pull 2017-07-06T07-00 Recent NVIDIA Changes
2 parents b873470 + e12c4e7 commit 8a5aa7e

File tree

6 files changed

+76
-44
lines changed

6 files changed

+76
-44
lines changed

runtime/include/mthdecls.h

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ typedef struct {
7474
single precision versions of the math.h functions, in which case the
7575
single precision versions should be used: */
7676

77-
#if defined(WIN64) || defined(SOLARIS8664)
77+
#if defined(WIN64)
7878

7979
#define ACOSF acos
8080
#define ASINF asin
@@ -101,8 +101,8 @@ typedef struct {
101101
#define FLOORF floor
102102
#define FMODF fmod
103103
#define HYPOTF hypot
104-
#define COPYSIGNF copysignf
105-
#define COPYSIGN copysign
104+
#define COPYSIGNF _copysignf
105+
#define COPYSIGN _copysign
106106
#define ERFF erf
107107
#define ERFCF erfc
108108
#define GAMMAF tgamma
@@ -132,18 +132,12 @@ typedef struct {
132132
* Also, with MSOT8, hypot is depcrecated, and will not link
133133
* correctly. Need to use _hypot.
134134
*/
135-
#if defined(WIN64)
136135
#define POWF __mth_i_dpowd
137-
#define COPYSIGNF _copysignf
138-
#define COPYSIGN _copysign
139136
#ifdef __PGI_TOOLS9
140137
#define hypot _hypot
141138
#endif
142-
#else
143-
#define POWF pow
144-
#endif
145139

146-
#else
140+
#else /* #if defined (WIN64) */
147141
#define ACOSF acosf
148142
#define ASINF asinf
149143
#define ATANF atanf
@@ -249,17 +243,7 @@ typedef struct {
249243
#define BESSEL_Y1 y1
250244
#define BESSEL_YN yn
251245
#endif
252-
#endif
253-
254-
/*
255-
#if defined(INTERIX86)
256-
extern double HYPOTF();
257-
#endif
258-
*/
259-
260-
#if defined(SOLARIS8664)
261-
extern double hypot(double, double);
262-
#endif
246+
#endif /* #if defined (WIN64) */
263247

264248
/* declarations for math functions */
265249

tools/flang2/flang2exe/cgmain.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5491,27 +5491,6 @@ find_load_cse(int ilix, OPERAND *load_op, LL_Type *llt)
54915491
return NULL;
54925492
}
54935493

5494-
static LOGICAL
5495-
openmp_atomic_ld(int ilix)
5496-
{
5497-
ATOMIC_INFO info;
5498-
switch (ILI_OPC(ilix)) {
5499-
case IL_ATOMICLDI:
5500-
case IL_ATOMICLDKR:
5501-
case IL_ATOMICLDA:
5502-
case IL_ATOMICLDSP:
5503-
case IL_ATOMICLDDP:
5504-
break;
5505-
default:
5506-
return FALSE;
5507-
}
5508-
info = atomic_info(ilix);
5509-
5510-
if (info.origin == AORG_OPENMP)
5511-
return TRUE;
5512-
else
5513-
return FALSE;
5514-
}
55155494

55165495
/**
55175496
\brief return new operand of type OT_TMP as result of loading \p load_op
@@ -5536,7 +5515,7 @@ make_load(int ilix, OPERAND *load_op, LL_Type *rslt_type, MSZ msz,
55365515
0, ERR_Fatal);
55375516

55385517
cse_op = NULL;
5539-
if (ENABLE_CSE_OPT && !openmp_atomic_ld(ilix)) {
5518+
if (ENABLE_CSE_OPT && !is_omp_atomic_ld(ilix)) {
55405519
operand = find_load_cse(ilix, load_op, rslt_type);
55415520
if (operand != NULL) {
55425521
const int bits = ll_type_int_bits(operand->ll_type);

tools/flang2/flang2exe/expatomics.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2563,13 +2563,15 @@ _exp_mp_atomic_read(int stc, const datainfo* o, DTYPE dtype,
25632563
o->dtype == DT_DCMPLX) {
25642564

25652565
tmp_sptr = mkatomictemp(o->dtype);
2566-
nme[0] = addnme(NT_VAR, tmp_sptr, 0, (INT)0);
25672566
size = zsize_of(dtype);
25682567
size_ili = ad_icon(size);
2568+
ADDRTKNP(tmp_sptr, 1);
2569+
loc_of(nme[0]);
25692570
result = ll_make_atomic_load(size_ili, opnd[0],
25702571
ad_acon(tmp_sptr, 0), opnd[2]);
25712572
iltb.callfg = 1;
25722573
chk_block(result);
2574+
nme[0] = addnme(NT_VAR, tmp_sptr, 0, (INT)0);
25732575
result = ad3ili(o->ld,
25742576
ad_acon(tmp_sptr, 0),
25752577
nme[0],
@@ -2650,6 +2652,8 @@ _exp_mp_atomic_write(int stc, const datainfo* o, DTYPE dtype,
26502652
nme[1], mem_size(DTY(dtype)));
26512653
chk_block(result);
26522654
size_ili = ad_icon(size);
2655+
ADDRTKNP(tmp_sptr, 1);
2656+
loc_of(nme[0]);
26532657
result = ll_make_atomic_store(size_ili, opnd[0],
26542658
ad_acon(tmp_sptr, 0), opnd[2]);
26552659
iltb.callfg = 1;
@@ -2802,6 +2806,7 @@ exp_mp_atomic_update(ILM *ilmp)
28022806
expected_sptr = mkatomictemp(o->dtype);
28032807
stc = atomic_encode_rmw(mem_size(DTY(dtype)),
28042808
SS_PROCESS, AORG_OPENMP, aop);
2809+
loc_of(nme[0]);
28052810
result = ad5ili(o->atomicrmw, opnd[1], opnd[0], nme[0], stc, opnd[2]);
28062811

28072812
result = ad4ili(o->st, result, ad_acon(expected_sptr, 0),
@@ -2844,6 +2849,7 @@ exp_mp_atomic_update(ILM *ilmp)
28442849
result = ad4ili(o->st, desired_val, ad_acon(desired_sptr, 0),
28452850
addnme(NT_VAR, desired_sptr, 0, (INT)0),
28462851
mem_size(DTY(dtype)));
2852+
ASSNP(desired_sptr, 1);
28472853
chk_block(result);
28482854
}
28492855
/* do compare exchange */
@@ -2852,6 +2858,7 @@ exp_mp_atomic_update(ILM *ilmp)
28522858
size_ili = ad_icon(size);
28532859
ADDRTKNP(expected_sptr, 1);
28542860
ADDRTKNP(desired_sptr, 1);
2861+
loc_of(nme[0]);
28552862
result = ll_make_atomic_compare_xchg(size_ili, opnd[0],
28562863
ad_acon(expected_sptr, 0),
28572864
ad_acon(desired_sptr, 0),
@@ -2889,6 +2896,7 @@ exp_mp_atomic_update(ILM *ilmp)
28892896
addnme(NT_VAR, desired_sptr, 0, (INT)0),
28902897
msz);
28912898
stc = atomic_encode(msz, SS_PROCESS, AORG_OPENMP);
2899+
loc_of(nme[0]);
28922900
cmpxchg = ad_cmpxchg(o->cmpxchg, desired_val, opnd[0], nme[0],
28932901
stc, expected_val, ad_icon(0), opnd[2],
28942902
ad_icon(0));
@@ -3054,6 +3062,7 @@ exp_mp_atomic_capture(ILM *ilmp)
30543062
expected_sptr = mkatomictemp(o->dtype);
30553063
stc = atomic_encode_rmw(mem_size(DTY(cpt.dtype)),
30563064
SS_PROCESS, AORG_OPENMP, cpt.aop);
3065+
loc_of(cpt.x_nme);
30573066
result = ad5ili(o->atomicrmw, cpt.expr, cpt.x, cpt.x_nme, stc,
30583067
cpt.mem_order);
30593068

@@ -3111,6 +3120,7 @@ exp_mp_atomic_capture(ILM *ilmp)
31113120
size_ili = ad_icon(size);
31123121
ADDRTKNP(expected_sptr, 1);
31133122
ADDRTKNP(desired_sptr, 1);
3123+
loc_of(cpt.x_nme);
31143124
result = ll_make_atomic_compare_xchg(size_ili, cpt.x,
31153125
ad_acon(expected_sptr, 0),
31163126
ad_acon(desired_sptr, 0),
@@ -3166,6 +3176,7 @@ exp_mp_atomic_capture(ILM *ilmp)
31663176
addnme(NT_VAR, desired_sptr, 0, (INT)0),
31673177
msz);
31683178
stc = atomic_encode(msz, SS_PROCESS, AORG_OPENMP);
3179+
loc_of(cpt.x_nme);
31693180
cmpxchg = ad_cmpxchg(o->cmpxchg, desired_val, cpt.x, cpt.x_nme,
31703181
stc, expected_val, ad_icon(0), cpt.mem_order,
31713182
ad_icon(0));

tools/flang2/flang2exe/expsmp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,18 @@ exp_smp(ILM_OP opc, ILM *ilmp, int curilm)
22112211
break;
22122212

22132213
case IM_MP_ATOMIC:
2214+
if (ll_ilm_is_rewriting())
2215+
break;
2216+
wr_block();
2217+
cr_block();
2218+
bihb.csfg = BIH_CS(expb.curbih) = TRUE;
2219+
break;
22142220
case IM_MP_ENDATOMIC:
2221+
if (ll_ilm_is_rewriting())
2222+
break;
2223+
wr_block();
2224+
cr_block();
2225+
bihb.csfg = BIH_CS(expb.curbih) = FALSE;
22152226
break;
22162227

22172228
case IM_MP_ATOMICREAD:

tools/flang2/flang2exe/ili.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ int atomic_encode_rmw(MSZ msz, SYNC_SCOPE scope, ATOMIC_ORIGIN origin,
588588
ATOMIC_RMW_OP op);
589589
MEMORY_ORDER memory_order(int ilix);
590590
ATOMIC_INFO atomic_info(int ilix);
591+
extern LOGICAL is_omp_atomic_ld(int);
592+
extern LOGICAL is_omp_atomic_st(int);
591593

592594
ATOMIC_INFO atomic_decode(int encoding);
593595
int atomic_info_index(ILI_OP opc);

tools/flang2/flang2exe/iliutil.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13029,3 +13029,48 @@ memory_order(int ilix)
1302913029
}
1303013030
return memory_order_from_operand(ILI_OPND(ilix, i));
1303113031
}
13032+
13033+
13034+
LOGICAL
13035+
is_omp_atomic_ld(int ilix)
13036+
{
13037+
ATOMIC_INFO info;
13038+
switch (ILI_OPC(ilix)) {
13039+
case IL_ATOMICLDI:
13040+
case IL_ATOMICLDKR:
13041+
case IL_ATOMICLDA:
13042+
case IL_ATOMICLDSP:
13043+
case IL_ATOMICLDDP:
13044+
break;
13045+
default:
13046+
return FALSE;
13047+
}
13048+
info = atomic_info(ilix);
13049+
13050+
if (info.origin == AORG_OPENMP)
13051+
return TRUE;
13052+
else
13053+
return FALSE;
13054+
}
13055+
13056+
LOGICAL
13057+
is_omp_atomic_st(int ilix)
13058+
{
13059+
ATOMIC_INFO info;
13060+
switch (ILI_OPC(ilix)) {
13061+
case IL_ATOMICSTI:
13062+
case IL_ATOMICSTKR:
13063+
case IL_ATOMICSTA:
13064+
case IL_ATOMICSTSP:
13065+
case IL_ATOMICSTDP:
13066+
break;
13067+
default:
13068+
return FALSE;
13069+
}
13070+
info = atomic_info(ilix);
13071+
13072+
if (info.origin == AORG_OPENMP)
13073+
return TRUE;
13074+
else
13075+
return FALSE;
13076+
}

0 commit comments

Comments
 (0)