Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/peter-evans/create…
Browse files Browse the repository at this point in the history
…-pull-request-6
  • Loading branch information
tgymnich authored Feb 27, 2024
2 parents 07281c0 + ca06ef3 commit db760ec
Show file tree
Hide file tree
Showing 22 changed files with 973 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bcload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: mkdir
run: cd enzyme && rm -rf build && mkdir build
- name: cmake
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: mkdir
run: rm -rf build && mkdir build
- name: cmake
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: mkdir
run: rm -rf build && mkdir build
- name: cmake
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
docs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: mattnotmitt/doxygen-action@v1.9.2
- uses: mattnotmitt/doxygen-action@v1.9.8
with:
working-directory: 'enzyme/'
doxyfile-path: 'doxygen.cfg'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/enzyme-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
sudo sed -i 's/add_executable(llvm-omp-device-info IMPORTED)//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
sudo sed -i 's/llvm-omp-device-info//g' /usr/lib/llvm-${{matrix.llvm}}/lib/cmake/llvm/LLVMExports*.cmake
fi
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: mkdir
run: rm -rf build && mkdir build
- name: cmake
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
brew update
brew install llvm@${{ matrix.llvm }} make cmake
sudo python3 -m pip install --upgrade pip lit requests
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: mkdir
run: rm -rf build && mkdir build
- name: cmake
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
run: |
brew install llvm@${{ matrix.llvm }} make cmake gcc
sudo python3 -m pip install --upgrade pip lit
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: mkdir
run: rm -rf build && mkdir build
- name: cmake
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/enzyme-julia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
- x64
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: 'wsmoses/Enzyme.jl'
path: ./jl
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/enzyme-mlir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ jobs:
sudo apt-get update
sudo apt-get install -y binutils ninja-build cmake gcc g++ python3 python3-dev
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: 'Enzyme'

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'llvm/llvm-project'
ref: 'bc82cfb38d83f1afeb2c290aa472c2e2e88919cb'
Expand All @@ -46,7 +46,7 @@ jobs:

- name: Cache MLIR
id: cache-mlir
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: llvm-project/mlir-build
key: ${{ matrix.llbuild }}-${{ matrix.os }}-mlir-${{ steps.mlir-commit.outputs.sha_short }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.16.2
with:
source: 'enzyme/Enzyme enzyme/tools/enzyme-tblgen'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fortran.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
sudo apt-get update && sudo apt-get install -y intel-oneapi-compiler-fortran-${{ matrix.ifx }} intel-oneapi-mpi-${{ matrix.mpi }} intel-oneapi-mpi-devel-${{ matrix.mpi }}
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: generate build system
run: |
rm -rf build && mkdir build && cd build
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ jobs:
name: Enzyme Tag CI
runs-on: ubuntu-latest
steps:
- uses: tibdex/github-app-token@v1
- uses: actions/create-github-app-token@v1
id: generate_token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
repository: JuliaPackaging/Yggdrasil
repositories: JuliaPackaging/Yggdrasil

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'JuliaPackaging/Yggdrasil'
path: ygg

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: enz
- name: replace
Expand Down
15 changes: 15 additions & 0 deletions enzyme/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ gentbl(
],
)

gentbl(
name = "include-utils",
tbl_outs = [(
"-gen-header-strings",
"IncludeUtils.inc",
)],
tblgen = ":enzyme-tblgen",
td_file = "Enzyme/Clang/include_utils.td",
td_srcs = ["Enzyme/Clang/include_utils.td"],
deps = [
":enzyme-tblgen",
],
)

