lcompilers / lc

C++ compiler
MIT License
26 stars 7 forks source link

Support XSimd #86

Open anutosh491 opened 9 months ago

anutosh491 commented 9 months ago

The project looks great. It would be nice if there could be some support for libraries providing C++ wrappers for SIMD intrinsics. A prime example for this could be 1) https://github.com/xtensor-stack/xsimd 2) https://xsimd.readthedocs.io/en/latest/index.html

anutosh491 commented 9 months ago

A simple example for the same would be

#include "xsimd/xsimd.hpp"
#include <iostream>

namespace xs = xsimd;

int main(int, char*[])
{
    xs::batch<double, xs::avx> a = { 1.5, 2.5, 3.5, 4.5 };
    xs::batch<double, xs::avx> b = { 2.5, 3.5, 4.5, 5.5 };
    auto mean = (a + b) / 2;
    std::cout << mean << std::endl;
    return 0;
}
(2.0, 3.0, 4.0, 5.0)
certik commented 9 months ago

Yes, for xsimd we should use our "SIMD" physical array in LCompilers, to generate vectorized code.