Mentions légales du service

Skip to content
Snippets Groups Projects
Commit ea9a42d2 authored by Adrien Leman's avatar Adrien Leman Committed by hhakim
Browse files

debug 4 hierfactorization 4 GPU

parent fc7e8f70
Branches
Tags
No related merge requests found
...@@ -9,27 +9,54 @@ endif(BUILD_READ_MAT_FILE) ...@@ -9,27 +9,54 @@ endif(BUILD_READ_MAT_FILE)
add_definitions(-DCOMPILE_GPU) add_definitions(-DCOMPILE_GPU)
# generation des executables de algorithme hierarchical_fact en GPU en simple et double precision
foreach(TEST_FPP float double)
foreach(testin hierarchicalFactorization_gpu) if(BUILD_READ_MAT_FILE AND MATIO_LIB_FILE AND MATIO_INC_DIR )
# generation des executables de algorithme hierarchical_fact en GPU en simple et double precision
foreach(TEST_FPP float double)
foreach(testin hierarchicalFactorization_gpu ) #Faust_multiplication_gpu
# copy CPU files cpp.in to the user's ./src/ directory en float et double precision # copy CPU files cpp.in to the user's ./src/ directory en float et double precision
configure_file(${FAUST_SRC_TEST_SRC_DIR}/${testin}.cpp.in ${FAUST_BIN_TEST_SRC_DIR}/${testin}_${TEST_FPP}.cpp @ONLY) configure_file(${FAUST_SRC_TEST_SRC_DIR}/${testin}.cpp.in ${FAUST_BIN_TEST_SRC_DIR}/${testin}_${TEST_FPP}.cpp @ONLY)
# Creation des executable en double et en float # Creation des executable en double et en float
add_executable(${testin}_${TEST_FPP} ${FAUST_BIN_TEST_SRC_DIR}/${testin}_${TEST_FPP}.cpp ${FAUST_BIN_TEST_SRC_DIR}/ ${FAUST_CMDLINE_TYPE_FORMAT_MAT_SRC_DIR}/faust_init_from_matio.cpp ${FAUST_CMDLINE_TYPE_FORMAT_MAT_SRC_DIR}/faust_init_from_matio_mat.cpp) add_executable(${testin}_${TEST_FPP} ${FAUST_BIN_TEST_SRC_DIR}/${testin}_${TEST_FPP}.cpp ${FAUST_BIN_TEST_SRC_DIR}/ ${FAUST_CMDLINE_TYPE_FORMAT_MAT_SRC_DIR}/faust_init_from_matio.cpp ${FAUST_CMDLINE_TYPE_FORMAT_MAT_SRC_DIR}/faust_init_from_matio_mat.cpp)
target_link_libraries(${testin}_${TEST_FPP} ${FAUST_TARGET} ${MATIO_LIB_FILE} ${HDF5_LIB_FILE} ${CUBLAS_LIB_FILE} ${CUDART_LIB_FILE} ${CUSPARSE_LIB_FILE}) target_link_libraries(${testin}_${TEST_FPP} ${FAUST_TARGET} ${MATIO_LIB_FILE} ${HDF5_LIB_FILE} ${CUBLAS_LIB_FILE} ${CUDART_LIB_FILE} ${CUSPARSE_LIB_FILE})
install(TARGETS ${testin}_${TEST_FPP} DESTINATION ${FAUST_INSTALL_BIN}) install(TARGETS ${testin}_${TEST_FPP} DESTINATION ${FAUST_INSTALL_BIN})
endforeach()
endforeach() endforeach()
endforeach() ###### IN CASE MATIO IS NOT AVAILABLE YOU CAN RUN THE TEST ######
else(BUILD_READ_MAT_FILE AND MATIO_LIB_FILE AND MATIO_INC_DIR )
# test GPU #message(STATUS "Library matio is not available. Please used .xml input files.")
add_test(NAME HADAMARD_GPU_FACT_DOUBLE COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_double ${FAUST_DATA_MAT_DIR}/config_HADAMARD.mat) endif(BUILD_READ_MAT_FILE AND MATIO_LIB_FILE AND MATIO_INC_DIR )
add_test(NAME FAUST_HIER_GPU_DOUBLE COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_double ${FAUST_DATA_MAT_DIR}/config_compared_hierarchical_fact.mat 9401.5 0.1)
add_test(NAME FAUST_HIER_GPU_FLOAT COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_float ${FAUST_DATA_MAT_DIR}/config_compared_hierarchical_fact.mat 9401.5 0.1)
add_test(NAME MEG_GPU_FACT_FLOAT COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_float ${FAUST_DATA_MAT_DIR}/config_MEG.mat 22332 1)
add_test(NAME MEG_GPU_FACT_DOUBLE COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_double ${FAUST_DATA_MAT_DIR}/config_MEG.mat 22480 1)
set(TIMEOUT_MEG 14000) set(TIMEOUT_MEG 14000)
set_tests_properties(MEG_GPU_FACT_FLOAT MEG_GPU_FACT_DOUBLE PROPERTIES TIMEOUT ${TIMEOUT_MEG}) # MATLAB input format
if (BUILD_READ_MAT_FILE AND MATIO_LIB_FILE AND MATIO_INC_DIR)
foreach(TEST_FPP float double)
#message (STATUS "------------------------------------------------")
#message (STATUS "${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_${TEST_FPP} ${FAUST_DATA_MAT_DIR}/matrix_HADAMARD_32.mat ${FAUST_CONFIG_MAT_DIR}/config_HADAMARD_32.mat 5930 30")
add_test(NAME MATFILE_FACT_HADAMARD_GPU_${TEST_FPP} COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_${TEST_FPP} ${FAUST_DATA_MAT_DIR}/matrix_HADAMARD_32.mat ${FAUST_CONFIG_MAT_DIR}/config_HADAMARD_32.mat 5930 30)
# add_test(NAME MATFILE_FACT_HADAMARD_GPU_FLOAT COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_float ${FAUST_DATA_MAT_DIR}/matrix_HADAMARD_32.mat ${FAUST_CONFIG_MAT_DIR}/config_HADAMARD_32.mat 5930 30)
add_test(NAME MATFILE_FACT_HIER_GPU_${TEST_FPP} COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_${TEST_FPP} ${FAUST_DATA_MAT_DIR}/matrix_hierarchical_fact.mat ${FAUST_CONFIG_MAT_DIR}/config_hierarchical_fact.mat 9401.5 0.1)
#add_test(NAME MATFILE_FACT_HIER_GPU_FLOAT COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_float ${FAUST_DATA_MAT_DIR}/matrix_hierarchical_fact.mat ${FAUST_CONFIG_MAT_DIR}/config_hierarchical_fact.mat 9401.5 0.1)
add_test(NAME MATFILE_FACT_MEG_GPU_${TEST_FPP} COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_${TEST_FPP} ${FAUST_DATA_MAT_DIR}/matrix_MEG.mat ${FAUST_CONFIG_MAT_DIR}/config_MEG.mat 22450 200)
#add_test(NAME MATFILE_FACT_MEG_GPU_DOUBLE COMMAND ${FAUST_BIN_TEST_GPU_DIR}/hierarchicalFactorization_gpu_double ${FAUST_DATA_MAT_DIR}/matrix_MEG.mat ${FAUST_CONFIG_MAT_DIR}/config_MEG.mat 22480 1)
# add_test(NAME MATFILE_MULTIPLICATION_MEG_GPU_${TEST_FPP} COMMAND ${FAUST_BIN_TEST_GPU_DIR}/Faust_multiplication_gpu_${TEST_FPP} ${FAUST_DEMO_BSL_DATA_SRC_DIR}X_meg.mat ${FAUST_DEMO_BSL_DATA_SRC_DIR}M_6.mat ${FAUST_DEMO_BSL_DATA_SRC_DIR}M_8.mat ${FAUST_DEMO_BSL_DATA_SRC_DIR}M_16.mat ${FAUST_DEMO_BSL_DATA_SRC_DIR}M_25.mat)
# add_test(NAME MATFILE_MULTIPLICATION_MEG_GPU_FLOAT COMMAND ${FAUST_BIN_TEST_GPU_DIR}/Faust_multiplication_gpu_float ${FAUST_DEMO_BSL_DATA_SRC_DIR}X_meg.mat ${FAUST_DEMO_BSL_DATA_SRC_DIR}M_6.mat ${FAUST_DEMO_BSL_DATA_SRC_DIR}M_8.mat ${FAUST_DEMO_BSL_DATA_SRC_DIR}M_16.mat ${FAUST_DEMO_BSL_DATA_SRC_DIR}M_25.mat)
set_tests_properties(MATFILE_FACT_MEG_GPU_${TEST_FPP} PROPERTIES TIMEOUT ${TIMEOUT_MEG})
endforeach()
endif(BUILD_READ_MAT_FILE AND MATIO_LIB_FILE AND MATIO_INC_DIR)
...@@ -79,11 +79,21 @@ int main(int argc, char* argv[]) ...@@ -79,11 +79,21 @@ int main(int argc, char* argv[])
string configFilename = "@FAUST_CONFIG_MAT_DIR@/config_hierarchical_fact.mat"; string configFilename = "@FAUST_CONFIG_MAT_DIR@/config_hierarchical_fact.mat";
string MatrixFilename = "@FAUST_DATA_MAT_DIR@/matrix_hierarchical_fact.mat"; string MatrixFilename = "@FAUST_DATA_MAT_DIR@/matrix_hierarchical_fact.mat";
if (argc >= 3) if (argc >= 3)
{
configFilename = argv[2]; configFilename = argv[2];
MatrixFilename = argv[1]; MatrixFilename = argv[1];
}
FPP expectedLambda = 0;
if (argc >= 4)
expectedLambda = atof(argv[3]);
FPP epsilon = 0.0001;
if (argc >= 5)
epsilon = atof(argv[4]);
size_t ind = configFilename.find_last_of("."); size_t ind = configFilename.find_last_of(".");
...@@ -117,16 +127,7 @@ int main(int argc, char* argv[]) ...@@ -117,16 +127,7 @@ int main(int argc, char* argv[])
FPP expectedLambda = 0; // useless for CPU but use for compatibility with GPU
if (argc >= 4)
expectedLambda = atof(argv[3]);
FPP epsilon = 0.0001;
if (argc >= 5)
epsilon = atof(argv[4]);
//useless for CPU but use for compatibility with GPU
Faust::BlasHandle<Cpu> blasHandle; Faust::BlasHandle<Cpu> blasHandle;
Faust::SpBlasHandle<Cpu> spblasHandle; Faust::SpBlasHandle<Cpu> spblasHandle;
......
...@@ -56,6 +56,13 @@ ...@@ -56,6 +56,13 @@
#include "faust_SpBlasHandle_gpu.h" #include "faust_SpBlasHandle_gpu.h"
#include "faust_BlasHandle_gpu.h" #include "faust_BlasHandle_gpu.h"
/** \brief An example of using the hierarchical factorization of a dense matrix using GPU process. from .mat file.
* An dense matrix is loaded from "@FAUST_DATA_MAT_DIR@
* \param MatrixFilename : a .mat (MATLAB file) where the matrix to be factorized is stored
* \param configFilename : a .mat (MATLAB file) configuration file which contains the parameter of the hierarchical algorithm (default launch with a predefined configuration called hierFact)
* \param expectedLambda (optionnal) : compared the expected scalar of the factorisation with the computed one in the precision defined with epsilon
*\param epsilon (optionnal) : precision for the test of equality (default value 0.0001)
*/
using namespace std; using namespace std;
typedef @TEST_FPP@ FPP;//faust floating point precision typedef @TEST_FPP@ FPP;//faust floating point precision
...@@ -73,10 +80,24 @@ int main(int argc, char* argv[]) ...@@ -73,10 +80,24 @@ int main(int argc, char* argv[])
} }
string configFilename = "@FAUST_DATA_MAT_DIR@/config_compared_hierarchical_fact.mat"; string configFilename = "@FAUST_CONFIG_MAT_DIR@/config_compared_hierarchical_fact.mat";
string MatrixFilename = "@FAUST_DATA_MAT_DIR@/matrix_hierarchical_fact.mat";
if (argc >= 3)
{
configFilename = argv[2];
MatrixFilename = argv[1];
}
FPP expectedLambda = 0;
if (argc >= 4)
expectedLambda = atof(argv[3]);
FPP epsilon = 0.0001;
if (argc >= 5)
epsilon = atof(argv[4]);
if (argc >= 2)
configFilename = argv[1];
size_t ind = configFilename.find_last_of("."); size_t ind = configFilename.find_last_of(".");
...@@ -110,17 +131,6 @@ int main(int argc, char* argv[]) ...@@ -110,17 +131,6 @@ int main(int argc, char* argv[])
FPP expectedLambda = 0;
if (argc >= 3)
expectedLambda = atof(argv[2]);
FPP epsilon = 0.0001;
if (argc >= 4)
epsilon = atof(argv[3]);
// initialisation CUDA environment // initialisation CUDA environment
std::cout<<"initialisation of GPU environnement"<<std::endl; std::cout<<"initialisation of GPU environnement"<<std::endl;
//cublasHandle_t cublasHandle; //cublasHandle_t cublasHandle;
...@@ -133,13 +143,21 @@ int main(int argc, char* argv[]) ...@@ -133,13 +143,21 @@ int main(int argc, char* argv[])
std::cout<<"initialisation of HierarchicalFact parameter"<<std::endl; std::cout<<"initialisation of HierarchicalFact parameter"<<std::endl;
// parameter setting
Faust::Params<FPP,Gpu> params; Faust::Params<FPP,Gpu> params;
std::cout<<"init_params"<<std::endl; std::cout<<"init_params"<<std::endl;
init_params_from_matiofile(params,configFilename.c_str(),"params"); init_params_from_matiofile(params,configFilename.c_str(),"params");
std::cout<<"Display2"<<std::endl; std::cout<<"Display2"<<std::endl;
params.Display(); params.Display();
cout<<"launch"<<endl; cout<<"launch"<<endl;
Faust::HierarchicalFact<FPP,Gpu> hierFact(params,blasHandle,spblasHandle);
// matrix to be factorized
Faust::MatDense<FPP,Gpu> matrix;
init_faust_mat_from_matio(matrix,MatrixFilename.c_str(),"matrix");
//algorithm
Faust::HierarchicalFact<FPP,Gpu> hierFact(matrix,params,blasHandle,spblasHandle);
std::cout<<"factorisation"<<std::endl; std::cout<<"factorisation"<<std::endl;
Faust::Timer_gpu t1; Faust::Timer_gpu t1;
...@@ -185,7 +203,7 @@ int main(int argc, char* argv[]) ...@@ -185,7 +203,7 @@ int main(int argc, char* argv[])
write_faust_core_into_matfile(hierFactCore,outputFilename.str().c_str(),"fact"); write_faust_core_into_matfile(hierFactCore,outputFilename.str().c_str(),"fact");
//relativeError //relativeError
Faust::MatDense<FPP,Gpu> const dataMatrix(params.data); Faust::MatDense<FPP,Gpu> const dataMatrix(matrix);
Faust::MatDense<FPP,Gpu> tmp; Faust::MatDense<FPP,Gpu> tmp;
tmp=hierFactCore.get_product(blasHandle,spblasHandle); tmp=hierFactCore.get_product(blasHandle,spblasHandle);
Faust::MatDense<FPP,Gpu> const faustProduct(tmp); Faust::MatDense<FPP,Gpu> const faustProduct(tmp);
......
...@@ -51,8 +51,9 @@ ...@@ -51,8 +51,9 @@
#include <vector> #include <vector>
using namespace std; using namespace std;
template<typename FPP,Device DEVICE> ////////////////////////////////////// modif AL
/*template<typename FPP,Device DEVICE>
void init_faust_mat_from_matio(Faust::MatDense<FPP,DEVICE>& M, const char* fileName, const char* variableName) void init_faust_mat_from_matio(Faust::MatDense<FPP,DEVICE>& M, const char* fileName, const char* variableName)
{ {
matvar_t* matvar = faust_matio_read_variable(fileName, variableName); matvar_t* matvar = faust_matio_read_variable(fileName, variableName);
...@@ -60,7 +61,52 @@ void init_faust_mat_from_matio(Faust::MatDense<FPP,DEVICE>& M, const char* fileN ...@@ -60,7 +61,52 @@ void init_faust_mat_from_matio(Faust::MatDense<FPP,DEVICE>& M, const char* fileN
init_mat_from_matvar(M, matvar); init_mat_from_matvar(M, matvar);
Mat_VarFree(matvar); Mat_VarFree(matvar);
} }
*/
template<typename FPP,Device DEVICE>
void init_faust_mat_from_matio(Faust::MatDense<FPP,DEVICE>& M, const char* fileName, const char* variableName)
{
int nbr_params;
// Dans le cas de GPU, on passe par une matrice dense CPU pour loader une matrice dense GPU car on ne peut pas acceder au data par GPU, (seulement 1er valeur).
Faust::MatDense<FPP,Cpu> data_mat;
matvar_t* matvar = faust_matio_read_variable(fileName, variableName);
init_mat_from_matvar(data_mat, matvar);
data_mat.check_dim_validity();
M=data_mat;
/*
if (data_mat == NULL)
{
cerr<<"error cannot access to the field : "<<variableName<<endl;
exit(EXIT_FAILURE);
}
nbr_params = Mat_VarGetNumberOfFields(matvar);
char*const* fieldNames;
fieldNames = Mat_VarGetStructFieldnames(matvar);
matvar_t* current_var;
current_var=Mat_VarGetStructFieldByName(matvar,variableName,0);
if (current_var == NULL)
{
cerr<<"error cannot access to the field : "<<variableName<<endl;
exit(EXIT_FAILURE);
}
init_mat_from_matvar(data_mat, current_var);
//data_mat.Display();
Mat_VarFree(matvar);
Mat_VarFree(current_var);
*/
}
////////////////////////////////////// modif AL
template<typename FPP,Device DEVICE> template<typename FPP,Device DEVICE>
void init_faust_spmat_from_matio(Faust::MatSparse<FPP,DEVICE>& S, const char* fileName, const char* variableName) void init_faust_spmat_from_matio(Faust::MatSparse<FPP,DEVICE>& S, const char* fileName, const char* variableName)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment