Skip to content
Permalink
Browse files

Merge pull request #815 from ThePortlandGroup/nv_stage

Pull 2019-10-09T10-36 Recent NVIDIA Changes
  • Loading branch information...
sscalpone committed Oct 9, 2019
2 parents 257d7e4 + 5758ee4 commit d07daf33646a76b90260a8627818e8f395d73403
@@ -92,13 +92,17 @@ if(${LIBPGMATH_SYSTEM_PROCESSOR} MATCHES "x86_64" AND NOT ${LIBPGMATH_WITH_GENER
TARGET_WIN_X8664 TARGET_WIN _PGI_NOBUILTINS MAXCPUS=256
MAXCPUSL=8 MAXCPUSR=8 WINNT WIN64 LONG_IS_32
HOST_WIN TARGET_X8664 _NO_CRT_STDIO_INLINE)
#djp HOST_WIN _DLL TARGET_X8664 _NO_CRT_STDIO_INLINE)
#problems with -O2 and higher using vectorcall ABI
# set(FLAGS_L1 "-m64 -O2 ")
set(FLAGS_L2 "-m64 ")

set(DEFINITIONS_L2
TARGET_WIN_X8664 TARGET_WIN _PGI_NOBUILTINS MAXCPUS=256
MAXCPUSL=8 MAXCPUSR=8 WINNT WIN64 LONG_IS_32
HOST_WIN TARGET_X8664 _NO_CRT_STDIO_INLINE)
#djp HOST_WIN _DLL TARGET_X8664 _NO_CRT_STDIO_INLINE)
#problems with -O2 and higher using vectorcall ABI
# set(FLAGS_L2 "-m64 -O2 ")
set(FLAGS_L2 "-m64 ")

# common
# Definitions and compiler flags for level 1 directories
@@ -19,13 +19,16 @@
#ifndef COMMON_H
#define COMMON_H

static float int_as_float(int a) { return *(float*)&a; }
static int float_as_int(float a) { return *(int*)&a; }

float const TWO_TO_24_F = 16777216.0f;
float const PINF = int_as_float(0x7f800000);
float const NINF = int_as_float(0xff800000);
float const CANONICAL_NAN = int_as_float(0xffc00000);
#include <math.h>

static inline float int_as_float(int a) { return *(float*)&a; }
static inline int float_as_int(float a) { return *(int*)&a; }

static float const TWO_TO_24_F = 16777216.0f;
static float const PINF = +INFINITY;
static float const NINF = -INFINITY;
static float const CANONICAL_NAN = -NAN;

const float ONE_F[] __attribute__ ((aligned (64))) = {
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
@@ -16,14 +16,19 @@
*
*/

#ifndef COMMON_H
#define COMMON_H

static float int_as_float(int a) { return *(float*)&a; }
static int float_as_int(float a) { return *(int*)&a; }

float const TWO_TO_24_F = 16777216.0f;
float const PINF = int_as_float(0x7f800000);
float const NINF = int_as_float(0xff800000);
float const CANONICAL_NAN = int_as_float(0xffc00000);
#include <math.h>

static inline float int_as_float(int a) { return *(float*)&a; }
static inline int float_as_int(float a) { return *(int*)&a; }

static float const TWO_TO_24_F = 16777216.0f;
static float const PINF = +INFINITY;
static float const NINF = -INFINITY;
static float const CANONICAL_NAN = -NAN;

const float ONE_F[] __attribute__ ((aligned (64))) = {
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))) = {
-0.5f,-0.5f,-0.5f,-0.5f,-0.5f,-0.5f,-0.5f,-0.5f
};

#endif
@@ -0,0 +1,46 @@
!
! Copyright (c) 2018, Arm Ltd. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!

! RUN: %flang -g -S -emit-llvm %s -o - | FileCheck %s
module first
integer :: var1 = 37
end module

module second
use first
integer :: var2 = 47
contains
function init()
var2 = var2 - var1
end function
end module

program hello
use second
print *, var1
print *, var2
end program hello

