Shachar, Before AVX512, all Intel ISA were backward compatible. I.e., for example, any AVX2 machine were capable to executed any of AVX1.1 AVX1, SSE4, SSSE3, SSE2, ... code.
Starting AVX512 it's a little different and AVX512 consist of several sets (F, BW, Vl, ...). Wikipedia describes that well. And specific chip has support for specific set of instructions, so KNL (Xeon Phi) and SKX (Xeon Scalable) have different sets of instruction: KNL (F, CD, ER, PF) and SKX (F, CD, VL, DQ, BW). So we have to different targets: avx512knl and avx512skx. But I guess you care more about AVX2. If you are targeting specific CPU, just use it as a target. If you are targeting multiple CPUs, you might have two strategies: (1) use the least common denominator (say, SSE4) or (2) do multi-versioning, so you chose the right optimized version in runtime. The second case is obviously a better choice. So, all you need is to specify the list of targets you'd like to support, as you did in your example. auto-dispatch code will be generated automatically. But there's one nuance, ISPC target also has a "width": in avx2-i32x8, the last 8 is a width. Typically it matches SIMD width, but sometimes it's beneficial to have "double pumped" target, like avx2-i32x16 - typically it's beneficial for compute intensive kernels with low register pressure. The choice has to be static - you just decide which one suits better your code and use it for AVX2 hardware. So, use --target=<list> switch with the list of desired supported platforms, but avoid collision on the first part (as "avx2" in avx2-i32x8) of target. Hope my explanation is not too messy. Let me know if it helps. Dmitry On Fri, Apr 12, 2019 at 10:48 AM shachar harussi <[email protected]> wrote: > Hi Dimitry > Thanks for the quick reply > Since I’m new to ispc I’m probably missing something and I need your help > in figuring out if so. So let me rephrase: > I want to compile a single version that support avx optimizations. > The cpu could be any, the cpu flags could be just avx or avx+avx2. Now the > question is what is the target I need to compile with? > —target=avx > —target-avx2 > Both? Other? > Any help is appreciated > > Thanks > Shachar > > > On Fri, Apr 12, 2019 at 1:13 AM Dmitry Babokin <[email protected]> wrote: > >> Hi Shachar, >> >> When you use multiple targets in the same compilation, it triggers >> enabling of auto-dispatch code. The problem is that auto-dispatch needs to >> make decision for the dispatch solely on CPUID. Hence two targets for the >> same ISA, but with different width cause ambiguity. >> >> Who are you going to use the same function compiled for the same AVX >> targets in different variants? How are you going to make a decision which >> version to use? >> >> Dmitry. >> >> On Thu, Apr 11, 2019 at 7:40 AM shachar harussi <[email protected]> >> wrote: >> >>> Hi, >>> I compile w/ ispc for multiple targets ( same code on different machines >>> w/ avx OR avx2 OR both) >>> tried >>> ispc --pic >>> --target=avx1-i32x4,avx1-i32x8,avx1-i32x16,avx1-i64x4,avx1.1-i32x8,avx1.1-i32x16,avx1.1-i64x4,avx2-i32x8,avx2-i32x16,avx2-i64x4,avx512knl-i32x16,avx512skx-i32x16 >>> ${CMAKE_CURRENT_SOURCE_DIR}/ispc/${srcfile}.ispc -o ${srcfile}.o >>> >>> but getting >>> >>> Error: Can't compile to multiple variants of avx target! >>> >>> What should I do ? >>> >>> use generic ? >>> >>> compile w/ different avx targets by my self ? >>> >>> best, >>> >>> Shachar >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Intel SPMD Program Compiler Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Intel SPMD Program Compiler Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "Intel SPMD Program Compiler Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Intel SPMD Program Compiler Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
