Skip to content

Commit d07daf3

Browse files
authored
Merge pull request #815 from ThePortlandGroup/nv_stage
Pull 2019-10-09T10-36 Recent NVIDIA Changes
2 parents 257d7e4 + 5758ee4 commit d07daf3

File tree

12 files changed

+126
-34
lines changed

12 files changed

+126
-34
lines changed

runtime/libpgmath/lib/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,17 @@ if(${LIBPGMATH_SYSTEM_PROCESSOR} MATCHES "x86_64" AND NOT ${LIBPGMATH_WITH_GENER
9292
TARGET_WIN_X8664 TARGET_WIN _PGI_NOBUILTINS MAXCPUS=256
9393
MAXCPUSL=8 MAXCPUSR=8 WINNT WIN64 LONG_IS_32
9494
HOST_WIN TARGET_X8664 _NO_CRT_STDIO_INLINE)
95-
#djp HOST_WIN _DLL TARGET_X8664 _NO_CRT_STDIO_INLINE)
95+
#problems with -O2 and higher using vectorcall ABI
96+
# set(FLAGS_L1 "-m64 -O2 ")
97+
set(FLAGS_L2 "-m64 ")
9698

9799
set(DEFINITIONS_L2
98100
TARGET_WIN_X8664 TARGET_WIN _PGI_NOBUILTINS MAXCPUS=256
99101
MAXCPUSL=8 MAXCPUSR=8 WINNT WIN64 LONG_IS_32
100102
HOST_WIN TARGET_X8664 _NO_CRT_STDIO_INLINE)
101-
#djp HOST_WIN _DLL TARGET_X8664 _NO_CRT_STDIO_INLINE)
103+
#problems with -O2 and higher using vectorcall ABI
104+
# set(FLAGS_L2 "-m64 -O2 ")
105+
set(FLAGS_L2 "-m64 ")
102106

103107
# common
104108
# Definitions and compiler flags for level 1 directories

runtime/libpgmath/lib/common/log10f/common.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
#ifndef COMMON_H
2020
#define COMMON_H
2121

22-
static float int_as_float(int a) { return *(float*)&a; }
23-
static int float_as_int(float a) { return *(int*)&a; }
2422

25-
float const TWO_TO_24_F = 16777216.0f;
26-
float const PINF = int_as_float(0x7f800000);
27-
float const NINF = int_as_float(0xff800000);
28-
float const CANONICAL_NAN = int_as_float(0xffc00000);
23+
#include <math.h>
24+
25+
static inline float int_as_float(int a) { return *(float*)&a; }
26+
static inline int float_as_int(float a) { return *(int*)&a; }
27+
28+
static float const TWO_TO_24_F = 16777216.0f;
29+
static float const PINF = +INFINITY;
30+
static float const NINF = -INFINITY;
31+
static float const CANONICAL_NAN = -NAN;
2932

3033
const float ONE_F[] __attribute__ ((aligned (64))) = {
3134
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,

runtime/libpgmath/lib/common/logf/common.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@
1616
*
1717
*/
1818

19+
#ifndef COMMON_H
20+
#define COMMON_H
1921

20-
static float int_as_float(int a) { return *(float*)&a; }
21-
static int float_as_int(float a) { return *(int*)&a; }
2222

23-
float const TWO_TO_24_F = 16777216.0f;
24-
float const PINF = int_as_float(0x7f800000);
25-
float const NINF = int_as_float(0xff800000);
26-
float const CANONICAL_NAN = int_as_float(0xffc00000);
23+
#include <math.h>
24+
25+
static inline float int_as_float(int a) { return *(float*)&a; }
26+
static inline int float_as_int(float a) { return *(int*)&a; }
27+
28+
static float const TWO_TO_24_F = 16777216.0f;
29+
static float const PINF = +INFINITY;
30+
static float const NINF = -INFINITY;
31+
static float const CANONICAL_NAN = -NAN;
2732

2833
const float ONE_F[] __attribute__ ((aligned (64))) = {
2934
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
@@ -117,3 +122,4 @@ const float c9[] __attribute__ ((aligned (64))) = {
117122
-0.5f,-0.5f,-0.5f,-0.5f,-0.5f,-0.5f,-0.5f,-0.5f
118123
};
119124

125+
#endif
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
!
2+
! Copyright (c) 2018, Arm Ltd. All rights reserved.
3+
!
4+
! Licensed under the Apache License, Version 2.0 (the "License");
5+
! you may not use this file except in compliance with the License.
6+
! You may obtain a copy of the License at
7+
!
8+
! http://www.apache.org/licenses/LICENSE-2.0
9+
!
10+
! Unless required by applicable law or agreed to in writing, software
11+
! distributed under the License is distributed on an "AS IS" BASIS,
12+
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
! See the License for the specific language governing permissions and
14+
! limitations under the License.
15+
!
16+
17+
! RUN: %flang -g -S -emit-llvm %s -o - | FileCheck %s
18+
module first
19+
integer :: var1 = 37
20+
end module
21+
22+
module second
23+
use first
24+
integer :: var2 = 47
25+
contains
26+
function init()
27+
var2 = var2 - var1
28+
end function
29+
end module
30+
31+
program hello
32+
use second
33+
print *, var1
34+
print *, var2
35+
end program hello
36+
37+
! //CHECK: ![[DBG_DIC:[0-9]+]] = distinct !DICompileUnit({{.*}}, imports: ![[DBG_IMPORTS:[0-9]+]])
38+
! //CHECK: ![[DBG_MOD1:[0-9]+]] = !DIModule({{.*}}, name: "first"
39+
! //CHECK: ![[DBG_MOD2:[0-9]+]] = !DIModule({{.*}}, name: "second"
40+
! //CHECK: ![[DBG_IMPORTS:[0-9]+]] = !{![[DBG_IE1:[0-9]+]], ![[DBG_IE2:[0-9]+]], ![[DBG_IE3:[0-9]+]], ![[DBG_IE4:[0-9]+]]}
41+
! //CHECK: ![[DBG_IE1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[DBG_SP1:[0-9]+]], entity: ![[DBG_MOD2]],
42+
! //CHECK: ![[DBG_SP1]] = distinct !DISubprogram(name: "init",
43+
! //CHECK: ![[DBG_IE2]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[DBG_SP1]], entity: ![[DBG_MOD1]],
44+
! //CHECK: ![[DBG_IE3]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[DBG_SP2:[0-9]+]], entity: ![[DBG_MOD1]],
45+
! //CHECK: ![[DBG_SP2]] = distinct !DISubprogram(name: "hello",
46+
! //CHECK: ![[DBG_IE4]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[DBG_SP2]], entity: ![[DBG_MOD2]],

tools/flang1/flang1exe/semsmp.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ static int get_omp_combined_mode(BIGINT64 type);
123123
static void mp_handle_map_clause(SST *, int, char *, int, int, bool);
124124
static void mp_check_maptype(const char *maptype);
125125
static LOGICAL is_in_omptarget(int d);
126+
static LOGICAL is_in_omptarget_data(int d);
126127
#endif
127128
#ifdef OMP_OFFLOAD_LLVM
128129
static void gen_reduction_ompaccel(REDUC *reducp, REDUC_SYM *reduc_symp,
@@ -4822,7 +4823,7 @@ semsmp(int rednum, SST *top)
48224823
*/
48234824
case ACCEL_DATA1:
48244825
#if defined(OMP_OFFLOAD_LLVM) || defined(OMP_OFFLOAD_PGI)
4825-
if(is_in_omptarget(sem.doif_depth)) {
4826+
if(is_in_omptarget(sem.doif_depth) || is_in_omptarget_data(sem.doif_depth)) {
48264827
//todo support array section in the map clause for openmp
48274828
if (SST_IDG(RHS(1)) == S_IDENT || SST_IDG(RHS(1)) == S_DERIVED) {
48284829
sptr = SST_SYMG(RHS(1));
@@ -10292,13 +10293,22 @@ check_map_data_sharing(int sptr)
1029210293
return TRUE;
1029310294
}
1029410295

10296+
static LOGICAL is_in_omptarget_data(int d)
10297+
{
10298+
if(flg.omptarget && (DI_IN_NEST(d, DI_TARGETENTERDATA) ||
10299+
DI_IN_NEST(d, DI_TARGETEXITDATA) ||
10300+
DI_IN_NEST(d, DI_TARGETDATA)))
10301+
return TRUE;
10302+
return FALSE;
10303+
}
1029510304
static LOGICAL is_in_omptarget(int d)
1029610305
{
1029710306
if(flg.omptarget && (DI_IN_NEST(d, DI_TARGET) ||
1029810307
DI_IN_NEST(d, DI_TARGTEAMSDISTPARDO) ||
1029910308
DI_IN_NEST(d, DI_TARGPARDO) ||
1030010309
DI_IN_NEST(d, DI_TARGETSIMD) ||
10301-
DI_IN_NEST(d, DI_TARGTEAMSDIST)))
10310+
DI_IN_NEST(d, DI_TARGTEAMSDIST) ||
10311+
DI_IN_NEST(d, DI_TARGETENTERDATA)))
1030210312
return TRUE;
1030310313
return FALSE;
1030410314
}

tools/flang2/flang2exe/exp_rte.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,7 @@ ldst_size(DTYPE dtype, ILI_OP *ldo, ILI_OP *sto, int *siz)
18911891
*siz = MSZ_SBYTE;
18921892
break;
18931893
case TY_SINT:
1894+
case TY_SLOG:
18941895
case TY_NCHAR:
18951896
*siz = MSZ_SHWORD;
18961897
break;
@@ -1936,6 +1937,9 @@ ldst_size(DTYPE dtype, ILI_OP *ldo, ILI_OP *sto, int *siz)
19361937
*siz = MSZ_WORD;
19371938
}
19381939
break;
1940+
case TY_BLOG:
1941+
*siz = MSZ_SBYTE;
1942+
break;
19391943
case TY_INT:
19401944
default:
19411945
*siz = MSZ_WORD;

tools/flang2/flang2exe/expsmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2985,7 +2985,7 @@ clear_tplnk(void)
29852985
int sym;
29862986
for (sym = gbl.threadprivate; sym > NOSYM; sym = TPLNKG(sym)) {
29872987
TPLNKP(sym, 0);
2988-
THPRVTOPTP(sym, 0); /* so much trouble clear this too, damnit */
2988+
THPRVTOPTP(sym, 0); /* so much trouble clear this too */
29892989
}
29902990
gbl.threadprivate = NOSYM;
29912991
}

tools/flang2/flang2exe/mwd.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4336,18 +4336,15 @@ printblocks(void)
43364336
if (full) {
43374337
fprintf(dfile, "func_count=%d, curr_func=%d=%s\n", gbl.func_count,
43384338
GBL_CURRFUNC, GBL_CURRFUNC > 0 ? SYMNAME(GBL_CURRFUNC) : "");
4339-
#ifdef CUDAG
4340-
putcuda("cuda", CUDAG(GBL_CURRFUNC));
4341-
fprintf(dfile, "\n");
4342-
#endif
43434339
} else {
43444340
fprintf(dfile, "func_count=%d, curr_func=%s\n", gbl.func_count,
43454341
GBL_CURRFUNC > 0 ? SYMNAME(GBL_CURRFUNC) : "");
4342+
}
43464343
#ifdef CUDAG
4347-
putcuda("cuda", CUDAG(GBL_CURRFUNC));
4348-
fprintf(dfile, "\n");
4344+
if (GBL_CURRFUNC > 0)
4345+
putcuda("cuda", CUDAG(GBL_CURRFUNC));
4346+
fprintf(dfile, "\n");
43494347
#endif
4350-
}
43514348
block = BIHNUMG(GBL_CURRFUNC);
43524349
for (; block; block = BIH_NEXT(block)) {
43534350
printblock(block);

tools/flang2/flang2exe/outliner.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ get_opc_name(ILM_OP opc)
327327
static char *
328328
ll_get_outlined_funcname(int fileno, int lineno, bool isompaccel, ILM_OP opc) {
329329
char *name;
330-
const char* name_opc = get_opc_name(opc);
331330
static unsigned nmLen = 0;
332331
const unsigned maxDigitLen = 10; /* Len of 2147483647 */
333332
unsigned nmSize;
@@ -343,15 +342,15 @@ ll_get_outlined_funcname(int fileno, int lineno, bool isompaccel, ILM_OP opc) {
343342
funcCnt++;
344343
prefix = host_prefix;
345344
}
346-
plen = strlen(prefix);
347345
if(gbl.outlined) {
348-
assert(!strncmp(name_currfunc, prefix, plen),
349-
"Outlined function doesn't start with correct prefix", r, ERR_Fatal);
350-
name_currfunc = strtok(&name_currfunc[plen], "_");
346+
{
347+
plen = strlen(host_prefix);
348+
name_currfunc = strtok(&name_currfunc[plen], "_");
349+
}
351350
}
352351
nmSize = (3 * maxDigitLen) + 5 + strlen(name_currfunc) + 1;
353352
name = (char *)malloc(nmSize + strlen(prefix));
354-
r = snprintf(name, nmSize, "%s%s_%s_F%dL%d_%d", prefix, name_currfunc, name_opc, fileno, lineno, funcCnt);
353+
r = snprintf(name, nmSize, "%s%s_F%dL%d_%d", prefix, name_currfunc, fileno, lineno, funcCnt);
355354
assert(r < nmSize, "buffer overrun", r, ERR_Fatal);
356355
return name;
357356
}

tools/flang2/flang2exe/tgtutil.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ tgt_target_fill_params(SPTR arg_base_sptr, SPTR arg_size_sptr, SPTR args_sptr,
391391
OMPACCEL_SYM midnum_sym;
392392
DTYPE param_dtype, load_dtype;
393393
SPTR param_sptr;
394-
LOGICAL isPointer, isMidnum, isImplicit;
394+
LOGICAL isPointer, isMidnum, isImplicit, isThis;
395395
/* fill the arrays */
396396
/* Build the list: (size, sptr) pairs. */
397397

@@ -434,8 +434,10 @@ tgt_target_fill_params(SPTR arg_base_sptr, SPTR arg_size_sptr, SPTR args_sptr,
434434

435435
/* Find the base */
436436
if(targetinfo->symbols[i].in_map) {
437-
if(llis_array_kind(param_dtype) || llis_pointer_kind(param_dtype))
437+
if(llis_array_kind(param_dtype))
438438
param_dtype = array_element_dtype(param_dtype);
439+
else if (llis_pointer_kind(param_dtype))
440+
param_dtype = DTySeqTyElement(param_dtype);
439441
iliy = targetinfo->symbols[i].ili_base;
440442
ilix = mk_ompaccel_store(iliy, DT_ADDR, nme_base,
441443
ad_acon(arg_base_sptr, i * TARGET_PTRSIZE));
@@ -452,7 +454,7 @@ tgt_target_fill_params(SPTR arg_base_sptr, SPTR arg_size_sptr, SPTR args_sptr,
452454
chk_block(ilix);
453455
} else {
454456
/* Optimization - Pass by value for scalar */
455-
if (TY_ISSCALAR(DTY(param_dtype))) {
457+
if (TY_ISSCALAR(DTY(param_dtype)) && (targetinfo->symbols[i].map_type & OMP_TGT_MAPTYPE_IMPLICIT) || isMidnum || isThis ) {
456458
iliy = mk_ompaccel_ldsptr(param_sptr);
457459
load_dtype = param_dtype;
458460
} else {

0 commit comments

Comments
 (0)