Skip to content

Commit d2bfa70

Browse files
Merge branch 'main' into progress-bar-premerge-tests
2 parents 736bedb + e83abd7 commit d2bfa70

File tree

27 files changed

+423
-383
lines changed

27 files changed

+423
-383
lines changed

.ci/monolithic-linux.sh

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,15 @@
1313
# run only the relevant tests.
1414
#
1515

16-
set -ex
17-
set -o pipefail
16+
source .ci/utils.sh
1817

19-
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
20-
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
2118
INSTALL_DIR="${BUILD_DIR}/install"
22-
rm -rf "${BUILD_DIR}"
23-
24-
sccache --zero-stats
2519

2620
mkdir -p artifacts/reproducers
2721

28-
# Make sure any clang reproducers will end up as artifacts.
22+
# Make sure any clang reproducers will end up as artifacts
2923
export CLANG_CRASH_DIAGNOSTICS_DIR=`realpath artifacts/reproducers`
3024

31-
function at-exit {
32-
retcode=$?
33-
34-
sccache --show-stats > artifacts/sccache_stats.txt
35-
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
36-
cp "${BUILD_DIR}"/test-results.*.xml artifacts/ || :
37-
38-
# If building fails there will be no results files.
39-
shopt -s nullglob
40-
41-
if [[ "$GITHUB_STEP_SUMMARY" != "" ]]; then
42-
python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \
43-
$retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
44-
fi
45-
}
46-
trap at-exit EXIT
47-
48-
function start-group {
49-
groupname=$1
50-
if [[ "$GITHUB_ACTIONS" != "" ]]; then
51-
echo "::endgroup"
52-
echo "::group::$groupname"
53-
elif [[ "$POSTCOMMIT_CI" != "" ]]; then
54-
echo "@@@$STEP@@@"
55-
else
56-
echo "Starting $groupname"
57-
fi
58-
}
59-
6025
projects="${1}"
6126
targets="${2}"
6227
runtimes="${3}"

.ci/monolithic-windows.sh

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,7 @@
1313
# run only the relevant tests.
1414
#
1515

16-
set -ex
17-
set -o pipefail
18-
19-
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
20-
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
21-
22-
rm -rf "${BUILD_DIR}"
23-
24-
sccache --zero-stats
25-
function at-exit {
26-
retcode=$?
27-
28-
mkdir -p artifacts
29-
sccache --show-stats >> artifacts/sccache_stats.txt
30-
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
31-
cp "${BUILD_DIR}"/test-results.*.xml artifacts/ || :
32-
33-
# If building fails there will be no results files.
34-
shopt -s nullglob
35-
36-
if [[ "$GITHUB_STEP_SUMMARY" != "" ]]; then
37-
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \
38-
$retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
39-
fi
40-
}
41-
trap at-exit EXIT
42-
43-
function start-group {
44-
groupname=$1
45-
if [[ "$GITHUB_ACTIONS" != "" ]]; then
46-
echo "::endgroup"
47-
echo "::group::$groupname"
48-
elif [[ "$POSTCOMMIT_CI" != "" ]]; then
49-
echo "@@@$STEP@@@"
50-
else
51-
echo "Starting $groupname"
52-
fi
53-
}
16+
source .ci/utils.sh
5417

5518
projects="${1}"
5619
targets="${2}"

.ci/utils.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
#===----------------------------------------------------------------------===##
3+
#
4+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
# See https://llvm.org/LICENSE.txt for license information.
6+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
#
8+
#===----------------------------------------------------------------------===##
9+
10+
# This script performs some setup and contains some utilities used for in the
11+
# monolithic-linux.sh and monolithic-windows.sh scripts.
12+
13+
set -ex
14+
set -o pipefail
15+
16+
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
17+
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
18+
19+
rm -rf "${BUILD_DIR}"
20+
21+
sccache --zero-stats
22+
23+
function at-exit {
24+
retcode=$?
25+
26+
mkdir -p artifacts
27+
sccache --show-stats >> artifacts/sccache_stats.txt
28+
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
29+
cp "${BUILD_DIR}"/test-results.*.xml artifacts/ || :
30+
31+
# If building fails there will be no results files.
32+
shopt -s nullglob
33+
34+
if [[ "$GITHUB_STEP_SUMMARY" != "" ]]; then
35+
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \
36+
$retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
37+
fi
38+
}
39+
trap at-exit EXIT
40+
41+
function start-group {
42+
groupname=$1
43+
if [[ "$GITHUB_ACTIONS" != "" ]]; then
44+
echo "::endgroup"
45+
echo "::group::$groupname"
46+
elif [[ "$POSTCOMMIT_CI" != "" ]]; then
47+
echo "@@@$STEP@@@"
48+
else
49+
echo "Starting $groupname"
50+
fi
51+
}

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,14 @@ static bool compileModuleAndReadASTImpl(CompilerInstance &ImportingInstance,
14851485
return false;
14861486
}
14871487

