Agner`s CPU blog

Software optimization resources | E-mail subscription to this blog | www.agner.org

 
thread Major update of Vector Class Library - Agner - 2019-08-05
last replythread Major update of Vector Class Library - aalex - 2020-07-21
last reply Major update of Vector Class Library - Agner - 2020-07-22
 
Major update of Vector Class Library
Author: Agner Date: 2019-08-05 03:15
Good news. I have made a major update of the Vector Class Library.


Highlights:


  • Moved to Github
  • Apache 2.0 License
  • VCL version 2 uses the C++17 standard. Version 1 is still available for compilers not supporting C++17
  • Makes full use of new instruction sets: AVX512F/BW/DQ/VL
  • Support for future instruction sets: AVX512VBMI and VBMI2
  • Improved permute and blend functions, making full use of C++17 metaprogramming features
  • Testbench for systematic testing of VCL
  • Add-on packages for various purposes

This has been a lot of work, and it has been postponed because I have been busy on other projects. But finally VCL version 2.00 is here. The new C++14 and C++17 standards allow me to do a lot of metaprogramming, especially in the permute and blend functions. The code will do a lot of calculations and search to find the optimal implementation of a particular permutation pattern - at compile time. The result is just one or a few instructions to execute at run time. These metaprogramming features are something that I have been longing for. Version 1 of VCL used a lot of awkward tricks to work with the limited metaprogramming possibilities.


The AVX512 instruction set adds a lot of instructions that we have been missing. It also adds more efficient branching and conditional execution of vector elements. PC processors with AVX512 have been delayed for a couple of years, but now they are available, and they give significant improvement to vector performance.


More than half the work of updating VCL has been testing. I have developed a testbench and a bash script that runs through thousands of combinations of functions, operators, vector classes, instruction sets, compilers, and platforms. Each combination is compiled and tested automatically. It would have been impossible to do so many tests manually. The development of this testbench has certainly been worth the effort. It allowed me to find some hidden bugs in my code - and some bugs in the compilers as well.


The Vector Class Library is already used by programmers all over the world. I am sure that it will be even more useful with these updates.


I have decided for a more permissive license because the selling of commercial licenses gave a lot of administrative and bureaucratic problems for just a small profit. The Apache license will make commercial use of VCL easier. Instead of selling commercial licenses, I am now suggesting that commercial users donate to some open source project.

   
Major update of Vector Class Library
Author:  Date: 2020-07-21 20:25
I am seeing the following error while compiling vcl ( in fact just including the vectorclass.h header) , please advice

====== code being compiled ================
#include <stdio.h>
#include "vectorclass.h"

int main()
{}

============ error ==========================

g++ -mavx -march=native -O3 -std=gnu++17 -I./version2-master -o output/test_vcl test_vcl.cpp
In file included from ./version2-master/vectorclass.h:37:0,
from test_vcl.cpp:5:
./version2-master/instrset.h: In function ‘VTYPE nan_vec(uint32_t)’:
./version2-master/instrset.h:423:8: error: expected ‘(’ before ‘constexpr’
if constexpr ((VTYPE::elementtype() & 1) != 0) { // double
^
test_vcl.cpp:30:1: error: expected ‘}’ at end of input
}
^
makefile:6: recipe for target 'output/test_vcl' failed
make: *** [output/test_vcl] Error 1

============ error ==========================

g++ -mavx -march=native -O3 -std=c++17 -I./version2-master -o output/test_vcl test_vcl.cpp
In file included from ./version2-master/vectorclass.h:37:0,
from test_vcl.cpp:5:
./version2-master/instrset.h: In function ‘VTYPE nan_vec(uint32_t)’:
./version2-master/instrset.h:423:8: error: expected ‘(’ before ‘constexpr’
if constexpr ((VTYPE::elementtype() & 1) != 0) { // double
^
test_vcl.cpp:21:1: error: expected ‘}’ at end of input
}

g++ -mavx -O3 -std=c++17 -I./version2-master -o output/test_vcl test_vcl.cpp
In file included from ./version2-master/vectorclass.h:37:0,
from test_vcl.cpp:5:
./version2-master/instrset.h: In function ‘VTYPE nan_vec(uint32_t)’:
./version2-master/instrset.h:423:8: error: expected ‘(’ before ‘constexpr’
if constexpr ((VTYPE::elementtype() & 1) != 0) { // double
^
test_vcl.cpp:21:1: error: expected ‘}’ at end of input
}

============= compiler info =============================================
aalex@aalex-desktop:~/projects/sdn/3rdparty/vcl$ g++ --version
g++ (Ubuntu 5.5.0-12ubuntu1~16.04) 5.5.0 20171010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


======= cpu info ===========================
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 21
Model: 1
Model name: AMD FX(tm)-8120 Eight-Core Processor
Stepping: 2
CPU MHz: 1417.109
CPU max MHz: 3100.0000
CPU min MHz: 1400.0000
BogoMIPS: 6221.23
Virtualization: AMD-V
L1d cache: 16K
L1i cache: 64K
L2 cache: 2048K
L3 cache: 8192K
NUMA node0 CPU(s): 0-7
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 cx16 sse4_1 sse4_2 popcnt aes xsave avx lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs xop skinit wdt lwp fma4 nodeid_msr topoext perfctr_core perfctr_nb cpb hw_pstate ssbd ibpb vmmcall arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold

   
Major update of Vector Class Library
Author: Agner Date: 2020-07-22 00:06
aalex wrote:
I am seeing the following error while compiling vcl
Please use a newer version of g++ or clang++