Skip to content

Commit 6196855

Browse files
authored
Merge pull request #841 from ThePortlandGroup/nv_stage
Pull 2019-11-26T15-28 Recent NVIDIA Changes
2 parents cbadb27 + 265c9c9 commit 6196855

File tree

14 files changed

+184
-17
lines changed

14 files changed

+184
-17
lines changed

runtime/flang/allo.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,17 @@ I8(__alloc04)(__NELEM_T nelem, dtype kind, size_t len,
396396
if (!ISPRESENT(errmsg))
397397
errmsg = NULL;
398398

399+
if (*pointer && I8(__fort_allocated)(*pointer)
400+
&& ISPRESENT(stat) && *stat == 2) {
401+
int i;
402+
char *mp;
403+
MP_P_STDIO;
404+
mp = "array already allocated";
405+
for (i = 0; i < errlen; i++)
406+
errmsg[i] = (*mp ? *mp++ : ' ');
407+
MP_V_STDIO;
408+
}
409+
399410
#if (defined(WIN64) || defined(WIN32))
400411
#define ALN_LARGE
401412
#else
@@ -912,7 +923,13 @@ ENTF90(ALLOC03_CHKA, alloc03_chka)(__INT_T *nelem, __INT_T *kind, __INT_T *len,
912923
{
913924

914925
if (*pointer && I8(__fort_allocated)(*pointer)) {
915-
__fort_abort("ALLOCATE: array already allocated");
926+
if (ISPRESENT(stat)) {
927+
*stat = 2;
928+
} else {
929+
__fort_abort("ALLOCATE: array already allocated");
930+
}
931+
} else if (ISPRESENT(stat) && *firsttime) {
932+
*stat = 0;
916933
}
917934
ENTF90(ALLOC03,alloc03)(nelem, kind, len, stat, pointer, offset,
918935
firsttime,CADR(errmsg), CLEN(errmsg));
@@ -937,7 +954,7 @@ ENTF90(ALLOC04A, alloc04a)(__NELEM_T *nelem, __INT_T *kind, __INT_T *len,
937954
{
938955
ALLHDR();
939956

940-
if (ISPRESENT(stat) && *firsttime)
957+
if (ISPRESENT(stat) && *firsttime && *stat != 2)
941958
*stat = 0;
942959

943960
if (!ISPRESENT(stat) && !*align) {
@@ -977,7 +994,13 @@ ENTF90(ALLOC04_CHKA, alloc04_chka)(__NELEM_T *nelem, __INT_T *kind,
977994
{
978995

979996
if (*pointer && I8(__fort_allocated)(*pointer)) {
980-
__fort_abort("ALLOCATE: array already allocated");
997+
if (ISPRESENT(stat)) {
998+
*stat = 2;
999+
} else {
1000+
__fort_abort("ALLOCATE: array already allocated");
1001+
}
1002+
} else if (ISPRESENT(stat) && *firsttime) {
1003+
*stat = 0;
9811004
}
9821005
ENTF90(ALLOC04,alloc04)(nelem, kind, len, stat, pointer, offset, firsttime,
9831006
align, CADR(errmsg), CLEN(errmsg));

runtime/flang/rdst.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ENTFTN(TEMPLATE, template)(F90_Desc *dd, __INT_T *p_rank,
3232

3333
#include <string.h>
3434
#include "fort_vars.h"
35-
#if defined(TARGET_LINUX_X8664) || defined (TARGET_LINUX_POWER) || defined(TARGET_OSX_X8664)
35+
#if defined(TARGET_LINUX_X8664) || defined (TARGET_LINUX_POWER) || defined(TARGET_OSX_X8664) || defined(TARGET_LINUX_ARM32) || defined(TARGET_LINUX_ARM64)
3636
#include <unistd.h>
3737
#include <sys/wait.h>
3838
#endif
@@ -2849,7 +2849,7 @@ ENTF90(EXECCMDLINE, execcmdline)(DCHAR(command), __LOG_T *wait,
28492849

28502850
if (cmdstat)
28512851
store_int_kind(cmdstat, cmdstat_int_kind, 0);
2852-
#if defined(TARGET_LINUX_X8664) || defined(TARGET_OSX_X8664) || defined (TARGET_LINUX_POWER)
2852+
#if defined(TARGET_LINUX_X8664) || defined(TARGET_OSX_X8664) || defined(TARGET_LINUX_POWER) || defined(TARGET_LINUX_ARM32) || defined(TARGET_LINUX_ARM64)
28532853
pid_t pid, w;
28542854
int wstatus, ret;
28552855

runtime/flang/type.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static void sourced_alloc_and_assign_array(int extent, char *ab, char *bb, TYPE_
3636
static void sourced_alloc_and_assign_array_from_scalar(int extent, char *ab, char *bb, TYPE_DESC *td);
3737

3838
static void get_source_and_dest_sizes(F90_Desc *ad, F90_Desc *bd, int *dest_sz, int *src_sz, int *dest_is_array, int *src_is_array, TYPE_DESC **tad, TYPE_DESC **tbd, __INT_T flag);
39+
static int has_intrin_type(F90_Desc *dd);
3940

4041
#define ARG1_PTR 0x1
4142
#define ARG1_ALLOC 0x2
@@ -1676,6 +1677,8 @@ static struct type_desc *I8(__f03_ty_to_id)[__NTYPES] = {
16761677
0,
16771678
0,
16781679
0,
1680+
0,
1681+
0,
16791682
0};
16801683

16811684
void ENTF90(SET_INTRIN_TYPE, set_intrin_type)(F90_Desc *dd, __INT_T intrin_type)
@@ -1829,6 +1832,31 @@ void ENTF90(POLY_ASN_DEST_INTRIN,
18291832
ENTF90(POLY_ASN, poly_asn)(ab, ad, bb, bd, flag);
18301833
}
18311834

1835+
/** \brief This routine checks whether a descriptor is associated with an
1836+
* intrinsic type.
1837+
*
1838+
* \param dd is the descriptor we are testing.
1839+
*
1840+
* \return 1 if \param dd is associated with an intinsinc type, else 0.
1841+
*/
1842+
static int has_intrin_type(F90_Desc *dd)
1843+
{
1844+
int i;
1845+
OBJECT_DESC *td = (OBJECT_DESC *)dd;
1846+
int is_intrin_type = 0;
1847+
1848+
if (td->type == NULL)
1849+
return 0;
1850+
1851+
for(i=0; i < __NTYPES; ++i) {
1852+
if (td->type == I8(__f03_ty_to_id)[i]) {
1853+
return 1;
1854+
}
1855+
}
1856+
1857+
return 0;
1858+
}
1859+
18321860
void ENTF90(INIT_UNL_POLY_DESC, init_unl_poly_desc)(F90_Desc *dd, F90_Desc *sd,
18331861
__INT_T kind)
18341862
{
@@ -1842,12 +1870,16 @@ void ENTF90(INIT_UNL_POLY_DESC, init_unl_poly_desc)(F90_Desc *dd, F90_Desc *sd,
18421870
}
18431871
dd->kind = kind;
18441872
} else {
1845-
dd->len = (sd && sd->tag == __DESC) ? sd->len : 0;
1846-
dd->tag = __DESC;
1873+
dd->len = (sd && (sd->tag == __DESC || sd->tag == __POLY)) ? sd->len : 0;
1874+
dd->tag = __POLY;
18471875
dd->rank = 0;
18481876
dd->lsize = 0;
18491877
dd->gsize = 0;
18501878
dd->kind = kind;
1879+
if (sd && (sd->tag == __DESC || sd->tag == __POLY ||
1880+
has_intrin_type(sd))) {
1881+
ENTF90(SET_TYPE, set_type)(dd, sd);
1882+
}
18511883
}
18521884
}
18531885

test/f90_correct/inc/pp73.mk

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Copyright (c) 2019, NVIDIA CORPORATION. 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+
########## Make rule for test pp73 ########
18+
19+
20+
pp73: run
21+
22+
23+
build: $(SRC)/pp73.f90
24+
-$(RM) pp73.$(EXESUFFIX) core *.d *.mod FOR*.DAT FTN* ftn* fort.*
25+
@echo ------------------------------------ building test $@
26+
-$(FC) -c $(FFLAGS) $(LDFLAGS) $(SRC)/pp73.f90 -o pp73.$(OBJX)
27+
-$(FC) $(FFLAGS) $(LDFLAGS) pp73.$(OBJX) $(LIBS) -o pp73.$(EXESUFFIX)
28+
29+
30+
run:
31+
@echo ------------------------------------ executing test pp73
32+
pp73.$(EXESUFFIX)
33+
34+
verify: ;
35+

test/f90_correct/lit/pp73.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (c) 2017, NVIDIA CORPORATION. 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+
# Shared lit script for each tests. Run bash commands that run tests with make.
17+
18+
# RUN: KEEP_FILES=%keep FLAGS=%flags TEST_SRC=%s MAKE_FILE_DIR=%S/.. bash %S/runmake | tee %t
19+
# RUN: cat %t | FileCheck %S/runmake

test/f90_correct/src/pp73.f90

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
2+
!
3+
! Licensed under the Apache License, Version 2.0 (the "License");
4+
! you may not use this file except in compliance with the License.
5+
! You may obtain a copy of the License at
6+
!
7+
! http://www.apache.org/licenses/LICENSE-2.0
8+
!
9+
! Unless required by applicable law or agreed to in writing, software
10+
! distributed under the License is distributed on an "AS IS" BASIS,
11+
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
! See the License for the specific language governing permissions and
13+
! limitations under the License.
14+
!
15+
!
16+
! Tests subscripted pointer expressions that point to non-contiguous array
17+
! sections.
18+
19+
program main
20+
integer, pointer :: p1(:), p2(:)
21+
integer, target :: a(20)
22+
integer :: expect(8) = [3, 5, 7, 9, 11, 13, 15, 17]
23+
integer :: j
24+
a = [(j,j=1,20)]
25+
p1 => a(::2)
26+
p2(1:8) => p1(2:9)
27+
if (all(p2 .eq. expect)) then
28+
print *, 'PASS'
29+
else
30+
print *, 'FAIL'
31+
endif
32+
end program main

tools/flang1/flang1exe/ast.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,6 +3429,10 @@ simply_contiguous(int arr_ast)
34293429
}
34303430
break;
34313431
case A_SUBSCR:
3432+
sptr = memsym_of_ast(arr_ast);
3433+
if (POINTERG(sptr)) {
3434+
return CONTIGATTRG(sptr);
3435+
}
34323436
return contiguous_array_section(arr_ast);
34333437
}
34343438

tools/flang1/flang1exe/rest.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,6 +2050,10 @@ transform_call(int std, int ast)
20502050
handle_seq_section(entry, ele, i, std, &retval, &descr, 1,
20512051
inface_arg);
20522052
} else {
2053+
if (!DESCRG(sptr)) {
2054+
get_static_descriptor(sptr);
2055+
get_all_descriptors(sptr);
2056+
}
20532057
SPTR descr_sptr = DESCRG(sptr);
20542058
/* Set the INTERNREF flag of array descriptor to make sure host
20552059
subroutines' array descriptor is accessible for contained

tools/flang1/flang1exe/semant.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11383,6 +11383,7 @@ semant1(int rednum, SST *top)
1138311383
copy_sym_flags(sym, proc_interf_sptr);
1138411384
HCCSYMP(sym, 1);
1138511385
IS_PROC_PTR_IFACEP(sym, 1);
11386+
INTERFACEP(sym, 1);
1138611387
}
1138711388
proc_interf_sptr = sym;
1138811389
}

tools/flang1/flang1exe/semant.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,7 @@ int has_poly_mbr(int sptr, int flag);
16091609
void push_tbp_arg(ITEM *item);
16101610
ITEM *pop_tbp_arg(void);
16111611
void err307(char *, int, int);
1612+
void gen_init_unl_poly_desc(int dest_sdsc_ast, int src_sdsc_ast, int std);
16121613

16131614
/* xref.c */
16141615
void xrefinit(void);

0 commit comments

Comments
 (0)