Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
34 changes: 7 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,14 @@ set(CMAKE_CXX_EXTENSIONS NO)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_UPPER)
if(BUILD_TYPE_UPPER STREQUAL "DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG_INIT
"-gdwarf-4"
CACHE STRING "Flags used by the compiler during debug builds" FORCE)
set(CMAKE_C_FLAGS_DEBUG_INIT
"-gdwarf-4"
CACHE STRING "Flags used by the compiler during debug builds" FORCE)
set(CMAKE_CUDA_FLAGS_DEBUG_INIT
"-gdwarf-4"
CACHE STRING "Flags used by the compiler during debug builds" FORCE)
message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG_INIT}")
message(STATUS "CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG_INIT}")
message(STATUS "CMAKE_CUDA_FLAGS_DEBUG: ${CMAKE_CUDA_FLAGS_DEBUG_INIT}")
add_compile_options("-gdwarf-4")
elseif(BUILD_TYPE_UPPER STREQUAL "RELWITHDEBINFO")
set(CMAKE_CXX_FLAGS_DEBUG_INIT
"-gdwarf-4"
CACHE STRING "Flags used by the compiler during debug builds" FORCE)
set(CMAKE_C_FLAGS_DEBUG_INIT
"-gdwarf-4"
CACHE STRING "Flags used by the compiler during debug builds" FORCE)
set(CMAKE_CUDA_FLAGS_DEBUG_INIT
"-gdwarf-4"
CACHE STRING "Flags used by the compiler during debug builds" FORCE)
message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG_INIT}")
message(STATUS "CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG_INIT}")
message(STATUS "CMAKE_CUDA_FLAGS_DEBUG: ${CMAKE_CUDA_FLAGS_DEBUG_INIT}")
if(BUILD_TYPE_UPPER STREQUAL "DEBUG" OR BUILD_TYPE_UPPER STREQUAL
"RELWITHDEBINFO")
add_compile_options("-gdwarf-4")
foreach(lang CXX C CUDA)
set(CMAKE_${lang}_FLAGS_${BUILD_TYPE_UPPER}_INIT
"-gdwarf-4"
CACHE STRING "Flags used by the compiler during debug builds" FORCE)
endforeach()
endif()

option(MNEME_ENABLE_CUDA "Enable CUDA" OFF)
Expand Down
39 changes: 39 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and leaders pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Scope

This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Contributing to Mneme

Thank you for your interest in contributing to Mneme! We welcome contributions of all forms, including bug fixes, new features, documentation improvements, and performance enhancements.

## Development Workflow

1. **Fork and Clone**: Fork the repository and clone it locally.
2. **Branch**: Create a feature branch from `develop`.
```bash
git checkout -b feature/my-new-feature develop
```
3. **Implement**: Write your code, adhering to the project's coding style.
4. **Test**: Ensure your changes pass existing tests and add new tests where appropriate.
- C++ Tests: Built with CMake (Enable `-DMNEME_ENABLE_TESTS=On`).
- Python Tests: Run via `pytest`.
5. **Commit**: Use descriptive commit messages.
6. **Push and PR**: Push your branch and open a Pull Request against `develop`.

## Coding Style

### C++
We follow the LLVM coding style with slight modifications.
- Use **clang-format** to format your code before submitting. A `.clang-format` file is provided in the root directory.
- Indentation: 2 spaces.
- Headers: Use include guards or `#pragma once`.

### Python
- Use **Black** for formatting.
- Use **Isort** for import sorting.
- Type hints are encouraged for public APIs.
- Configuration is available in `pyproject.toml`.

## Reporting Issues

Please search existing issues before reporting a new one. When opening an issue, provide:
- Mneme version / Commit hash.
- System information (OS, GPU, Driver version).
- Reproduction steps or a minimal example.
3 changes: 3 additions & 0 deletions cmake/MnemeFunctions.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

function(add_mneme target)
# Link proteus as a shared library for preloading.
# TODO: Change to static linking and use linker wrapper flags for interposing.
Expand Down
3 changes: 3 additions & 0 deletions cmake/SetupLLVM.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Add the location of LLVMConfig.cmake to CMake search paths (so that
# find_package can locate it)

Expand Down
3 changes: 3 additions & 0 deletions include/mneme/DeviceTraits.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once
#include <dlfcn.h>
#include <optional>
Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemeInternal.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifdef MNEME_ENABLE_HIP
#include "mneme/MnemeRecordHIP.hpp"
using MnemeRecordImplT = mneme::MnemeRecorderHIP;
Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemeJITProteus.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <proteus/CoreLLVM.h>
#include <proteus/CoreLLVMDevice.h>

Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemeKernelInfo.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once

#include <llvm/ADT/DenseMap.h>
Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemeLLVMUtils.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once
#include "llvm/ADT/DenseMapInfo.h"
#include <llvm/ADT/SmallVector.h>
Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemeLogger.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once

#ifdef MNEME_ENABLE_LOGGER
Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemeMemory.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once

#include <cstdint>
Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemePageManager.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once
#include <llvm/ADT/StringRef.h>
#include <llvm/Support/raw_ostream.h>
Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemePython.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <mneme/DeviceTraits.hpp>
#include <mneme/MnemeReplay.hpp>

Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemeRecord.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once

#include "mneme/MnemeLLVMUtils.hpp"
Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemeReplay.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <cstdint>
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/IR/LLVMContext.h>
Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemeSnapshot.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once
#include <cstdint>
#include <filesystem>
Expand Down
3 changes: 3 additions & 0 deletions include/mneme/MnemeUtils.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once
#include <cstdint>
#include <iomanip>
Expand Down
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 88
target-version = ['py37', 'py38', 'py39', 'py310']
include = '\.pyi?$'

[tool.isort]
profile = "black"
multi_line_output = 3

[tool.pytest.ini_options]
testpaths = ["python/tests"]
addopts = "--cov=mneme --cov-report=xml"

[tool.coverage.run]
omit = ["*/llvm/*"]
3 changes: 3 additions & 0 deletions python/mneme/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .llvm import initfini

initfini.initialize()
Expand Down
3 changes: 3 additions & 0 deletions python/mneme/async_executor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) 2021-2024. LLNL-CODE-2000766 and Mneme Contributors
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

import queue
import threading
import time
Expand Down
Loading