What's mean of readers in cache_read?

I do not know what’s the purpose to provide the readers in cache_read, could anyone explain it?

Thanks

1 Like

This is useful when the memory management is (semi-)explicit to the developer. One example is in GPUs you want to specify the data to be read into the local memory for subsequent use. cache_read is not useful for devices which implicitly handle the memory copy for the developers, e.g. CPUs.

1 Like

I understand the purpose of cache_read, but do not understand the readers parameter.

the readers are the consumers which we want to redirect to the cache.

Say original dataflow is

A -> B
A-> C

If we do Ac = cache_read(A, readers=[B]), then it becomes

A->Ac -> B
A-> C

2 Likes

Thanks for catching a good point, would you be interested in update the docstring of cache read to add additional clarification that might help others?

Thanks for @tqchen, it’s clear for me now. Sure, I will update the docstring fo cache_read late.

@tqchen

temp_R = s.cache_write(temp_G, “global”) means the dataflow is temp_G ->temp_R, right?

thanks

it is the other way around

A-> G, B->G

R = s.cache_write(G, “global”)

will result in

A->R, B->R, R ->G

2 Likes