CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
112 lines
3.8 KiB
Python
112 lines
3.8 KiB
Python
################################################################################
|
|
#
|
|
# Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
# in the Software without restriction, including without limitation the rights
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell cop-
|
|
# ies of the Software, and to permit persons to whom the Software is furnished
|
|
# to do so, subject to the following conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
# copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM-
|
|
# PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNE-
|
|
# CTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
################################################################################
|
|
|
|
from rocisa import code
|
|
from rocisa.container import sgpr
|
|
from rocisa.instruction import SMovB32
|
|
from copy import deepcopy
|
|
import pickle
|
|
import timeit
|
|
|
|
def fastdeepcopy(x):
|
|
# Note: Some object can't be pickled
|
|
return pickle.loads(pickle.dumps(x))
|
|
|
|
def test_code():
|
|
label = code.Label("label", comment="comment")
|
|
print(label)
|
|
tesxtblock = code.TextBlock("textblock")
|
|
print(tesxtblock)
|
|
|
|
#Test Module
|
|
module = code.Module("module")
|
|
module.add(SMovB32(dst=sgpr(1), src=sgpr(2)))
|
|
module2 = module.add(code.Module("module2"))
|
|
module2.add(SMovB32(dst=sgpr(3), src=sgpr(4)))
|
|
print(module)
|
|
print(module.prettyPrint(""))
|
|
|
|
for item in module.items():
|
|
item.name = "newname"
|
|
for item in module.items():
|
|
assert item.name == "newname"
|
|
|
|
flat = module.flatitems()
|
|
testpop = []
|
|
while flat:
|
|
item = flat.pop(0)
|
|
testpop.append(item)
|
|
print("Test pop", testpop)
|
|
|
|
|
|
srdUpperValue = code.SrdUpperValue((9,4,2))
|
|
print(srdUpperValue.desc())
|
|
assert srdUpperValue.getValue() == 131072
|
|
|
|
signature = code.SignatureBase(kernelName="123",
|
|
kernArgsVersion=1,
|
|
codeObjectVersion="4",
|
|
groupSegmentSize=256,
|
|
sgprWorkGroup=(1, 1, 100),
|
|
vgprWorkItem=1,
|
|
flatWorkGroupSize=(256),
|
|
numSgprPreload=16)
|
|
print(signature)
|
|
|
|
vs = code.ValueSet("BufferLimit", 0xFFFFFFFF, format=1)
|
|
print(vs)
|
|
|
|
def timeit_decorator(func):
|
|
def wrapper(*args, **kwargs):
|
|
start_time = timeit.default_timer()
|
|
result = func(*args, **kwargs)
|
|
end_time = timeit.default_timer()
|
|
print(f"Function {func.__name__} took {end_time - start_time:.6f} seconds")
|
|
return result
|
|
return wrapper
|
|
|
|
def copyfunc(obj, noPickle=False):
|
|
obj2 = deepcopy(obj)
|
|
print("Copied item using deepcopy:", obj2)
|
|
if noPickle:
|
|
return
|
|
obj3 = fastdeepcopy(obj)
|
|
print("Copied item using pickle:", obj3)
|
|
|
|
def test_copy():
|
|
label = code.Label("label", comment="comment")
|
|
copyfunc(label)
|
|
tesxtblock = code.TextBlock("textblock")
|
|
copyfunc(tesxtblock)
|
|
|
|
module = code.Module("module")
|
|
module.add(SMovB32(dst=sgpr(1), src=sgpr(2)))
|
|
module2 = module.add(code.Module("module2"))
|
|
module2.add(SMovB32(dst=sgpr(3), src=sgpr(4)))
|
|
copyfunc(module, True)
|
|
|
|
valueset = code.ValueSet("Test", 1)
|
|
copyfunc(valueset)
|
|
|
|
test_code()
|
|
test_copy()
|