cc_library(
name = "EnzymeStatic",
srcs = glob(
Expand All @@ -167,6 +181,7 @@ cc_library(
data = ["@llvm-project//clang:builtin_headers_gen"],
visibility = ["//visibility:public"],
deps = [
"include-utils",
":binop-derivatives",
":blas-attributor",
":blas-derivatives",
Expand Down
4 changes: 2 additions & 2 deletions enzyme/Enzyme/AdjointGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4821,7 +4821,7 @@ class AdjointGenerator : public llvm::InstVisitor<AdjointGenerator> {
if (call.getAttributes().hasParamAttr(i, attr)) {
if (gutils->getWidth() == 1) {
structAttrs[args.size()].push_back(call.getParamAttr(i, attr));
} else if (attr == "enzymejl_returnRoots") {
} else if (attr == std::string("enzymejl_returnRoots")) {
structAttrs[args.size()].push_back(
Attribute::get(call.getContext(), "enzymejl_returnRoots_v"));
}
Expand Down Expand Up @@ -5155,7 +5155,7 @@ class AdjointGenerator : public llvm::InstVisitor<AdjointGenerator> {
if (gutils->getWidth() == 1) {
structAttrs[pre_args.size()].push_back(
call.getParamAttr(i, attr));
} else if (attr == "enzymejl_returnRoots") {
} else if (attr == std::string("enzymejl_returnRoots")) {
structAttrs[pre_args.size()].push_back(
Attribute::get(call.getContext(), "enzymejl_returnRoots_v"));
}
Expand Down
6 changes: 6 additions & 0 deletions enzyme/Enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ add_public_tablegen_target(BlasDeclarationsIncGen)
add_public_tablegen_target(BlasTAIncGen)
add_public_tablegen_target(BlasDiffUseIncGen)

set(LLVM_TARGET_DEFINITIONS Clang/include_utils.td)
enzyme_tablegen(IncludeUtils.inc -gen-header-strings)
add_public_tablegen_target(IncludeUtilsIncGen)

include_directories(${CMAKE_CURRENT_BINARY_DIR})

set(LLVM_LINK_COMPONENTS Demangle)
Expand Down Expand Up @@ -74,6 +78,7 @@ if (${Clang_FOUND})
LLVM
)
target_compile_definitions(ClangEnzyme-${LLVM_VERSION_MAJOR} PUBLIC ENZYME_RUNPASS)
add_dependencies(ClangEnzyme-${LLVM_VERSION_MAJOR} IncludeUtilsIncGen)
endif()
add_llvm_library( LLDEnzyme-${LLVM_VERSION_MAJOR}
${ENZYME_SRC} Clang/EnzymePassLoader.cpp
Expand Down Expand Up @@ -107,6 +112,7 @@ if (${Clang_FOUND})
clang
)
target_compile_definitions(ClangEnzyme-${LLVM_VERSION_MAJOR} PUBLIC ENZYME_RUNPASS)
add_dependencies(ClangEnzyme-${LLVM_VERSION_MAJOR} IncludeUtilsIncGen)
endif()
add_llvm_library( LLDEnzyme-${LLVM_VERSION_MAJOR}
${ENZYME_SRC} Clang/EnzymePassLoader.cpp
Expand Down
37 changes: 37 additions & 0 deletions enzyme/Enzyme/Clang/EnzymeClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclGroup.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/MacroBuilder.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/SemaDiagnostic.h"

#include "../Utils.h"

#include "IncludeUtils.inc"

using namespace clang;

#if LLVM_VERSION_MAJOR >= 18
Expand Down Expand Up @@ -134,6 +138,39 @@ class EnzymePlugin final : public clang::ASTConsumer {
Builder.defineMacro("ENZYME_VERSION_PATCH",
std::to_string(ENZYME_VERSION_PATCH));
CI.getPreprocessor().setPredefines(Predefines.str());

auto baseFS = &CI.getFileManager().getVirtualFileSystem();
llvm::vfs::OverlayFileSystem *fuseFS(
new llvm::vfs::OverlayFileSystem(baseFS));
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> fs(
new llvm::vfs::InMemoryFileSystem());

struct tm y2k = {};

y2k.tm_hour = 0;
y2k.tm_min = 0;
y2k.tm_sec = 0;
y2k.tm_year = 100;
y2k.tm_mon = 0;
y2k.tm_mday = 1;
time_t timer = mktime(&y2k);
for (const auto &pair : include_headers) {
fs->addFile(StringRef(pair[0]), timer,
llvm::MemoryBuffer::getMemBuffer(
StringRef(pair[1]), StringRef(pair[0]),
/*RequiresNullTerminator*/ true));
}

fuseFS->pushOverlay(fs);
fuseFS->pushOverlay(baseFS);
CI.getFileManager().setVirtualFileSystem(fuseFS);

auto DE = CI.getFileManager().getDirectoryRef("/enzymeroot");
assert(DE);
auto DL = DirectoryLookup(*DE, SrcMgr::C_User,
/*isFramework=*/false);
CI.getPreprocessor().getHeaderSearchInfo().AddSearchPath(DL,
/*isAngled=*/true);
}
~EnzymePlugin() {}
void HandleTranslationUnit(ASTContext &context) override {}
Expand Down
Loading

0 comments on commit db760ec

Please sign in to comment.