Skip to content
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

Ctrl pkt wip #3

Closed
wants to merge 2 commits into from
Closed

Ctrl pkt wip #3

wants to merge 2 commits into from

Conversation

fifield
Copy link
Owner

@fifield fifield commented Aug 16, 2024

test:

# test.py -*- 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
#
# (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates

import numpy as np
import pyxrt as xrt
import sys
import time

from aie.dialects.aie import *
import aie.dialects.aiex as aiex
import aie.dialects.linalg as linalg
import aie.dialects.scf as scf
from aie.extras.context import mlir_mod_ctx
from aie.extras import types as T
from aie.passmanager import PassManager

import aie.utils.test as test_utils

import aie.compiler.aiecc.main as aiecc
from aie.dialects.aie import generate_control_packets

def gen_cp_sequence():
    with mlir_mod_ctx() as ctx:
        @device(AIEDevice.npu1)
        def device_body():
            params = []
            @aiex.runtime_sequence(*params)
            def sequence(*args):
                aiex.control_packet(address = 0x0001F000, opcode = 0, stream_id = 0, data = [2])
                aiex.control_packet(address = 0x0001F020, opcode = 0, stream_id = 0, data = [2])
                aiex.control_packet(address = 0x00000400, opcode = 1, stream_id = 2, length = 4)
        return ctx.module

def main(opts):
    aie_module = gen_cp_sequence()
    print(aie_module)
    for i in generate_control_packets(aie_module.operation):
        print(i)

if __name__ == "__main__":
    opts = {}
    main(opts)

output:

$ python ./test_cp.py 
module {
  aie.device(npu1) {
    aiex.runtime_sequence() {
      aiex.control_packet {address = 126976 : ui32, data = array<i32: 2>, opcode = 0 : i32, stream_id = 0 : i32}
      aiex.control_packet {address = 127008 : ui32, data = array<i32: 2>, opcode = 0 : i32, stream_id = 0 : i32}
      aiex.control_packet {address = 1024 : ui32, length = 4 : i32, opcode = 1 : i32, stream_id = 2 : i32}
    }
  }
}

0001F000
00000002
8001F020
00000002
02700400

Comment on lines +95 to +96
output << "_symbol " << bufName << " " << "0x"
<< llvm::utohexstr(offset + bufferBaseAddr) << " " << numBytes << '\n';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format] reported by reviewdog 🐶

Suggested change
output << "_symbol " << bufName << " " << "0x"
<< llvm::utohexstr(offset + bufferBaseAddr) << " " << numBytes << '\n';
output << "_symbol " << bufName << " "
<< "0x" << llvm::utohexstr(offset + bufferBaseAddr) << " " << numBytes
<< '\n';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant