Community
cancel
Showing results for 
Search instead for 
Did you mean: 
gallus2
Beginner
35 Views

How to implement HW-thread private memory

Let's say I have a pointer char *p. How can I implement behavior, in which depending on which processor is doing pointer dereference, different data is accessed?

I want something like Thread Local Storage, but for HW thread (something like HW-thread Local Storage, CPU Local Storage).

char *p = ...; // Initialization should be done in some special way, probably
char *local_p = get_hwls(p);
0 Kudos
3 Replies
TimP
Black Belt
35 Views

Maybe one of us is missing a point. As tls would be associated with a software thread, hardware affinity would associate both the thread and the tls sufficiently closely with hardware cache and local RAM to give the performance benefits.
anthony_williams
Beginner
35 Views

Quoting - tim18
Maybe one of us is missing a point. As tls would be associated with a software thread, hardware affinity would associate both the thread and the tls sufficiently closely with hardware cache and local RAM to give the performance benefits.

Indeed. Also, if the software thread is not tied to a particular hardware thread then the code would be pretty meaningless: the hardware thread used to set or retrieve the value could in principle be distinct to that used to run the code immediately before and after the value was accessed.
jimdempseyatthecove
Black Belt
35 Views


The only HW local storage you have is/are the registers (IA). And depending on your scoping interpretation, this might extend into L1, L2, L3 cache.

When using O/S calls for restricting the affinity of a software thread to a HW thread you can have some measure of selection for the cache storage