L2 cache is managed by the hardware inside the CPU - everything goes through here, so you don't (can't) "allocate" in it. However, if you take care to keep your code efficiently small, then the L2 cache will end up containing your entire codeset, and thus run faster.
It looks like the casx instruction is giving ASM programmers some means to directly use the L2 cache, outside of the normal CPU hardware cache management.
If "casx" isn't an intel instruction, then forget about using it on that processor!
None of this seems relevant to perl shared memory though - where does perl come into this???