Skip to content

P-ISA Functional Modeler and supporting common libraries #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 19, 2025
Merged
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
78 changes: 78 additions & 0 deletions functional_modeler/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
---
Language: Cpp
BasedOnStyle: Microsoft
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveMacros: true
AlignOperands: true
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
ColumnLimit: 0
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
FixNamespaceComments: true
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
NamespaceIndentation: None
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Right
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
ReflowComments: false
UseTab: Never
47 changes: 47 additions & 0 deletions functional_modeler/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: mixed-line-ending
- id: check-byte-order-marker
- repo: https://github.com/crate-ci/typos
rev: v1.20.9 # Updated 2024/04
hooks:
- id: typos
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.1 # Updated 2023/07
hooks:
- id: insert-license
name: insert-license-shell
files: \.(sh|py)$
args:
- --license-filepath
# defaults to: LICENSE.txt
- HEADER
- id: insert-license
name: insert-license-cpp
files: \.(c|cc|cxx|cpp|h|hpp|hxx|inl|h.in)$
args:
- --license-filepath
# defaults to: LICENSE.txt
- HEADER
- --comment-style
- // # defaults to: #
- repo: local
hooks:
- id: clang-format-14
name: clang-format-14
entry: clang-format-14
language: system
files: \.(c|cc|cxx|cpp|h|hpp|hxx|inl)$
args: ["-i", "--style=file"]
- id: cpplint
name: cpplint
entry: cpplint
language: system
files: \.(c|cc|cxx|cpp|h|hpp|hxx)$
args:
- --recursive
74 changes: 74 additions & 0 deletions functional_modeler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
################################
# P-ISA Tools Main Entrypoint
################################

cmake_minimum_required(VERSION 3.22)

# General Setup
if(CMAKE_BUILD_TYPE)
set(RELEASE_TYPES
Debug
Release
RelWithDebInfo
MinSizeRel)
list(FIND RELEASE_TYPES ${CMAKE_BUILD_TYPE} INDEX_FOUND)
if(${INDEX_FOUND} EQUAL -1)
message(
FATAL_ERROR
"CMAKE_BUILD_TYPE must be one of Debug, Release, RelWithDebInfo, or MinSizeRel"
)
endif()
else()
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of Build" FORCE)
endif()

option(ENABLE_DATA_FORMATS "Enable support for the data formats library" OFF)
message(ENABLE_DATA_FORMATS="${ENABLE_DATA_FORMATS}")

option(ENABLE_FUNCTIONAL_MODELER "Enable building of functional modeler" ON)
message(ENABLE_FUNCTIONAL_MODELER="${ENABLE_FUNCTIONAL_MODELER}")

option(ENABLE_PROGRAM_MAPPER "Enable building of program mapper" OFF)
message(ENABLE_PROGRAM_MAPPER="${ENABLE_PROGRAM_MAPPER}")

option(ENABLE_P_ISA_UTILITIES "Enable building of p-isa utilities" OFF)
message(ENABLE_P_ISA_UTILITIES="${ENABLE_P_ISA_UTILITIES}")

configure_file(common/config.h.in "${CMAKE_BINARY_DIR}/p_isa_tools_config/config.h")

project(p_isa_tools LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Define standard installation directories (GNU)
include(GNUInstallDirs)

# Set default output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")

# Find OpenMP on system
find_package(OpenMP REQUIRED)

# External fetch and build dependencies
include(cmake/dependencies.cmake)

# Policy is explicit header locations
set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/p_isa_tools_config/)

# Include *.h files in sources so they appear in IDEs
file(GLOB_RECURSE IDE_HEADERS program_mapper/*.h functional_modeler/*.h dependencies/*.h common/*.h)

# Build sub-directories
add_subdirectory(common)
if(ENABLE_FUNCTIONAL_MODELER)
add_subdirectory(functional_modeler)
endif()
if(ENABLE_PROGRAM_MAPPER)
add_subdirectory(program_mapper)
endif()
if(ENABLE_P_ISA_UTILITIES)
add_subdirectory(p_isa_utilities)
endif()
11 changes: 11 additions & 0 deletions functional_modeler/CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (C) 2020 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

# Some of these filters can be removed once existing code permits
filter=-whitespace
filter=-readability/todo
filter=-runtime/references
filter=-runtime/explicit
filter=-build/c++11
filter=-build/namespaces
filter=-build/include
59 changes: 59 additions & 0 deletions functional_modeler/cmake/dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

include(FetchContent)
FetchContent_Declare(
json_for_modern_cpp
# v3.11.2 released Aug 2023
URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz
URL_HASH SHA256=8c4b26bf4b422252e13f332bc5e388ec0ab5c3443d24399acb675e68278d341f
)

FetchContent_MakeAvailable(json_for_modern_cpp)

FetchContent_Declare(
argmap
# TODO at the mo, grabs the latest this should change once versioned
URL https://raw.githubusercontent.com/helibproject/argmap/main/argmap.h
DOWNLOAD_NO_EXTRACT TRUE
)

FetchContent_GetProperties(argmap)
if (NOT argmap_POPULATED)
FetchContent_Populate(argmap)
include_directories(${argmap_SOURCE_DIR})
endif()

FetchContent_Declare(
snap
# commit from Feb 2023
GIT_REPOSITORY https://github.com/snap-stanford/snap.git
GIT_TAG 6924a035aabd1ce0a547b94e995e142f29eb5040
)

FetchContent_GetProperties(snap)
if (NOT snap_POPULATED)
FetchContent_Populate(snap)
message(STATUS "Building SNAP, this may take a while ...")
execute_process(COMMAND make -j
WORKING_DIRECTORY ${snap_SOURCE_DIR}
OUTPUT_QUIET
ERROR_QUIET
OUTPUT_FILE ${FETCHCONTENT_BASE_DIR}/snap.stdout
ERROR_FILE ${FETCHCONTENT_BASE_DIR}/snap.stderr
)
add_library(snap OBJECT IMPORTED GLOBAL)
set_target_properties(snap PROPERTIES IMPORTED_OBJECTS ${snap_SOURCE_DIR}/snap-core/Snap.o)
include_directories(${snap_SOURCE_DIR}/snap-core ${snap_SOURCE_DIR}/glib-core)
message(STATUS "Finished building SNAP")
endif()

if(ENABLE_DATA_FORMATS)
find_package(HERACLES_DATA_FORMATS CONFIG)
if(NOT HERACLES_DATA_FORMATS_FOUND)
FetchContent_Declare(
heracles_data_formats
GIT_REPOSITORY git@github.com:IntelLabs/HERACLES-data-formats.git
GIT_TAG main
)
FetchContent_MakeAvailable(heracles_data_formats)
endif()
endif()
15 changes: 15 additions & 0 deletions functional_modeler/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
##################
# HERACLES Utils
##################

project(common)

set(SRCS
p_isa/p_isa_instruction.cpp
p_isa/parser/p_isa_parser.cpp
p_isa/p_isa_performance_modeler.h
p_isa/p_isa_performance_modeler.cpp
)

add_library(common OBJECT ${SRCS})
target_include_directories(common PRIVATE ${INCLUDE_DIRS})
4 changes: 4 additions & 0 deletions functional_modeler/common/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (C) 2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#cmakedefine01 ENABLE_DATA_FORMATS
Loading