! //CHECK: ![[DBG_DIC:[0-9]+]] = distinct !DICompileUnit({{.*}}, imports: ![[DBG_IMPORTS:[0-9]+]])
! //CHECK: ![[DBG_MOD1:[0-9]+]] = !DIModule({{.*}}, name: "first"
! //CHECK: ![[DBG_MOD2:[0-9]+]] = !DIModule({{.*}}, name: "second"
! //CHECK: ![[DBG_IMPORTS:[0-9]+]] = !{![[DBG_IE1:[0-9]+]], ![[DBG_IE2:[0-9]+]], ![[DBG_IE3:[0-9]+]], ![[DBG_IE4:[0-9]+]]}
! //CHECK: ![[DBG_IE1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[DBG_SP1:[0-9]+]], entity: ![[DBG_MOD2]],
! //CHECK: ![[DBG_SP1]] = distinct !DISubprogram(name: "init",
! //CHECK: ![[DBG_IE2]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[DBG_SP1]], entity: ![[DBG_MOD1]],
! //CHECK: ![[DBG_IE3]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[DBG_SP2:[0-9]+]], entity: ![[DBG_MOD1]],
! //CHECK: ![[DBG_SP2]] = distinct !DISubprogram(name: "hello",
! //CHECK: ![[DBG_IE4]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[DBG_SP2]], entity: ![[DBG_MOD2]],
@@ -123,6 +123,7 @@ static int get_omp_combined_mode(BIGINT64 type);
static void mp_handle_map_clause(SST *, int, char *, int, int, bool);
static void mp_check_maptype(const char *maptype);
static LOGICAL is_in_omptarget(int d);
static LOGICAL is_in_omptarget_data(int d);
#endif
#ifdef OMP_OFFLOAD_LLVM
static void gen_reduction_ompaccel(REDUC *reducp, REDUC_SYM *reduc_symp,
@@ -4822,7 +4823,7 @@ semsmp(int rednum, SST *top)
*/
case ACCEL_DATA1:
#if defined(OMP_OFFLOAD_LLVM) || defined(OMP_OFFLOAD_PGI)
if(is_in_omptarget(sem.doif_depth)) {
if(is_in_omptarget(sem.doif_depth) || is_in_omptarget_data(sem.doif_depth)) {
//todo support array section in the map clause for openmp
if (SST_IDG(RHS(1)) == S_IDENT || SST_IDG(RHS(1)) == S_DERIVED) {
sptr = SST_SYMG(RHS(1));
@@ -10292,13 +10293,22 @@ check_map_data_sharing(int sptr)
return TRUE;
}

static LOGICAL is_in_omptarget_data(int d)
{
if(flg.omptarget && (DI_IN_NEST(d, DI_TARGETENTERDATA) ||
DI_IN_NEST(d, DI_TARGETEXITDATA) ||
DI_IN_NEST(d, DI_TARGETDATA)))
return TRUE;
return FALSE;
}
static LOGICAL is_in_omptarget(int d)
{
if(flg.omptarget && (DI_IN_NEST(d, DI_TARGET) ||
DI_IN_NEST(d, DI_TARGTEAMSDISTPARDO) ||
DI_IN_NEST(d, DI_TARGPARDO) ||
DI_IN_NEST(d, DI_TARGETSIMD) ||
DI_IN_NEST(d, DI_TARGTEAMSDIST)))
DI_IN_NEST(d, DI_TARGTEAMSDIST) ||
DI_IN_NEST(d, DI_TARGETENTERDATA)))
return TRUE;
return FALSE;
}
@@ -1891,6 +1891,7 @@ ldst_size(DTYPE dtype, ILI_OP *ldo, ILI_OP *sto, int *siz)
*siz = MSZ_SBYTE;
break;
case TY_SINT:
case TY_SLOG:
case TY_NCHAR:
*siz = MSZ_SHWORD;
break;
@@ -1936,6 +1937,9 @@ ldst_size(DTYPE dtype, ILI_OP *ldo, ILI_OP *sto, int *siz)
*siz = MSZ_WORD;
}
break;
case TY_BLOG:
*siz = MSZ_SBYTE;
break;
case TY_INT:
default:
*siz = MSZ_WORD;
@@ -2985,7 +2985,7 @@ clear_tplnk(void)
int sym;
for (sym = gbl.threadprivate; sym > NOSYM; sym = TPLNKG(sym)) {
TPLNKP(sym, 0);
THPRVTOPTP(sym, 0); /* so much trouble clear this too, damnit */
THPRVTOPTP(sym, 0); /* so much trouble clear this too */
}
gbl.threadprivate = NOSYM;
}
@@ -4336,18 +4336,15 @@ printblocks(void)
if (full) {
fprintf(dfile, "func_count=%d, curr_func=%d=%s\n", gbl.func_count,
GBL_CURRFUNC, GBL_CURRFUNC > 0 ? SYMNAME(GBL_CURRFUNC) : "");
#ifdef CUDAG
putcuda("cuda", CUDAG(GBL_CURRFUNC));
fprintf(dfile, "\n");
#endif
} else {
fprintf(dfile, "func_count=%d, curr_func=%s\n", gbl.func_count,
GBL_CURRFUNC > 0 ? SYMNAME(GBL_CURRFUNC) : "");
}
#ifdef CUDAG
putcuda("cuda", CUDAG(GBL_CURRFUNC));
fprintf(dfile, "\n");
if (GBL_CURRFUNC > 0)
putcuda("cuda", CUDAG(GBL_CURRFUNC));
fprintf(dfile, "\n");
#endif
}
block = BIHNUMG(GBL_CURRFUNC);
for (; block; block = BIH_NEXT(block)) {
printblock(block);
@@ -327,7 +327,6 @@ get_opc_name(ILM_OP opc)
static char *
ll_get_outlined_funcname(int fileno, int lineno, bool isompaccel, ILM_OP opc) {
char *name;
const char* name_opc = get_opc_name(opc);
static unsigned nmLen = 0;
const unsigned maxDigitLen = 10; /* Len of 2147483647 */
unsigned nmSize;
@@ -343,15 +342,15 @@ ll_get_outlined_funcname(int fileno, int lineno, bool isompaccel, ILM_OP opc) {
funcCnt++;
prefix = host_prefix;
}
plen = strlen(prefix);
if(gbl.outlined) {
assert(!strncmp(name_currfunc, prefix, plen),
"Outlined function doesn't start with correct prefix", r, ERR_Fatal);
name_currfunc = strtok(&name_currfunc[plen], "_");
{
plen = strlen(host_prefix);
name_currfunc = strtok(&name_currfunc[plen], "_");
}
}
nmSize = (3 * maxDigitLen) + 5 + strlen(name_currfunc) + 1;
name = (char *)malloc(nmSize + strlen(prefix));
r = snprintf(name, nmSize, "%s%s_%s_F%dL%d_%d", prefix, name_currfunc, name_opc, fileno, lineno, funcCnt);
r = snprintf(name, nmSize, "%s%s_F%dL%d_%d", prefix, name_currfunc, fileno, lineno, funcCnt);
assert(r < nmSize, "buffer overrun", r, ERR_Fatal);
return name;
}
@@ -391,7 +391,7 @@ tgt_target_fill_params(SPTR arg_base_sptr, SPTR arg_size_sptr, SPTR args_sptr,
OMPACCEL_SYM midnum_sym;
DTYPE param_dtype, load_dtype;
SPTR param_sptr;
LOGICAL isPointer, isMidnum, isImplicit;
LOGICAL isPointer, isMidnum, isImplicit, isThis;
/* fill the arrays */
/* Build the list: (size, sptr) pairs. */

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

/* Find the base */
if(targetinfo->symbols[i].in_map) {
if(llis_array_kind(param_dtype) || llis_pointer_kind(param_dtype))
if(llis_array_kind(param_dtype))
param_dtype = array_element_dtype(param_dtype);
else if (llis_pointer_kind(param_dtype))
param_dtype = DTySeqTyElement(param_dtype);
iliy = targetinfo->symbols[i].ili_base;
ilix = mk_ompaccel_store(iliy, DT_ADDR, nme_base,
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,
chk_block(ilix);
} else {
/* Optimization - Pass by value for scalar */
if (TY_ISSCALAR(DTY(param_dtype))) {
if (TY_ISSCALAR(DTY(param_dtype)) && (targetinfo->symbols[i].map_type & OMP_TGT_MAPTYPE_IMPLICIT) || isMidnum || isThis ) {
iliy = mk_ompaccel_ldsptr(param_sptr);
load_dtype = param_dtype;
} else {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2015-2019, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -453,3 +453,21 @@ llmp_concur_add_shared_var(int stblock_sptr, int shared_sptr)
up = llmp_create_uplevel(stblock_sptr);
(void)llmp_add_shared_var(up, shared_sptr);
}

bool is_omp_mode_target(OMP_TARGET_MODE mode) {
switch (mode)
{
case mode_target:
case mode_target_teams:
case mode_target_teams_distribute:
case mode_target_teams_distribute_simd:
case mode_target_teams_distribute_parallel_for:
case mode_target_teams_distribute_parallel_for_simd:
case mode_target_parallel:
case mode_target_parallel_for:
case mode_target_parallel_for_simd:
return true;
default:
return false;
}
}
@@ -108,6 +108,9 @@ typedef enum {
mode_targetupdate_begin,
mode_targetupdate_end,
} OMP_TARGET_MODE;

bool is_omp_mode_target(OMP_TARGET_MODE mode);

/* The name of the modes of target related regions. */
static const char *omp_target_mode_names[] = {
"None target",

0 comments on commit d07daf3

Please sign in to comment.
You can’t perform that action at this time.