What is the difference between buf.data and buf.access_ptr

hi ,
i am little confused about the difference between matched_buffer.data and
matched_buffer.access_ptr?

for ex:
a = T.match_buffer(inp , (16) ,…)
T.evaluate(
T.call_extern(a.data …)
vs
Y.call_extern(a.access_ptr(…) , …)
)

according to my understanding , both will return the pointer to data of the buffer , but using the former (data directly) yeilds wrong output.

After further experimentation , i have realized that
buffer.data return the base_address of the buffer
whereas
buffer.access_ptr return the address of the sliced portion of buffer region.

is my understanding correct ? @sanirudh

Hi @yogeesh,

buffer.data does return the base_address, so you’re right about that. I haven’t used access_ptr before, but from what I could understand from the definition, I think you’re right. It is supposed to return the address of buffer at some offset, and it also contains the extent and type of access, so I’m guessing it’s supposed to be used as a builtin to represent read/write access to a particular buffer region.

1 Like

That’s correct: The buffer.data always points to the backing allocation, whereas buffer.access_ptr(...) or T.address_of(buffer[...]) point to the buffer’s location. In addition, the .access_ptr can specify whether the access is intended to be used for read-only access.

2 Likes

@sanirudh thank you for confirming my understanding and the explanantion. :slight_smile:

1 Like

@Lunderberg thanks a lot for you explanation and reassurance. :slight_smile: