gem5-users@gem5.org

The gem5 Users mailing list

View all threads

Ruby Message handling

VM
Vladimir Milicevic
Sat, Mar 2, 2024 12:11 AM

My goal is to extract and print specific information (e.g., request type) from the Messages passing through the Garnet NetworkInterface instances. Within NetworkInterface::wakeup(), I’ve been able to print the messages by using:
DPRINTF(RubyNetwork, "Message: %s\n", *(msg_ptr.get()));

In FS sims, I’m able to get messages printed such as:
Message: [RequestMsg: addr = [0xb9a3cfc0, line 0xb9a3cfc0] Type = GETS AccessMode = Supervisor Requestor = L1Cache-1 Destination = [NetDest (20)  - 0 0  - 0 1  -  - 0 0  - 0 0  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - ] MessageSize = Control DataBlk = [ 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 ] Len = 0 Dirty = 0 Prefetch = No ]

Now here’s where I run into trouble. I’d like access to each individual field of the request Message, instead of printing it as output. I’ve tried dynamically casting to RubyRequestType and accessing the getType() method, but this does not work:

Is there a better way to access the message attributes and enums within the garnet network from Ruby/SLICC code?

Thanks in advance,
Vlad

My goal is to extract and print specific information (e.g., request type) from the Messages passing through the Garnet NetworkInterface instances. Within NetworkInterface::wakeup(), I’ve been able to print the messages by using: DPRINTF(RubyNetwork, "Message: %s\n", *(msg_ptr.get())); In FS sims, I’m able to get messages printed such as: Message: [RequestMsg: addr = [0xb9a3cfc0, line 0xb9a3cfc0] Type = GETS AccessMode = Supervisor Requestor = L1Cache-1 Destination = [NetDest (20) - 0 0 - 0 1 - - 0 0 - 0 0 - - - - - - - - - - - - - - - ] MessageSize = Control DataBlk = [ 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 ] Len = 0 Dirty = 0 Prefetch = No ] Now here’s where I run into trouble. I’d like access to each individual field of the request Message, instead of printing it as output. I’ve tried dynamically casting to RubyRequestType and accessing the getType() method, but this does not work: Is there a better way to access the message attributes and enums within the garnet network from Ruby/SLICC code? Thanks in advance, Vlad
CW
C.-Y. Wu
Mon, Mar 4, 2024 11:13 AM

Hello Vlad,

I don't think you can dynamically cast a Message pointer (MsgPtr) to
RubyRequestType. Do you mean a RequestMsg pointer or a RubyRequest pointer?

If you used dynamic_cast in NetworkInterface.cc to cast a MsgPtr to a
RequestMsg pointer, you should be able to call the getType function. (The
function is defined in RequestMsg.hh.) But this function may not return the
information you want. Depending on the protocol you are using, different
fields are copied to a RequestMsg (which will eventually reach the network
interface). The sm files corresponding to the protocol define which fields
are copied. You will have to check the protocol you are using.
For example, in src/mem/ruby/protocol/Garnet_standalone-cache.sm, the
address, requestor, destination and message size are copied to the
RequestMsg (out_msg). But the type is set to "CoherenceRequestType:MSG".

Chia

On Sat, Mar 2, 2024 at 2:30 AM Vladimir Milicevic via gem5-users <
gem5-users@gem5.org> wrote:

My goal is to extract and print specific information (e.g., request type)
from the Messages passing through the Garnet NetworkInterface instances.
Within NetworkInterface::wakeup(), I’ve been able to print the messages by
using:

DPRINTF(RubyNetwork, "Message: %s\n", *(msg_ptr.get()));

In FS sims, I’m able to get messages printed such as:

Message: [RequestMsg: addr = [0xb9a3cfc0, line 0xb9a3cfc0] Type = GETS
AccessMode = Supervisor Requestor = L1Cache-1 Destination = [NetDest (20)

  • 0 0  - 0 1  -  - 0 0  - 0 0  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
    ] MessageSize = Control DataBlk = [ 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
    0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
    0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
    0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 ] Len = 0
    Dirty = 0 Prefetch = No ]

Now here’s where I run into trouble. I’d like access to each individual
field of the request Message, instead of printing it as output. I’ve tried
dynamically casting to RubyRequestType and accessing the getType() method,
but this does not work:

Is there a better way to access the message attributes and enums within
the garnet network from Ruby/SLICC code?

Thanks in advance,
Vlad


gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-leave@gem5.org

Hello Vlad, I don't think you can dynamically cast a Message pointer (MsgPtr) to RubyRequestType. Do you mean a RequestMsg pointer or a RubyRequest pointer? If you used dynamic_cast in NetworkInterface.cc to cast a MsgPtr to a RequestMsg pointer, you should be able to call the getType function. (The function is defined in RequestMsg.hh.) But this function may not return the information you want. Depending on the protocol you are using, different fields are copied to a RequestMsg (which will eventually reach the network interface). The sm files corresponding to the protocol define which fields are copied. You will have to check the protocol you are using. For example, in src/mem/ruby/protocol/Garnet_standalone-cache.sm, the address, requestor, destination and message size are copied to the RequestMsg (out_msg). But the type is set to "CoherenceRequestType:MSG". Chia On Sat, Mar 2, 2024 at 2:30 AM Vladimir Milicevic via gem5-users < gem5-users@gem5.org> wrote: > My goal is to extract and print specific information (e.g., request type) > from the Messages passing through the Garnet NetworkInterface instances. > Within NetworkInterface::wakeup(), I’ve been able to print the messages by > using: > > DPRINTF(RubyNetwork, "Message: %s\n", *(msg_ptr.get())); > > > In FS sims, I’m able to get messages printed such as: > > Message: [RequestMsg: addr = [0xb9a3cfc0, line 0xb9a3cfc0] Type = GETS > AccessMode = Supervisor Requestor = L1Cache-1 Destination = [NetDest (20) > - 0 0 - 0 1 - - 0 0 - 0 0 - - - - - - - - - - - - - - - > ] MessageSize = Control DataBlk = [ 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 > 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 > 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 > 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 ] Len = 0 > Dirty = 0 Prefetch = No ] > > > Now here’s where I run into trouble. I’d like access to each individual > field of the request Message, instead of printing it as output. I’ve tried > dynamically casting to RubyRequestType and accessing the getType() method, > but this does not work: > > Is there a better way to access the message attributes and enums within > the garnet network from Ruby/SLICC code? > > Thanks in advance, > Vlad > _______________________________________________ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-leave@gem5.org >
VM
Vladimir Milicevic
Wed, Mar 6, 2024 1:25 AM

Hi Chia,

