Skip to content

Commit c9def90

Browse files
committed
Move logic for precompiled kernels
1 parent da07415 commit c9def90

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

xobjects/struct.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,29 @@ def compile_class_kernels(
475475
extra_classes=(),
476476
extra_compile_args=(),
477477
):
478+
479+
if context.allow_prebuilt_kernels:
480+
_print_state = Print.suppress
481+
Print.suppress = True
482+
try:
483+
from xsuite import (
484+
get_suitable_kernel,
485+
XSK_PREBUILT_KERNELS_LOCATION,
486+
)
487+
kernel_info = get_suitable_kernel({}, ())
488+
except ImportError:
489+
kernel_info = None
490+
491+
Print.suppress = _print_state
492+
if kernel_info:
493+
module_name, _ = kernel_info
494+
kernels = context.kernels_from_file(
495+
module_name=module_name,
496+
containing_dir=XSK_PREBUILT_KERNELS_LOCATION,
497+
kernel_descriptions=cls._kernels,
498+
)
499+
context.kernels.update(kernels)
500+
478501
if only_if_needed:
479502
all_found = True
480503
for kk, kernel_description in cls._kernels.items():

0 commit comments

Comments
 (0)