facebookresearch / TensorComprehensions

A domain specific language to express machine learning workloads.
https://facebookresearch.github.io/TensorComprehensions/
Apache License 2.0
1.76k stars 211 forks source link

Support -mpcu flag and autodetect to trigger vectorization on proper vector lengths #588

Open nicolasvasilache opened 6 years ago

nicolasvasilache commented 6 years ago

This PR passes proper llvm::TargetMachine information in llvm_jit and codegen_llvm by introducing a proper TargetMachine at the LLVMJit level and avoids introducing adhoc objects.

The TargetMachine is constructed either from the --mcpu flag if passed or from the cpuid information.

As a consequence of all this, one can now emit AVX2 and AVX512 code. Before this commit, the TargetMachine was essentially a default one and only AVX code would be generated.

To test and see it one can run with:

cd build && \
make -j 16 test_mapper_llvm && \
./test/test_mapper_llvm --logtostderr=1 --llvm_dump_asm=1 --llvm_dump_after_opt=1 --llvm_dump_before_opt=1 --gtest_filter="*Batch*" --mcpu=skylake

Of course if one forces a more fancy architecture than one has, illegal instructions will likely be generated but at least the asm will be printed properly.

facebook-github-bot commented 6 years ago

Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours has expired.

Before we can review or merge your code, we need you to email cla@fb.com with your details so we can update your status.