-
Notifications
You must be signed in to change notification settings - Fork 1
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
Ravil Dorozhinskii
committed
Apr 1, 2023
1 parent
beb893c
commit 37cfb0e
Showing
13 changed files
with
157 additions
and
38 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
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,45 @@ | ||
include(FindPackageHandleStandardArgs) | ||
include(CheckCXXSourceRuns) | ||
include(CMakePushCheckState) | ||
|
||
cmake_push_check_state() | ||
include(CheckCXXSourceCompiles) | ||
|
||
if (NOT TARGET opensycl-config::interface) | ||
if (NOT DEFINED DEVICE_ARCH) | ||
message(FATAL_ERROR "`DEVICE_ARCH` env. variable is not provided.") | ||
else() | ||
|
||
add_library(opensycl-config::interface INTERFACE IMPORTED) | ||
|
||
execute_process(COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/find-opensycl.py -i | ||
OUTPUT_VARIABLE _OPENSYCL_INLCUDE_DIR) | ||
|
||
target_include_directories(opensycl-config::interface INTERFACE ${_OPENSYCL_INLCUDE_DIR} | ||
${_OPENSYCL_INLCUDE_DIR}/sycl) | ||
|
||
execute_process(COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/find-opensycl.py --vendor | ||
OUTPUT_VARIABLE _OPENSYCL_VENDOR) | ||
|
||
target_compile_definitions(opensycl-config::interface INTERFACE SYCL_PLATFORM_"${_OPENSYCL_VENDOR}") | ||
|
||
|
||
execute_process(COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/find-opensycl.py -t -a "${DEVICE_ARCH}" | ||
OUTPUT_VARIABLE _OPENSYCL_FULL_TARGET_NAME) | ||
|
||
set(HIPSYCL_TARGETS "${_OPENSYCL_FULL_TARGET_NAME}") | ||
set(OPENSYCL_TARGETS "${_OPENSYCL_FULL_TARGET_NAME}") | ||
|
||
find_package(OpenMP REQUIRED) | ||
add_library(opensycl-config::device_flags INTERFACE IMPORTED) | ||
target_link_libraries(opensycl-config::device_flags INTERFACE OpenMP::OpenMP_CXX) | ||
set_property(TARGET opensycl-config::device_flags PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
|
||
endif() | ||
endif() | ||
|
||
|
||
find_package_handle_standard_args(OpenSyclConfig _OPENSYCL_INLCUDE_DIR | ||
_OPENSYCL_FULL_TARGET_NAME | ||
_OPENSYCL_VENDOR) | ||
cmake_pop_check_state() |
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,83 @@ | ||
import os | ||
import sys | ||
from shutil import which | ||
import argparse | ||
import json | ||
|
||
|
||
def get_package_dir(): | ||
exe_name = which("syclcc") | ||
bin_dir = os.path.dirname(exe_name) | ||
return os.path.dirname(bin_dir) | ||
|
||
|
||
def get_config(): | ||
package_dir = get_package_dir() | ||
etc_dir = os.path.join(package_dir, "etc") | ||
config_file = None | ||
for root, dirs, files in os.walk(etc_dir): | ||
for file in files: | ||
if file == "syclcc.json": | ||
config_file = os.path.join(root, file) | ||
break | ||
|
||
if not config_file: | ||
print("failed to find opensycl config file", file=sys.stderr) | ||
sys.exit(1) | ||
|
||
with open(config_file, 'r') as file: | ||
data = json.load(file) | ||
return data | ||
|
||
|
||
def get_full_target_name(arch): | ||
data = get_config() | ||
platform = data["default-platform"] | ||
if platform == 'cuda': | ||
if not (data['default-nvcxx'].isspace() or 'NOTFOUND' in data['default-nvcxx']): | ||
default_target='cuda-nvcxx' | ||
arch = arch.replace('sm_', 'cc') | ||
else: | ||
default_target='cuda' | ||
elif platform == 'rocm': | ||
default_target='hip' | ||
print(f'{default_target}:{arch}', end='') | ||
|
||
|
||
def get_vendor_name(): | ||
data = get_config() | ||
platform = data["default-platform"] | ||
if platform == 'cuda': | ||
print('NVIDIA', end='') | ||
elif platform == 'rocm': | ||
print('AMD', end='') | ||
else: | ||
print('Intel', end='') | ||
|
||
|
||
def get_include_dir(): | ||
package_dir = get_package_dir() | ||
include_dir = os.path.join(package_dir, 'include') | ||
print(include_dir, end = '') | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Extracts info from opensycl') | ||
parser.add_argument('-t', '--target', action='store_true', help='get default target') | ||
parser.add_argument('-i', '--include_dir', action='store_true', help='get include dir') | ||
parser.add_argument('-a', '--arch', type=str, help='architecture name') | ||
parser.add_argument('--vendor', action='store_true', help='get vendor name') | ||
args = parser.parse_args() | ||
|
||
if (args.target): | ||
if (not args.arch): | ||
print("architecture name is not provided", file=sys.stderr) | ||
sys.exit(1) | ||
get_full_target_name(args.arch) | ||
|
||
if (args.include_dir): | ||
get_include_dir() | ||
|
||
if (args.vendor): | ||
get_vendor_name() | ||
|
||
|
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
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