0

I’m learning how to use SIMD (Single Instruction, Multiple Data) for parallel data processing.

Suppose I have a large dataset (e.g., an array of 1 million floats), and I want to process it efficiently using SIMD instructions (like SSE, AVX, or NEON).

My question is: How do I decide how much data a processor or core should process in a SIMD program?

Do I just split the data evenly by the number of logical cores or SIMD lanes? Or are there other things to consider?

Additional context: • I know that SIMD operates on vectors (e.g., 128-bit or 256-bit registers), so I can process 4 or 8 floats at a time depending on the instruction set. • I’m not sure how this interacts with CPU cores or hardware threads. • Should I also consider cache size, memory bandwidth, or NUMA?

What are the best practices or heuristics to decide the data chunk size when designing a SIMD-parallel program?

7
  • Sounds like you're asking about dividing work between threads, which is unrelated to SIMD. For comparison of strategies, see OpenMP schedule static vs. dynamic. Within each thread, you use full-width SIMD when you have big arrays (except sometimes with AVX-512 you might only use 256-bit vectors). Commented Sep 29 at 17:03
  • It really depends on your problem and your CPU and what other tasks you do in the background if it is even worth the overhead of multithreading. If you have a million floats and perform like 10 flops on each it will probably take less than a millisecond on a single core. (Whether that time is short or long also depends on your problem ...) Commented Sep 29 at 17:38
  • "I’m not sure how this interacts with CPU cores" This is two (mostly) independent things. Generally, people split data in (often contiguous) chunks that are computed by each thread. Each thread can then compute things using SIMD instruction independently of others. Commented Sep 29 at 20:19
  • Please note however that >=2 threads can be executed to the same CPU core thanks to simultaneous multithreading (a.k.a. SMT). SMT can significantly impact the performance of an SIMD code and also the way you write them. Predicting the impact of SMT on code is known to be often very challenging (on any non-trivial code) so the best is to run the target code. Thus, it is hard to draw guidelines in such a case. Commented Sep 29 at 20:24
  • 1
    "What are the best practices or heuristics to decide the data chunk size when designing a SIMD-parallel program?" I am not sure to fully understand the question. The bigger the chunks size, the better. However, there is a balance to find between SIMD and multithreading. The chunks should be at least the size of the native SIMD vectors. For sake of efficiency (and to leverage instruction-level parallelism, a.k.a. ILP), I advise you to increase this minimum to at least 2~4 times the size of the native SIMD vectors. Commented Sep 29 at 20:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.