vthread can hide latency, what’s cthread for?
thanks
vthread can hide latency, what’s cthread for?
thanks
Short answer:use vthread for GPUs, and cthread for accelerators.
both cthread and vthread are used for vitural threading. The main difference is that vthread will do some smart sharing of resources. Consider the following code.
for x in virtual_thread(2):
for y in virtual_thread(2):
alloc AA[1] = A[x]
alloc BB[1] = A[y]
C[y][x] += AA[0] * BB[0]
Default cthread
rewriting will create [2][2] space for AA and BB(because of 2x2 virtual threads).
In vthread writing, compiler detects that write to AA only relies on x(not y), so it will only create [2] space for AA. This however, is not helpful in latency hiding because each thread need its own space.
In other word, vthread for avoiding bank conflict, cthread for latency hiding, am I right?
that is right, note that vthread only changes the threading pattern, to avoid bank conflict, sometimes we need to also change memory layout (via storage_align)