1488+
// The module is built successfully, we can update its timestamp now.
1489+
if (ImportingInstance.getPreprocessor()
1490+
.getHeaderSearchInfo()
1491+
.getHeaderSearchOpts()
1492+
.ModulesValidateOncePerBuildSession) {
1493+
ImportingInstance.getModuleCache().updateModuleTimestamp(ModuleFileName);
1494+
}
1495+
14881496
return readASTAfterCompileModule(ImportingInstance, ImportLoc, ModuleNameLoc,
14891497
Module, ModuleFileName,
14901498
/*OutOfDate=*/nullptr, /*Missing=*/nullptr);

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5461,11 +5461,6 @@ ASTWriter::WriteAST(llvm::PointerUnion<Sema *, Preprocessor *> Subject,
54615461

54625462
WritingAST = false;
54635463

5464-
if (WritingModule && PPRef.getHeaderSearchInfo()
5465-
.getHeaderSearchOpts()
5466-
.ModulesValidateOncePerBuildSession)
5467-
ModCache.updateModuleTimestamp(OutputFile);
5468-
54695464
if (ShouldCacheASTInMemory) {
54705465
// Construct MemoryBuffer and update buffer manager.
54715466
ModCache.getInMemoryModuleCache().addBuiltPCM(

flang/include/flang/Lower/Cuda.h renamed to flang/include/flang/Lower/CUDA.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- Lower/Cuda.h -- Cuda Fortran utilities ------------------*- C++ -*-===//
1+
//===-- Lower/CUDA.h -- CUDA Fortran utilities ------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,6 +15,7 @@
1515

1616
#include "flang/Optimizer/Builder/FIRBuilder.h"
1717
#include "flang/Optimizer/Dialect/CUF/CUFOps.h"
18+
#include "flang/Runtime/allocator-registry-consts.h"
1819
#include "flang/Semantics/tools.h"
1920
#include "mlir/Dialect/Func/IR/FuncOps.h"
2021
#include "mlir/Dialect/OpenACC/OpenACC.h"
@@ -37,6 +38,15 @@ static inline unsigned getAllocatorIdx(const Fortran::semantics::Symbol &sym) {
3738
return kDefaultAllocator;
3839
}
3940

41+
void initializeDeviceComponentAllocator(
42+
Fortran::lower::AbstractConverter &converter,
43+
const Fortran::semantics::Symbol &sym, const fir::MutableBoxValue &box);
44+
45+
mlir::Type gatherDeviceComponentCoordinatesAndType(
46+
fir::FirOpBuilder &builder, mlir::Location loc,
47+
const Fortran::semantics::Symbol &sym, fir::RecordType recTy,
48+
llvm::SmallVector<mlir::Value> &coordinates);
49+
4050
} // end namespace Fortran::lower
4151

4252
#endif // FORTRAN_LOWER_CUDA_H

flang/lib/Lower/Allocatable.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#include "flang/Lower/Allocatable.h"
1414
#include "flang/Evaluate/tools.h"
1515
#include "flang/Lower/AbstractConverter.h"
16+
#include "flang/Lower/CUDA.h"
1617
#include "flang/Lower/ConvertType.h"
1718
#include "flang/Lower/ConvertVariable.h"
18-
#include "flang/Lower/Cuda.h"
1919
#include "flang/Lower/IterationSpace.h"
2020
#include "flang/Lower/Mangler.h"
2121
#include "flang/Lower/OpenACC.h"
@@ -445,10 +445,14 @@ class AllocateStmtHelper {
445445
/*mustBeHeap=*/true);
446446
}
447447

448-
void postAllocationAction(const Allocation &alloc) {
448+
void postAllocationAction(const Allocation &alloc,
449+
const fir::MutableBoxValue &box) {
449450
if (alloc.getSymbol().test(Fortran::semantics::Symbol::Flag::AccDeclare))
450451
Fortran::lower::attachDeclarePostAllocAction(converter, builder,
451452
alloc.getSymbol());
453+
if (Fortran::semantics::HasCUDAComponent(alloc.getSymbol()))
454+
Fortran::lower::initializeDeviceComponentAllocator(
455+
converter, alloc.getSymbol(), box);
452456
}
453457

454458
void setPinnedToFalse() {
@@ -481,7 +485,7 @@ class AllocateStmtHelper {
481485
// Pointers must use PointerAllocate so that their deallocations
482486
// can be validated.
483487
genInlinedAllocation(alloc, box);
484-
postAllocationAction(alloc);
488+
postAllocationAction(alloc, box);
485489
setPinnedToFalse();
486490
return;
487491
}
@@ -504,7 +508,7 @@ class AllocateStmtHelper {
504508
genCudaAllocate(builder, loc, box, errorManager, alloc.getSymbol());
505509
}
506510
fir::factory::syncMutableBoxFromIRBox(builder, loc, box);
507-
postAllocationAction(alloc);
511+
postAllocationAction(alloc, box);
508512
errorManager.assignStat(builder, loc, stat);
509513
}
510514

@@ -647,7 +651,7 @@ class AllocateStmtHelper {
647651
setPinnedToFalse();
648652
}
649653
fir::factory::syncMutableBoxFromIRBox(builder, loc, box);
650-
postAllocationAction(alloc);
654+
postAllocationAction(alloc, box);
651655
errorManager.assignStat(builder, loc, stat);
652656
}
653657

flang/lib/Lower/Bridge.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
#include "flang/Lower/Bridge.h"
1414

1515
#include "flang/Lower/Allocatable.h"
16+
#include "flang/Lower/CUDA.h"
1617
#include "flang/Lower/CallInterface.h"
1718
#include "flang/Lower/Coarray.h"
1819
#include "flang/Lower/ConvertCall.h"
1920
#include "flang/Lower/ConvertExpr.h"
2021
#include "flang/Lower/ConvertExprToHLFIR.h"
2122
#include "flang/Lower/ConvertType.h"
2223
#include "flang/Lower/ConvertVariable.h"
23-
#include "flang/Lower/Cuda.h"
2424
#include "flang/Lower/DirectivesCommon.h"
2525
#include "flang/Lower/HostAssociations.h"
2626
#include "flang/Lower/IO.h"

flang/lib/Lower/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ add_flang_library(FortranLower
1515
ConvertProcedureDesignator.cpp
1616
ConvertType.cpp
1717
ConvertVariable.cpp
18+
CUDA.cpp
1819
CustomIntrinsicCall.cpp
1920
HlfirIntrinsics.cpp
2021
HostAssociations.cpp

0 commit comments

Comments
 (0)