Skip to content

Commit 643c020

Browse files
jobottlechristopherngutierrezkylaneracefaberga
authored
P-ISA Functional Modeler and supporting common libraries (#58)
* Initial check in of the P-ISA Functional Modeler and supporting common files --------- Co-authored-by: christopherngutierrez <[email protected]> Co-authored-by: Kylan Race <[email protected]> Co-authored-by: Flavio Bergamaschi <[email protected]>
1 parent b884b9e commit 643c020

36 files changed

+9639
-5
lines changed

functional_modeler/.clang-format

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
---
3+
Language: Cpp
4+
BasedOnStyle: Microsoft
5+
AccessModifierOffset: -4
6+
AlignAfterOpenBracket: Align
7+
AlignConsecutiveAssignments: true
8+
AlignConsecutiveMacros: true
9+
AlignOperands: true
10+
AlignTrailingComments: false
11+
AllowAllArgumentsOnNextLine: true
12+
AllowAllConstructorInitializersOnNextLine: true
13+
AllowAllParametersOfDeclarationOnNextLine: true
14+
AllowShortCaseLabelsOnASingleLine: false
15+
AllowShortFunctionsOnASingleLine: Inline
16+
AllowShortIfStatementsOnASingleLine: false
17+
AllowShortLoopsOnASingleLine: false
18+
AlwaysBreakAfterDefinitionReturnType: None
19+
AlwaysBreakAfterReturnType: None
20+
AlwaysBreakTemplateDeclarations: true
21+
BinPackArguments: true
22+
BinPackParameters: true
23+
BraceWrapping:
24+
AfterCaseLabel: true
25+
AfterClass: true
26+
AfterControlStatement: true
27+
AfterEnum: true
28+
AfterFunction: true
29+
AfterNamespace: false
30+
AfterObjCDeclaration: true
31+
AfterStruct: true
32+
AfterUnion: true
33+
BeforeCatch: true
34+
BeforeElse: true
35+
IndentBraces: false
36+
BreakBeforeBinaryOperators: NonAssignment
37+
BreakBeforeBraces: Custom
38+
BreakBeforeTernaryOperators: false
39+
BreakConstructorInitializers: AfterColon
40+
ColumnLimit: 0
41+
CompactNamespaces: false
42+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
43+
ConstructorInitializerIndentWidth: 4
44+
ContinuationIndentWidth: 4
45+
Cpp11BracedListStyle: false
46+
DerivePointerAlignment: false
47+
FixNamespaceComments: true
48+
IndentCaseLabels: false
49+
IndentPPDirectives: None
50+
IndentWidth: 4
51+
NamespaceIndentation: None
52+
PenaltyBreakBeforeFirstCallParameter: 19
53+
PenaltyBreakComment: 300
54+
PenaltyBreakFirstLessLess: 120
55+
PenaltyBreakString: 1000
56+
PenaltyBreakTemplateDeclaration: 10
57+
PenaltyExcessCharacter: 1000000
58+
PenaltyReturnTypeOnItsOwnLine: 1000
59+
PointerAlignment: Right
60+
SortIncludes: true
61+
SortUsingDeclarations: true
62+
SpaceAfterCStyleCast: false
63+
SpaceAfterLogicalNot: false
64+
SpaceBeforeAssignmentOperators: true
65+
SpaceBeforeCpp11BracedList: false
66+
SpaceBeforeCtorInitializerColon: true
67+
SpaceBeforeInheritanceColon: true
68+
SpaceBeforeParens: ControlStatements
69+
SpaceBeforeRangeBasedForLoopColon: true
70+
SpaceInEmptyParentheses: false
71+
SpacesBeforeTrailingComments: 1
72+
SpacesInAngles: false
73+
SpacesInContainerLiterals: true
74+
SpacesInCStyleCastParentheses: false
75+
SpacesInParentheses: false
76+
SpacesInSquareBrackets: false
77+
ReflowComments: false
78+
UseTab: Never
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-merge-conflict
8+
- id: mixed-line-ending
9+
- id: check-byte-order-marker
10+
- repo: https://github.com/crate-ci/typos
11+
rev: v1.20.9 # Updated 2024/04
12+
hooks:
13+
- id: typos
14+
- repo: https://github.com/Lucas-C/pre-commit-hooks
15+
rev: v1.5.1 # Updated 2023/07
16+
hooks:
17+
- id: insert-license
18+
name: insert-license-shell
19+
files: \.(sh|py)$
20+
args:
21+
- --license-filepath
22+
# defaults to: LICENSE.txt
23+
- HEADER
24+
- id: insert-license
25+
name: insert-license-cpp
26+
files: \.(c|cc|cxx|cpp|h|hpp|hxx|inl|h.in)$
27+
args:
28+
- --license-filepath
29+
# defaults to: LICENSE.txt
30+
- HEADER
31+
- --comment-style
32+
- // # defaults to: #
33+
- repo: local
34+
hooks:
35+
- id: clang-format-14
36+
name: clang-format-14
37+
entry: clang-format-14
38+
language: system
39+
files: \.(c|cc|cxx|cpp|h|hpp|hxx|inl)$
40+
args: ["-i", "--style=file"]
41+
- id: cpplint
42+
name: cpplint
43+
entry: cpplint
44+
language: system
45+
files: \.(c|cc|cxx|cpp|h|hpp|hxx)$
46+
args:
47+
- --recursive

functional_modeler/CMakeLists.txt

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
################################
2+
# P-ISA Tools Main Entrypoint
3+
################################
4+
5+
cmake_minimum_required(VERSION 3.22)
6+
7+
# General Setup
8+
if(CMAKE_BUILD_TYPE)
9+
set(RELEASE_TYPES
10+
Debug
11+
Release
12+
RelWithDebInfo
13+
MinSizeRel)
14+
list(FIND RELEASE_TYPES ${CMAKE_BUILD_TYPE} INDEX_FOUND)
15+
if(${INDEX_FOUND} EQUAL -1)
16+
message(
17+
FATAL_ERROR
18+
"CMAKE_BUILD_TYPE must be one of Debug, Release, RelWithDebInfo, or MinSizeRel"
19+
)
20+
endif()
21+
else()
22+
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of Build" FORCE)
23+
endif()
24+
25+
option(ENABLE_DATA_FORMATS "Enable support for the data formats library" OFF)
26+
message(ENABLE_DATA_FORMATS="${ENABLE_DATA_FORMATS}")
27+
28+
option(ENABLE_FUNCTIONAL_MODELER "Enable building of functional modeler" ON)
29+
message(ENABLE_FUNCTIONAL_MODELER="${ENABLE_FUNCTIONAL_MODELER}")
30+
31+
option(ENABLE_PROGRAM_MAPPER "Enable building of program mapper" OFF)
32+
message(ENABLE_PROGRAM_MAPPER="${ENABLE_PROGRAM_MAPPER}")
33+
34+
option(ENABLE_P_ISA_UTILITIES "Enable building of p-isa utilities" OFF)
35+
message(ENABLE_P_ISA_UTILITIES="${ENABLE_P_ISA_UTILITIES}")
36+
37+
configure_file(common/config.h.in "${CMAKE_BINARY_DIR}/p_isa_tools_config/config.h")
38+
39+
project(p_isa_tools LANGUAGES CXX)
40+
41+
set(CMAKE_CXX_STANDARD 17)
42+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
43+
44+
# Define standard installation directories (GNU)
45+
include(GNUInstallDirs)
46+
47+
# Set default output directories
48+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
49+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
50+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
51+
52+
# Find OpenMP on system
53+
find_package(OpenMP REQUIRED)
54+
55+
# External fetch and build dependencies
56+
include(cmake/dependencies.cmake)
57+
58+
# Policy is explicit header locations
59+
set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/p_isa_tools_config/)
60+
61+
# Include *.h files in sources so they appear in IDEs
62+
file(GLOB_RECURSE IDE_HEADERS program_mapper/*.h functional_modeler/*.h dependencies/*.h common/*.h)
63+
64+
# Build sub-directories
65+
add_subdirectory(common)
66+
if(ENABLE_FUNCTIONAL_MODELER)
67+
add_subdirectory(functional_modeler)
68+
endif()
69+
if(ENABLE_PROGRAM_MAPPER)
70+
add_subdirectory(program_mapper)
71+
endif()
72+
if(ENABLE_P_ISA_UTILITIES)
73+
add_subdirectory(p_isa_utilities)
74+
endif()

functional_modeler/CPPLINT.cfg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (C) 2020 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Some of these filters can be removed once existing code permits
5+
filter=-whitespace
6+
filter=-readability/todo
7+
filter=-runtime/references
8+
filter=-runtime/explicit
9+
filter=-build/c++11
10+
filter=-build/namespaces
11+
filter=-build/include
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
include(FetchContent)
3+
FetchContent_Declare(
4+
json_for_modern_cpp
5+
# v3.11.2 released Aug 2023
6+
URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz
7+
URL_HASH SHA256=8c4b26bf4b422252e13f332bc5e388ec0ab5c3443d24399acb675e68278d341f
8+
)
9+
10+
FetchContent_MakeAvailable(json_for_modern_cpp)
11+
12+
FetchContent_Declare(
13+
argmap
14+
# TODO at the mo, grabs the latest this should change once versioned
15+
URL https://raw.githubusercontent.com/helibproject/argmap/main/argmap.h
16+
DOWNLOAD_NO_EXTRACT TRUE
17+
)
18+
19+
FetchContent_GetProperties(argmap)
20+
if (NOT argmap_POPULATED)
21+
FetchContent_Populate(argmap)
22+
include_directories(${argmap_SOURCE_DIR})
23+
endif()
24+
25+
FetchContent_Declare(
26+
snap
27+
# commit from Feb 2023
28+
GIT_REPOSITORY https://github.com/snap-stanford/snap.git
29+
GIT_TAG 6924a035aabd1ce0a547b94e995e142f29eb5040
30+
)
31+
32+
FetchContent_GetProperties(snap)
33+
if (NOT snap_POPULATED)
34+
FetchContent_Populate(snap)
35+
message(STATUS "Building SNAP, this may take a while ...")
36+
execute_process(COMMAND make -j
37+
WORKING_DIRECTORY ${snap_SOURCE_DIR}
38+
OUTPUT_QUIET
39+
ERROR_QUIET
40+
OUTPUT_FILE ${FETCHCONTENT_BASE_DIR}/snap.stdout
41+
ERROR_FILE ${FETCHCONTENT_BASE_DIR}/snap.stderr
42+
)
43+
add_library(snap OBJECT IMPORTED GLOBAL)
44+
set_target_properties(snap PROPERTIES IMPORTED_OBJECTS ${snap_SOURCE_DIR}/snap-core/Snap.o)
45+
include_directories(${snap_SOURCE_DIR}/snap-core ${snap_SOURCE_DIR}/glib-core)
46+
message(STATUS "Finished building SNAP")
47+
endif()
48+
49+
if(ENABLE_DATA_FORMATS)
50+
find_package(HERACLES_DATA_FORMATS CONFIG)
51+
if(NOT HERACLES_DATA_FORMATS_FOUND)
52+
FetchContent_Declare(
53+
heracles_data_formats
54+
GIT_REPOSITORY [email protected]:IntelLabs/HERACLES-data-formats.git
55+
GIT_TAG main
56+
)
57+
FetchContent_MakeAvailable(heracles_data_formats)
58+
endif()
59+
endif()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
##################
2+
# HERACLES Utils
3+
##################
4+
5+
project(common)
6+
7+
set(SRCS
8+
p_isa/p_isa_instruction.cpp
9+
p_isa/parser/p_isa_parser.cpp
10+
p_isa/p_isa_performance_modeler.h
11+
p_isa/p_isa_performance_modeler.cpp
12+
)
13+
14+
add_library(common OBJECT ${SRCS})
15+
target_include_directories(common PRIVATE ${INCLUDE_DIRS})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright (C) 2024 Intel Corporation
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#cmakedefine01 ENABLE_DATA_FORMATS

0 commit comments

Comments
 (0)