1

Is there a way to determine the optimal cache size (L1 and L2 possibly) within C#? I'm asking this because formally worked with: http://en.wikipedia.org/wiki/Loop_tiling Loop Tiling to make sure large data (for example Matrix Multiplications of like [3000] by [3000].

Currently I just ran multiple tests per computer, increasing block size, and grabbed the optimal cache that way but I am looking for a much faster run time calculator, or API, or something to help me determine this within C#.

Falcon165o
  • 2,875
  • 1
  • 20
  • 31
  • Possible duplicate of [how to determine CPU cache size in .NET?](http://stackoverflow.com/questions/6995787/how-to-determine-cpu-cache-size-in-net) – eirikdaude Feb 26 '16 at 12:51

1 Answers1

-5

AFAIK, C# is not a language that cares about such low-level questions. .Net Framework and the underlying OS should take care of that. It's not your problem as a .Net programmer.

If you DO want to know, you'll have to use/write a function/library in some lower level language like C/C++ (like this)

Community
  • 1
  • 1
m0skit0
  • 25,268
  • 11
  • 79
  • 127
  • 1
    I was using C# for the parallel processing mainly. I know how to do it a little bit in C but felt a lot better about doing it in C#. I could always cheat a little bit and write something in C or C++ to output it and read it into C# couldn't i? – Falcon165o Feb 22 '12 at 15:32
  • That's what I meant. Also if you check that link I gave, in Linux you can grab the cache from *sys*, although I don't think this interests you at all :) – m0skit0 Feb 22 '12 at 15:34
  • 1
    Yeah I saw that; then I traced it to the Windows Version and I could base it from it. Thank you :) Marking as answered. – Falcon165o Feb 22 '12 at 15:56
  • 2
    I'm sorry, but C# has pointers and explicit struct layouts and SIMD primitives. Of COURSE C# cares about this stuff. This isn't Java. – hoodaticus Dec 10 '16 at 00:33
  • @hoodaticus Hence the AFAIK ;) – m0skit0 Dec 10 '16 at 19:35