Within a Message Buffer enqueue method, I’m able to cast the MsgPtr to a RubyRequest and able to dereference this new pointer:
MessageBuffer::enqueue(MsgPtr message, Tick current_time, Tick delta)
[...]
auto rubyRequest = std::dynamic_pointer_castgem5::ruby::RubyRequest(message);
[...]
if (rubyRequest){
RubyRequestType requestType = rubyRequest->getType();

Then I used the header from a pre-built Ruby instance to manage the enum: #include "/gem5/build/{ISA}/mem/ruby/protocol/RubyRequestType.hh”

This only works in the message buffers from the mandatory queue in the caches, system.ruby.l1_cntrl1.mandatoryQueue:
system.ruby.l1_cntrl1.mandatoryQueue: RubyRequest info LD

When I try a similar method on the network interface, it does not work:
system.ruby.network.netifs2: Message Type: N4gem54ruby10RequestMsgE

Then I tried your method, particularly looking at the MESI_Two_Level-msg.sm on a pre-built Ruby instance. I sourced the resultant RequestMsg.cc/hhhttp://RequestMsg.cc/hh from the built ISA and wrote similar code to above, only casting to gem5::ruby::RequestMsg, this worked.

Thanks, Chia.

On Mar 4, 2024, at 6:13 AM, C.-Y. Wu via gem5-users gem5-users@gem5.org wrote:

[External Email]
Hello Vlad,

I don't think you can dynamically cast a Message pointer (MsgPtr) to RubyRequestType. Do you mean a RequestMsg pointer or a RubyRequest pointer?

If you used dynamic_cast in NetworkInterface.cchttp://networkinterface.cc/ to cast a MsgPtr to a RequestMsg pointer, you should be able to call the getType function. (The function is defined in RequestMsg.hh.) But this function may not return the information you want. Depending on the protocol you are using, different fields are copied to a RequestMsg (which will eventually reach the network interface). The sm files corresponding to the protocol define which fields are copied. You will have to check the protocol you are using.
For example, in src/mem/ruby/protocol/Garnet_standalone-cache.sm, the address, requestor, destination and message size are copied to the RequestMsg (out_msg). But the type is set to "CoherenceRequestType:MSG".

Chia

On Sat, Mar 2, 2024 at 2:30 AM Vladimir Milicevic via gem5-users <gem5-users@gem5.orgmailto:gem5-users@gem5.org> wrote:
My goal is to extract and print specific information (e.g., request type) from the Messages passing through the Garnet NetworkInterface instances. Within NetworkInterface::wakeup(), I’ve been able to print the messages by using:
DPRINTF(RubyNetwork, "Message: %s\n", *(msg_ptr.get()));

In FS sims, I’m able to get messages printed such as:
Message: [RequestMsg: addr = [0xb9a3cfc0, line 0xb9a3cfc0] Type = GETS AccessMode = Supervisor Requestor = L1Cache-1 Destination = [NetDest (20)  - 0 0  - 0 1  -  - 0 0  - 0 0  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - ] MessageSize = Control DataBlk = [ 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 ] Len = 0 Dirty = 0 Prefetch = No ]

Now here’s where I run into trouble. I’d like access to each individual field of the request Message, instead of printing it as output. I’ve tried dynamically casting to RubyRequestType and accessing the getType() method, but this does not work:

Is there a better way to access the message attributes and enums within the garnet network from Ruby/SLICC code?

Thanks in advance,
Vlad


gem5-users mailing list -- gem5-users@gem5.orgmailto:gem5-users@gem5.org
To unsubscribe send an email to gem5-users-leave@gem5.orgmailto:gem5-users-leave@gem5.org


gem5-users mailing list -- gem5-users@gem5.orgmailto:gem5-users@gem5.org
To unsubscribe send an email to gem5-users-leave@gem5.orgmailto:gem5-users-leave@gem5.org

This email contains links to content or websites. Always be cautious when opening external links or attachments.

Please visit https://carleton.ca/its/help-centre/report-phishing/ for information on reporting phishing messages.

When in doubt, the ITS Service Desk can provide assistance. https://carleton.ca/its/chat

-----End of Disclaimer-----

Hi Chia, Within a Message Buffer enqueue method, I’m able to cast the MsgPtr to a RubyRequest and able to dereference this new pointer: MessageBuffer::enqueue(MsgPtr message, Tick current_time, Tick delta) [...] auto rubyRequest = std::dynamic_pointer_cast<gem5::ruby::RubyRequest>(message); [...] if (rubyRequest){ RubyRequestType requestType = rubyRequest->getType(); Then I used the header from a pre-built Ruby instance to manage the enum: #include "/gem5/build/{ISA}/mem/ruby/protocol/RubyRequestType.hh” This only works in the message buffers from the mandatory queue in the caches, system.ruby.l1_cntrl1.mandatoryQueue: system.ruby.l1_cntrl1.mandatoryQueue: RubyRequest info LD When I try a similar method on the network interface, it does not work: system.ruby.network.netifs2: Message Type: N4gem54ruby10RequestMsgE Then I tried your method, particularly looking at the MESI_Two_Level-msg.sm on a pre-built Ruby instance. I sourced the resultant RequestMsg.cc/hh<http://RequestMsg.cc/hh> from the built ISA and wrote similar code to above, only casting to gem5::ruby::RequestMsg, this worked. Thanks, Chia. On Mar 4, 2024, at 6:13 AM, C.-Y. Wu via gem5-users <gem5-users@gem5.org> wrote: [External Email] Hello Vlad, I don't think you can dynamically cast a Message pointer (MsgPtr) to RubyRequestType. Do you mean a RequestMsg pointer or a RubyRequest pointer? If you used dynamic_cast in NetworkInterface.cc<http://networkinterface.cc/> to cast a MsgPtr to a RequestMsg pointer, you should be able to call the getType function. (The function is defined in RequestMsg.hh.) But this function may not return the information you want. Depending on the protocol you are using, different fields are copied to a RequestMsg (which will eventually reach the network interface). The sm files corresponding to the protocol define which fields are copied. You will have to check the protocol you are using. For example, in src/mem/ruby/protocol/Garnet_standalone-cache.sm, the address, requestor, destination and message size are copied to the RequestMsg (out_msg). But the type is set to "CoherenceRequestType:MSG". Chia On Sat, Mar 2, 2024 at 2:30 AM Vladimir Milicevic via gem5-users <gem5-users@gem5.org<mailto:gem5-users@gem5.org>> wrote: My goal is to extract and print specific information (e.g., request type) from the Messages passing through the Garnet NetworkInterface instances. Within NetworkInterface::wakeup(), I’ve been able to print the messages by using: DPRINTF(RubyNetwork, "Message: %s\n", *(msg_ptr.get())); In FS sims, I’m able to get messages printed such as: Message: [RequestMsg: addr = [0xb9a3cfc0, line 0xb9a3cfc0] Type = GETS AccessMode = Supervisor Requestor = L1Cache-1 Destination = [NetDest (20) - 0 0 - 0 1 - - 0 0 - 0 0 - - - - - - - - - - - - - - - ] MessageSize = Control DataBlk = [ 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 ] Len = 0 Dirty = 0 Prefetch = No ] Now here’s where I run into trouble. I’d like access to each individual field of the request Message, instead of printing it as output. I’ve tried dynamically casting to RubyRequestType and accessing the getType() method, but this does not work: Is there a better way to access the message attributes and enums within the garnet network from Ruby/SLICC code? Thanks in advance, Vlad _______________________________________________ gem5-users mailing list -- gem5-users@gem5.org<mailto:gem5-users@gem5.org> To unsubscribe send an email to gem5-users-leave@gem5.org<mailto:gem5-users-leave@gem5.org> _______________________________________________ gem5-users mailing list -- gem5-users@gem5.org<mailto:gem5-users@gem5.org> To unsubscribe send an email to gem5-users-leave@gem5.org<mailto:gem5-users-leave@gem5.org> This email contains links to content or websites. Always be cautious when opening external links or attachments. Please visit https://carleton.ca/its/help-centre/report-phishing/ for information on reporting phishing messages. When in doubt, the ITS Service Desk can provide assistance. https://carleton.ca/its/chat -----End of Disclaimer-----