Multithreading can be enabled for libsvm-3.0, though it requires some modification in the source and the makefile. However, the modification is trivial and is explained here: http://www.csie.ntu.edu.tw/~cjlin/libsvm/faq.html#f432 The dependency required is OpenMP and GCC >= 4.2. Description (in case the webpage above is down): It is very easy if you are using GCC 4.2 or after. In Makefile, add -fopenmp to CFLAGS. In class SVC_Q of svm.cpp, modify the for loop of get_Q to: #pragma omp parallel for private(j) for(j=start;j<len;j++) In the subroutine svm_predict_values of svm.cpp, add one line to the for loop: #pragma omp parallel for private(i) for(i=0;i<l;i++) kvalue[i] = Kernel::k_function(x,model->SV[i],model->param); For regression, you need a reduction clause for the variable sum: #pragma omp parallel for private(i) reduction(+:sum) for(i=0;i<model->l;i++) sum += sv_coef[i] * Kernel::k_function(x,model>SV[i],model>param); Then rebuild the package. Kernel evaluations in training/testing will be parallelized. ... For Python interface, you need to add the -lgomp link option: $(CXX) -lgomp -shared -dynamiclib svm.o -o libsvm.so.$(SHVER) Reproducible: Always
Hi. That could be a nice improvement, but we have the policy to follow upstream as much as we can. You could suggest the libsvm folks to roll a new release with the possibility of enabling openmp. Or if you insist, provide a patch here for the current ebuild. Also note gomp is specific to gcc. Thanks.
Created attachment 271171 [details, diff] OpenMP patch for LibSVM-3.1 Patch to enable OpenMP for LibSVM-3.1.
Okay. I've created a patch for LibSVM version 3.1 (which is still not available in Portage tree at the time of this writing). Basically, we need to build LibSVM with "make OPENMP=y" instead of simply "make". The problem is I don't know much about ebuild files. So, I don't know how to modify it. Hope this helps.
in cvs. thanks!