Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c1b2a0e5 authored by hhakim's avatar hhakim
Browse files

Integrate gpu_mod into Faust with tests for double and complex<double>. Faust...

Integrate gpu_mod into Faust with tests for double and complex<double>. Faust optimize_time is capable to use gpu_mod.

See git-submodule gpu_mod for more info.

[skip ci]
parent 95e4de46
No related branches found
No related tags found
No related merge requests found
[submodule "gpu_mod"]
path = gpu_mod
url = https://gitlab.inria.fr/faustgrp/gpu_mod
...@@ -242,6 +242,7 @@ option(NOPY2 "Enabling/Disabling python2 support." OFF) ...@@ -242,6 +242,7 @@ option(NOPY2 "Enabling/Disabling python2 support." OFF)
#set(BUILD_READ_MAT_FILE OFF CACHE BOOL "Using matio library to read mat files") #set(BUILD_READ_MAT_FILE OFF CACHE BOOL "Using matio library to read mat files")
option(FAUST_TORCH "Faust torch backend for the Faust-Matrix/Vector product." OFF) option(FAUST_TORCH "Faust torch backend for the Faust-Matrix/Vector product." OFF)
option(USE_GPU_MOD "Faust cuda backend for the Faust-Matrix/Vector prodduct." OFF)
if (BUILD_USE_SINGLEPRECISION) if (BUILD_USE_SINGLEPRECISION)
...@@ -625,6 +626,21 @@ if(FAUST_TORCH) ...@@ -625,6 +626,21 @@ if(FAUST_TORCH)
message(STATUS TORCH_DIR=${Torch_DIR}) message(STATUS TORCH_DIR=${Torch_DIR})
endif() endif()
if(USE_GPU_MOD)
find_package(GPU_MOD REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GPU_MOD_CFLAGS} -I${GPU_MOD_INCLUDE_DIR} -DUSE_GPU_MOD")
message(STATUS FaustCuda enabled)
set(FAUST_SCALAR_FOR_GM double)
set(GM_SCALAR double)
set(GM_REINTERPRET_CAST_SCALAR double)
configure_file(${FAUST_LINEAR_OPERATOR_CPU_SRC_DIR}/faust_gpu_mod_gen.hpp.in ${FAUST_LINEAR_OPERATOR_CPU_SRC_DIR}/faust_gpu_mod_double.hpp)
set(FAUST_SCALAR_FOR_GM complex<double>)
set(GM_SCALAR cuDoubleComplex)
set(GM_REINTERPRET_CAST_SCALAR double)
configure_file(${FAUST_LINEAR_OPERATOR_CPU_SRC_DIR}/faust_gpu_mod_gen.hpp.in ${FAUST_LINEAR_OPERATOR_CPU_SRC_DIR}/faust_gpu_mod_complexdouble.hpp)
endif()
include_directories(BEFORE ${EIGEN_INC_DIR} ${FAUST_SRC_LINEAR_OPERATOR_DIR} ${FAUST_LINEAR_OPERATOR_CPU_SRC_DIR} ${FAUST_ALGORITHM_FACTORIZATION_SRC_DIR} ${FAUST_UTILS_SRC_DIR}) include_directories(BEFORE ${EIGEN_INC_DIR} ${FAUST_SRC_LINEAR_OPERATOR_DIR} ${FAUST_LINEAR_OPERATOR_CPU_SRC_DIR} ${FAUST_ALGORITHM_FACTORIZATION_SRC_DIR} ${FAUST_UTILS_SRC_DIR})
########### add_subdirectory ############### ########### add_subdirectory ###############
if (BUILD_WRAPPER_PYTHON) if (BUILD_WRAPPER_PYTHON)
...@@ -697,6 +713,12 @@ if(FAUST_TORCH) ...@@ -697,6 +713,12 @@ if(FAUST_TORCH)
target_include_directories(${FAUST_TARGET} PUBLIC ${Torch_DIR}/../include ${Torch_DIR}/../include/torch/csrc/api/include) target_include_directories(${FAUST_TARGET} PUBLIC ${Torch_DIR}/../include ${Torch_DIR}/../include/torch/csrc/api/include)
endif() endif()
if(USE_GPU_MOD)
include_directories(${FAUST_TARGET} ${GPU_MOD_INCLUDE_DIR} ${GPU_MOD_INCLUDE_DIR}/../build)
target_include_directories(${FAUST_TARGET} PUBLIC ${GPU_MOD_INCLUDE_DIR} ${GPU_MOD_INCLUDE_DIR}/../build)
target_link_libraries(${FAUST_TARGET} ${GPU_MOD_LIBS})
endif()
if (BUILD_WRAPPER_MATLAB) if (BUILD_WRAPPER_MATLAB)
if (UNIX) if (UNIX)
if(APPLE) if(APPLE)
...@@ -839,17 +861,18 @@ SET(CPACK_STRIP_FILES "") ...@@ -839,17 +861,18 @@ SET(CPACK_STRIP_FILES "")
#SET(CPACK_SOURCE_IGNORE_FILES "/build/;/CMakeFiles/;/_CPack_Packages/;/bin/make_regression_constants;/install_manifest_/;.*~;/www/;/CVS//;/.svn/;/.git/;.cdtprojects;.project;/.settings/") #SET(CPACK_SOURCE_IGNORE_FILES "/build/;/CMakeFiles/;/_CPack_Packages/;/bin/make_regression_constants;/install_manifest_/;.*~;/www/;/CVS//;/.svn/;/.git/;.cdtprojects;.project;/.settings/")
IF(WIN32 AND NOT UNIX) IF(WIN32 AND NOT UNIX)
# NSIS is used independently (see misc/nsis/faust.nsi)
SET(CPACK_GENERATOR "NSIS") SET(CPACK_GENERATOR "NSIS")
IF(CMAKE_CL_64) IF(CMAKE_CL_64)
SET(CPACK_PACKAGE_FILE_NAME "FAUST-binary-${CPACK_PACKAGE_VERSION}-x86_64-Windows") SET(CPACK_PACKAGE_FILE_NAME "FAUST-binary-${CPACK_PACKAGE_VERSION}-x86_64-Windows")
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "FAUST-binary-${CPACK_PACKAGE_VERSION}-x86_64-Windows") SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "FAUST-binary-${CPACK_PACKAGE_VERSION}-x86_64-Windows")
ELSE(CMAKE_CL_64) ELSE(CMAKE_CL_64)
SET(CPACK_PACKAGE_FILE_NAME "FAUST-binary-${CPACK_PACKAGE_VERSION}-i386-Windows") SET(CPACK_PACKAGE_FILE_NAME "FAUST-binary-${CPACK_PACKAGE_VERSION}-i386-Windows")
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "FAUST-binary-${CPACK_PACKAGE_VERSION}-i386-Windows") SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "FAUST-binary-${CPACK_PACKAGE_VERSION}-i386-Windows")
ENDIF(CMAKE_CL_64) ENDIF(CMAKE_CL_64)
# NSIS not used yet, cause of a bug with suitable ZIP programme # NSIS not used yet, cause of a bug with suitable ZIP programme
# There is a bug in NSI that does not handle full unix paths properly. Make # There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes. # sure there is at least one set of four (4) backslashes.
# UPDATE: NSIS is used externally, see misc/nsis/faust.nis # UPDATE: NSIS is used externally, see misc/nsis/faust.nis
# SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp") # SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
SET(CPACK_NSIS_DISPLAY_NAME "FAUST") SET(CPACK_NSIS_DISPLAY_NAME "FAUST")
......
Subproject commit 933f3af9e16c808035fe545e0f771b9f88a0b20e
...@@ -197,11 +197,15 @@ if(MATIO_LIB_FILE AND MATIO_INC_DIR AND BUILD_READ_MAT_FILE AND NOT NOCPPTESTS) ...@@ -197,11 +197,15 @@ if(MATIO_LIB_FILE AND MATIO_INC_DIR AND BUILD_READ_MAT_FILE AND NOT NOCPPTESTS)
# faust_multiplication : time comparison between Faust-vector product and Dense matrix-vector product # faust_multiplication : time comparison between Faust-vector product and Dense matrix-vector product
list(APPEND tests hierarchicalFactorization hierarchicalFactorizationFFT test_palm4MSA test_palm4MSAFFT faust_multiplication faust_matdense_conjugate GivensFGFT GivensFGFTSparse GivensFGFTParallel GivensFGFTParallelSparse test_MatDiag faust_matsparse_mul faust_matsparse_index_op GivensFGFTComplex GivensFGFTComplexSparse GivensFGFTParallelComplex faust_toeplitz faust_circ faust_hankel palm4msa_2020 hierarchical2020 hierarchical2020Hadamard hierarchicalFactorizationHadamard) list(APPEND tests hierarchicalFactorization hierarchicalFactorizationFFT test_palm4MSA test_palm4MSAFFT faust_multiplication faust_matdense_conjugate GivensFGFT GivensFGFTSparse GivensFGFTParallel GivensFGFTParallelSparse test_MatDiag faust_matsparse_mul faust_matsparse_index_op GivensFGFTComplex GivensFGFTComplexSparse GivensFGFTParallelComplex faust_toeplitz faust_circ faust_hankel palm4msa_2020 hierarchical2020 hierarchical2020Hadamard hierarchicalFactorizationHadamard)
if(FAUST_TORCH) if(FAUST_TORCH)
list(APPEND tests faust_torch) list(APPEND tests faust_torch)
endif() endif()
if(USE_GPU_MOD)
list(APPEND tests faust_gpu_mod)
endif()
foreach(TEST_FPP float double complex<float> complex<double>) foreach(TEST_FPP float double complex<float> complex<double>)
foreach(testin IN LISTS tests) foreach(testin IN LISTS tests)
if(${TEST_FPP} MATCHES complex ) if(${TEST_FPP} MATCHES complex )
......
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
#ifdef FAUST_TORCH #ifdef FAUST_TORCH
#include "faust_torch.h" #include "faust_torch.h"
#endif #endif
#ifdef USE_GPU_MOD
#include "faust_gpu_mod.h"
#endif
namespace Faust { namespace Faust {
...@@ -93,6 +96,9 @@ namespace Faust { ...@@ -93,6 +96,9 @@ namespace Faust {
#ifdef FAUST_TORCH #ifdef FAUST_TORCH
std::vector<torch::Tensor> tensor_data; std::vector<torch::Tensor> tensor_data;
#endif #endif
#ifdef USE_GPU_MOD
FaustGPU<FPP> *gpu_faust;
#endif
void eval_sliced_Transform(); void eval_sliced_Transform();
void eval_fancy_idx_Transform(); void eval_fancy_idx_Transform();
......
...@@ -73,6 +73,9 @@ namespace Faust { ...@@ -73,6 +73,9 @@ namespace Faust {
template<typename FPP> template<typename FPP>
TransformHelper<FPP,Cpu>::TransformHelper() : is_transposed(false), is_conjugate(false), is_sliced(false), is_fancy_indexed(false), mul_order_opt_mode(0) TransformHelper<FPP,Cpu>::TransformHelper() : is_transposed(false), is_conjugate(false), is_sliced(false), is_fancy_indexed(false), mul_order_opt_mode(0)
#ifdef USE_GPU_MOD
, gpu_faust(nullptr)
#endif
{ {
this->transform = make_shared<Transform<FPP,Cpu>>(); this->transform = make_shared<Transform<FPP,Cpu>>();
} }
...@@ -235,6 +238,13 @@ namespace Faust { ...@@ -235,6 +238,13 @@ namespace Faust {
convMatGenListToTensorList(this->transform->data, tensor_data, at::kCPU, /* clone */ false, /* transpose */ ! is_transposed); convMatGenListToTensorList(this->transform->data, tensor_data, at::kCPU, /* clone */ false, /* transpose */ ! is_transposed);
// display_TensorList(tensor_data); // display_TensorList(tensor_data);
} }
#endif
#ifdef USE_GPU_MOD
if(mul_order_opt_mode == 10 && gpu_faust == nullptr)
{
Faust::FaustGPU<FPP>::init_gpu_mod(); //TODO: function enable_gpu_mod()
gpu_faust = new Faust::FaustGPU<FPP>(this->transform->data);
}
#endif #endif
switch(this->mul_order_opt_mode) switch(this->mul_order_opt_mode)
{ {
...@@ -276,6 +286,11 @@ namespace Faust { ...@@ -276,6 +286,11 @@ namespace Faust {
case 9: case 9:
Faust::tensor_chain_mul(tensor_data, M, &A, /* on_gpu */ false, /*clone */ false, /* chain_opt */ false, /* contiguous_dense_to_torch */ true, !is_transposed); Faust::tensor_chain_mul(tensor_data, M, &A, /* on_gpu */ false, /*clone */ false, /* chain_opt */ false, /* contiguous_dense_to_torch */ true, !is_transposed);
break; break;
#endif
#ifdef USE_GPU_MOD
case 10:
M = gpu_faust->multiply(&A);
break;
#endif #endif
default: default:
M = this->transform->multiply(A, isTransposed2char()); M = this->transform->multiply(A, isTransposed2char());
...@@ -353,7 +368,7 @@ namespace Faust { ...@@ -353,7 +368,7 @@ namespace Faust {
TransformHelper<FPP,Cpu>* TransformHelper<FPP,Cpu>::optimize_multiply(const bool transp /* deft to false */, const bool inplace, /* deft to 1 */ const int nsamples) TransformHelper<FPP,Cpu>* TransformHelper<FPP,Cpu>::optimize_multiply(const bool transp /* deft to false */, const bool inplace, /* deft to 1 */ const int nsamples)
{ {
TransformHelper<FPP,Cpu>* t_opt = nullptr; TransformHelper<FPP,Cpu>* t_opt = nullptr;
int NMETS = 10; int NMETS = 11;
std::chrono::duration<double> * times = new std::chrono::duration<double>[NMETS]; //use heap because of VS14 (error C3863) std::chrono::duration<double> * times = new std::chrono::duration<double>[NMETS]; //use heap because of VS14 (error C3863)
// MatDense<FPP,Cpu>* M = MatDense<FPP,Cpu>::randMat(transp?this->getNbRow():this->getNbCol(), 2048); // MatDense<FPP,Cpu>* M = MatDense<FPP,Cpu>::randMat(transp?this->getNbRow():this->getNbCol(), 2048);
int old_meth = this->get_mul_order_opt_mode(); int old_meth = this->get_mul_order_opt_mode();
...@@ -373,7 +388,15 @@ namespace Faust { ...@@ -373,7 +388,15 @@ namespace Faust {
for(int i=7;i<10;i++) for(int i=7;i<10;i++)
disabled_meths.push_back(i); disabled_meths.push_back(i);
#endif #endif
#ifdef USE_GPU_MOD
if(gpu_faust == nullptr)
{
Faust::FaustGPU<FPP>::init_gpu_mod(); //TODO: function enable_gpu_mod()
gpu_faust = new Faust::FaustGPU<FPP>(this->transform->data);
}
#else
disabled_meths.push_back(10);
#endif
for(int i=0; i < NMETS; i++) for(int i=0; i < NMETS; i++)
{ {
if(std::find(std::begin(disabled_meths), std::end(disabled_meths), i) != std::end(disabled_meths)) if(std::find(std::begin(disabled_meths), std::end(disabled_meths), i) != std::end(disabled_meths))
......
...@@ -100,6 +100,11 @@ if(FAUST_TORCH) ...@@ -100,6 +100,11 @@ if(FAUST_TORCH)
set(PYFAUST_PKG_SUFFIX "_torch") set(PYFAUST_PKG_SUFFIX "_torch")
endif() endif()
if(USE_GPU_MOD)
set(FAUST_PYTHON_INCLUDE_DIR "${FAUST_PYTHON_INCLUDE_DIR}, '${GPU_MOD_INCLUDE_DIR}', '${GPU_MOD_INCLUDE_DIR}/../build/'")
set(FAUST_SETUP_PY_CFLAGS "${FAUST_SETUP_PY_CFLAGS}, '-DUSE_GPU_MOD'")
endif()
# configure the setup.py.in into setup.py (equivalent of Makefile for Python) # configure the setup.py.in into setup.py (equivalent of Makefile for Python)
configure_file(${FAUST_PYTHON_SRC_DIR}/setup.py.in ${FAUST_PYTHON_BIN_DIR}/setup.py @ONLY) configure_file(${FAUST_PYTHON_SRC_DIR}/setup.py.in ${FAUST_PYTHON_BIN_DIR}/setup.py @ONLY)
configure_file(${FAUST_PYTHON_SRC_SRC_DIR}/_FaustCorePy.pyx ${FAUST_PYTHON_BIN_DIR}/_FaustCorePy.pyx COPYONLY) configure_file(${FAUST_PYTHON_SRC_SRC_DIR}/_FaustCorePy.pyx ${FAUST_PYTHON_BIN_DIR}/_FaustCorePy.pyx COPYONLY)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment