-
Notifications
You must be signed in to change notification settings - Fork 17
[BenchGC] attach DLTI for mlir module #312
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
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
4772f9a
introduce benchgc for correctness check
WangJialei-A 2124dc2
Merge branch 'main' into xurui/merge_bench_new
xurui1995 1f5b6ba
merge code
xurui1995 2cccd04
introduce benchgc for correctness check
WangJialei-A 1cabc2c
remove print
xurui1995 c3c5441
merge code
xurui1995 e316a98
fix
xurui1995 841e81f
simplify
xurui1995 42a50c2
merge main
xurui1995 b16a9b6
Merge branch 'main' into xurui/merge_into_benchgc
xurui1995 1e8b074
fix format
xurui1995 1c20184
fix format
xurui1995 69f2e94
reorg the pattern dir
xurui1995 8d0953c
improve
xurui1995 e05d5f0
fix format
xurui1995 e96d310
fix
xurui1995 9d03541
Merge branch 'main' into xurui/merge_into_benchgc
xurui1995 44d591d
add example
xurui1995 bae0e8b
Merge branch 'main' into xurui/merge_into_benchgc
xurui1995 bc7262d
Merge branch 'main' into xurui/merge_into_benchgc
xurui1995 420e3de
Merge branch 'main' into xurui/merge_into_benchgc
xurui1995 7923184
fix some comments
xurui1995 8e85b80
fix
xurui1995 56f2de6
fix
xurui1995 b87b2d4
add readme
xurui1995 8f09ed0
Merge branch 'main' into xurui/merge_into_benchgc
xurui1995 4726c81
Merge branch 'main' into xurui/merge_into_benchgc
xurui1995 b2597b9
add mlp filling
xurui1995 248dd12
Merge branch 'main' into xurui/merge_into_benchgc
xurui1995 4392974
fix mlp
xurui1995 3566b83
add case
xurui1995 8deb44c
remove old bench code
xurui1995 a0641e9
update readme
xurui1995 5372bf0
Merge branch 'main' into xurui/merge_into_benchgc
xurui1995 2448b76
add attch dlti
xurui1995 d614c40
skip attach dlti when it was already added
xurui1995 9db3237
update readme
xurui1995 d714cf0
update readme
xurui1995 6f34f0f
fix ci
xurui1995 8cb976f
fix
xurui1995 15d14f4
fix
xurui1995 82521bb
fix env name
xurui1995 fa59611
add test print
xurui1995 b4aecff
add test print2
xurui1995 20a0e28
test ci
xurui1995 67d155c
test ci cpu
xurui1995 1e7c835
add new cpuinfo
xurui1995 ed60ede
merge main
xurui1995 21860b4
fix
xurui1995 6db244e
fix
xurui1995 2d8e5ed
Merge branch 'main' into xurui/add_dlti
xurui1995 1e09121
Merge branch 'main' into xurui/add_dlti
xurui1995 2ab9a48
fix
xurui1995 072eed6
Merge branch 'main' into xurui/add_dlti
xurui1995 e7bfb70
Merge branch 'main' into xurui/add_dlti
xurui1995 9f5cb89
Merge branch 'main' into xurui/add_dlti
xurui1995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (C) 2024 Intel Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "mlir/Bindings/Python/PybindAdaptors.h" | ||
|
||
#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \ | ||
defined(_M_IX86) | ||
// x86 or x86_64 specific code | ||
void cpuid(int info[4], int leaf, int subleaf) { | ||
__asm__ __volatile__("cpuid" | ||
: "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), | ||
"=d"(info[3]) | ||
: "a"(leaf), "c"(subleaf)); | ||
} | ||
|
||
std::vector<int> getCacheSizes() { | ||
int info[4]; | ||
cpuid(info, 0, 0); | ||
int nIds = info[0]; | ||
int caches[3] = {}; | ||
for (int i = 0; i <= nIds; ++i) { | ||
cpuid(info, 4, i); | ||
int cacheType = info[0] & 0x1F; | ||
if (cacheType == 0) { | ||
break; | ||
} | ||
if (cacheType == 2) { | ||
// skip instruction cache | ||
continue; | ||
} | ||
int cacheLevel = (info[0] >> 5) & 0x7; | ||
int cacheLinesPerTag = ((info[1] >> 0) & 0xFFF) + 1; | ||
int cacheAssociativity = ((info[1] >> 12) & 0x3FF) + 1; | ||
int cachePartitions = ((info[1] >> 22) & 0x3FF) + 1; | ||
int cacheSets = info[2] + 1; | ||
int cacheSize = | ||
cacheLinesPerTag * cacheAssociativity * cachePartitions * cacheSets; | ||
if (cacheLevel >= 1 && cacheLevel <= 3) { | ||
caches[cacheLevel - 1] = cacheSize; | ||
} | ||
} | ||
return std::vector<int>(std::begin(caches), std::end(caches)); | ||
} | ||
|
||
bool isFeatureSupported(int function_id, int register_idx, int bit) { | ||
int info[4]; | ||
cpuid(info, function_id, 0); | ||
return (info[register_idx] & (1 << bit)) != 0; | ||
} | ||
|
||
int getMaxVectorWidth() { | ||
if (isFeatureSupported(7, 1, 16)) { // Check for AVX-512F support | ||
return 512; | ||
} else if (isFeatureSupported(1, 2, 28)) { // Check for AVX support | ||
return 256; | ||
} else if (isFeatureSupported(1, 3, 25)) { // Check for SSE support | ||
return 128; | ||
} | ||
return 64; // Default to 64 if none of the above features are supported | ||
} | ||
#else | ||
std::vector<int> getCacheSizes() { return {}; } | ||
|
||
int getMaxVectorWidth { return 0; } | ||
#endif | ||
|
||
PYBIND11_MODULE(_cpuinfo, m) { | ||
m.doc() = "Graph-compiler MLIR Python binding"; | ||
m.def("get_cache_sizes", &getCacheSizes, "Get CPU L1,L2,L3 cache size"); | ||
m.def("get_max_vector_width", &getMaxVectorWidth, | ||
"Get CPU supported max vector width"); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ===-- __init__.py - init ------------------------------------*- Python -*-===# | ||
# | ||
# This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# ===-----------------------------------------------------------------------===# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# ===-- cpuinfo.py - Getting the CPU info ---------------------*- Python -*-===# | ||
# | ||
# This file is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# ===-----------------------------------------------------------------------===# | ||
|
||
from .._mlir_libs import _cpuinfo | ||
|
||
_cache_sizes = [] | ||
_max_vector_width = None | ||
|
||
|
||
def get_cache_sizes(): | ||
global _cache_sizes | ||
if not _cache_sizes: | ||
_cache_sizes = _cpuinfo.get_cache_sizes() | ||
return _cache_sizes | ||
|
||
|
||
def get_max_vector_width(): | ||
global _max_vector_width | ||
if _max_vector_width is None: | ||
_max_vector_width = _cpuinfo.get_max_vector_width() | ||
return _max_vector_width |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.