forked from intel/intel-extension-for-openxla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c1e6ff
commit d176642
Showing
14 changed files
with
620 additions
and
1,459 deletions.
There are no files selected for viewing
This file contains 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 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 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,36 @@ | ||
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. | ||
# | ||
# 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. | ||
# ============================================================================== | ||
"""Compresses the contents of 'find_sycl_config.py'. | ||
The compressed file is what is actually being used. It works around remote | ||
config not being able to upload files yet. | ||
""" | ||
import base64 | ||
import zlib | ||
|
||
|
||
def main(): | ||
with open('find_sycl_config.py', 'rb') as f: | ||
data = f.read() | ||
|
||
compressed = zlib.compress(data) | ||
b64encoded = base64.b64encode(compressed) | ||
|
||
with open('find_sycl_config.py.gz.base64', 'wb') as f: | ||
f.write(b64encoded) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains 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 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 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 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,132 @@ | ||
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. | ||
# | ||
# 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. | ||
# ============================================================================== | ||
"""Prints SYCL library and header directories and versions found on the system. | ||
The script searches for SYCL library and header files on the system, inspects | ||
them to determine their version and prints the configuration to stdout. | ||
The path to inspect is specified through an environment variable (SYCL_PATH). | ||
If no valid configuration is found, the script prints to stderr and | ||
returns an error code. | ||
The script takes the directory specified by the SYCL_PATH environment variable. | ||
The script looks for headers and library files in a hard-coded set of | ||
subdirectories from base path of the specified directory. If SYCL_PATH is not | ||
specified, then "/opt/sycl" is used as it default value | ||
""" | ||
|
||
import io | ||
import os | ||
import re | ||
import sys | ||
|
||
|
||
class ConfigError(Exception): | ||
pass | ||
|
||
def _get_default_sycl_toolkit_path(): | ||
return "/opt/intel/oneapi/compiler/latest" | ||
|
||
def _get_toolkit_path(): | ||
"""Determines and returns the SYCL installation path.""" | ||
sycl_toolkit_path = None | ||
sycl_toolkit_path = _get_default_sycl_toolkit_path() | ||
if "SYCL_TOOLKIT_PATH" in os.environ: | ||
sycl_toolkit_path = os.environ["SYCL_TOOLKIT_PATH"] | ||
return os.path.realpath(sycl_toolkit_path) | ||
|
||
def _get_basekit_path(): | ||
return _get_toolkit_path().split("/compiler/")[0] | ||
|
||
def _get_basekit_version(): | ||
return _get_toolkit_path().split("/compiler/")[1].split("/")[0] | ||
|
||
def _get_composite_version_number(major, minor, patch): | ||
return 10000 * major + 100 * minor + patch | ||
|
||
|
||
def _get_header_version(path, name): | ||
"""Returns preprocessor defines in C header file.""" | ||
for line in io.open(path, "r", encoding="utf-8"): | ||
match = re.match(r"#define %s +(\d+)" % name, line) | ||
if match: | ||
value = match.group(1) | ||
return int(value) | ||
|
||
raise ConfigError('#define "{}" is either\n'.format(name) + | ||
" not present in file {} OR\n".format(path) + | ||
" its value is not an integer literal") | ||
|
||
|
||
def _find_sycl_config(basekit_path): | ||
|
||
def sycl_version_numbers(path): | ||
possible_version_files = [ | ||
"compiler/latest/linux/include/sycl/version.hpp", | ||
"compiler/latest/include/sycl/version.hpp", | ||
] | ||
version_file = None | ||
for f in possible_version_files: | ||
version_file_path = os.path.join(path, f) | ||
if os.path.exists(version_file_path): | ||
version_file = version_file_path | ||
break | ||
if not version_file: | ||
raise ConfigError( | ||
"SYCL version file not found in {}".format(possible_version_files)) | ||
|
||
major = _get_header_version(version_file, "__LIBSYCL_MAJOR_VERSION") | ||
minor = _get_header_version(version_file, "__LIBSYCL_MINOR_VERSION") | ||
patch = _get_header_version(version_file, "__LIBSYCL_PATCH_VERSION") | ||
return major, minor, patch | ||
|
||
major, minor, patch = sycl_version_numbers(basekit_path) | ||
|
||
sycl_config = { | ||
"sycl_version_number": _get_composite_version_number(major, minor, patch), | ||
"sycl_basekit_version_number": _get_basekit_version(), | ||
} | ||
|
||
return sycl_config | ||
|
||
|
||
def find_sycl_config(): | ||
"""Returns a dictionary of SYCL components config info.""" | ||
basekit_path = _get_basekit_path() | ||
toolkit_path = _get_toolkit_path() | ||
if not os.path.exists(basekit_path): | ||
raise ConfigError( | ||
'Specified SYCL_TOOLKIT_PATH "{}" does not exist'.format(basekit_path)) | ||
|
||
result = {} | ||
|
||
result["sycl_basekit_path"] = basekit_path | ||
result["sycl_toolkit_path"] = toolkit_path | ||
result.update(_find_sycl_config(basekit_path)) | ||
|
||
return result | ||
|
||
|
||
def main(): | ||
try: | ||
for key, value in sorted(find_sycl_config().items()): | ||
print("%s: %s" % (key, value)) | ||
except ConfigError as e: | ||
sys.stderr.write("\nERROR: {}\n\n".format(str(e))) | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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 @@ | ||
eJytV9tu2zgQfddXDBgUlTaunPZp4UUe3DRFvc3ahe22KJLAoCXaZiOLWpJKYhT5950hJVm+FEGL9UOiy3B4ZubM4egELlSx0XK5svDm7M0ZTFcCpiI3Sr/P1AP0S7tS2sTQzzIYk5mBsTBC34s0Dk6CE7iSCZqLFMo8FRosru8XPMF/1ZsOfBHaSJXDm/gMQjJg1SsW/YUeNqqENd9AriyURqALaWAhMwHiMRGFBZlDotZFJnmeCHiQduW2qZwgDPhWuVBzy9Gao32Bd4u2HXDrANNvZW3R63YfHh5i7sDGSi+7mTc03avBxeVwcvkKAbsln/NMGANa/FtKjaHON8ALxJPwOaLM+AMoDXypBb6zivA+aGllvuyAUQv7wLVAL6k0Vst5aXeSVaPDmNsGmC6eA+tPYDBh8LY/GUw66OPrYPph9HkKX/vjcX84HVxOYDSGi9Hw3WA6GA3x7j30h9/g42D4rgMCU4XbiMdCE34EKSmNrnQwEWIHwEJ5QKYQiVzIBOPKlyVfCliqe6FzDAcKodfSUDENwkvRSybX0nLrnhwERduc/6+/gDH2ScscaTj5dnGF28811xsCAyvBaf8US5RYpaVwGOHesw8ppRAgJdZFuTFWrOMgIMKbREvkmRFcIxeMS8XP3BM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6q6mKxWzbVr7O+RhixtOCZsJxW1Ifvy4hGlAojbEOpqRyHEdKmU4P9r/7QXYrbPZ1eCtU+B/+n+PxrMvl+MJzq/MJ8uLyq86GgwPHBVV5/+SIzwLLj7sOaq6+4hEUuhHHuOmR1tip3uC+hz0rYVrflR1YUcWs95vCHhnx+He0bLn+ODgocVPwfYIaGGt5OFAHfbVneNsldBYQCOb8rOV+5rDbqMhs4pc5gtVaXw7Q3Xpdg9YNDo2OBybFYjIe123p1/PtMfLSTMkHgwMXsNTJbyKOv+NjO9s4w8DYWg0xCI/bW+vdwtD1uwWbdoP9o3bgTrj9oPGOC6LFNUwfEbBo1Z9/cKqtGv8kvbltHrTa5TxTmw69emBjMDZVaThIQ1i5OfahFEjae6jImQvTA8PXTptw62niKpVfey3qkAztaiHORP7j5GYPq1FyG7yy/F4NO5hNm/y1tmHn9AhOoyaZVgWS8c0DuJ4nM3oeJ3N8LOUWp5inM1Yz/UwhRv8B886rVM= |
This file contains 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
Oops, something went wrong.