Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.

HT 64K aliasing and C#

Krishnamur_S_Intel
335 Views
I have a MT C# application that suffers from significant 64K aliasing conflicts with HT. The C# equivalent of alloca seems to be stackalloc. stackalloc requires me to declare my code unsafe. Does anyone have a workaround where I can avoid 64K aliasing conflicts with HT without using stackalloc?

Thanks for the help.

Srini
krishnamurthy.srinivasan@intel.com
0 Kudos
1 Reply
ClayB
New Contributor I
335 Views
Srini -

I've posed your question to Arch Robison, one of the engineers here at KSL that has been looking at C# for some time, and his response was:

If the thread executes a small recursive routine first, and the base case of the recursion does the real work of interest, then the number of recursions could be used to control the stack offset, albeit not to as high a degree of control as with stackalloc.

As an example, he gave the following pseudo-code.

int stack_waster( int i ) {    // Wastes i stack frames.  
    if( i>0 ) 
        return 1+stack_waster(i-1);    // Thwart tail-call optimization
    else {
        // base case         
       do_work_that_was_trying_to_avoid_64k_aliasing_issue;
       return 0;
    }
}


Each thread calling stack_waster() would need to use a different value of i.

-- clay
0 Kudos
Reply