J'utilise le Eigen library version 3.3 avec g ++ 5.4 et CUDA 8.0 dans Ubuntu 16.04 LTS.NVCC compile la bibliothèque Eigen et le redimensionnement de MatrixXd dans la structure à l'exécution échoue
Des choses confuses se sont produites lors de l'écriture du code. Un blocage se produit lorsque j'essaie de redimensionner Eigen :: MatrixXd dans une structure
la structure est la suivante.
struct cudaCopy{
struct s_path_info *nodes_parents
struct s_path_info *nodes_children
...
}
La structure s_path_info est la suivante.
struct s_path_info{
Eigen::MatrixXd supps;
Eigen::MatrixXd residu;
...
Les problèmes sont les suivants.
struct cudaCopy *mem;
mem = (struct cudaCopy*)malloc(sizeof(struct cudaCopy));
et
mem->nodes_parents = (struct s_path_info*)malloc(50 * sizeof(struct s_path_info))
for(int i=0; i<50; i++){
mem->nodes_parents[i].supps.resize(1, 1); // ERROR
Voici le backtrace que GDB exécuter le code.
#0 __GI___libc_free (mem=0x1) at malloc.c:2949 #1 0x000000000040a538 in Eigen::internal::aligned_free (ptr=0x1) at ../Eigen/Eigen/src/Core/util/Memory.h:177 #2 0x000000000040f3e8 in Eigen::internal::conditional_aligned_free<true> (ptr=0x1) at ../Eigen/Eigen/src/Core/util/Memory.h:230 #3 0x000000000040cdd4 in Eigen::internal::conditional_aligned_delete_auto<double, true> (ptr=0x1, size=7209728) at ../Eigen/Eigen/src/Core/util/Memory.h:416 #4 0x000000000040d085 in Eigen::DenseStorage<double, -1, -1, -1, 0>::resize (this=0x6e1348, size=20, rows=20, cols=1) at ../Eigen/Eigen/src/Core/DenseStorage.h:406 #5 0x000000000040ba9e in Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::resize (this=0x6e1348, rows=20, cols=1) at ../Eigen/Eigen/src/Core/PlainObjectBase.h:293 #6 0x000000000040697f in search::islsp_EstMMP_BF_reuse (this=0x7fffffffe4b0) at exam.cu:870 #7 0x0000000000404f33 in main() at exam.cu:422
Fait intéressant, les travaux suivants ainsi.
mem->nodes_children = (struct s_path_info*)malloc(10*50*sizeof(struct s_path_info))
for(int i=0; i<10*50; i++){
mem->nodes_children[i].supps.resize(1, 1); // OK
Je n'arrive pas à comprendre pourquoi les fichiers_parents ne peuvent pas être redimensionnés.
J'apprécierais tous les commentaires à ce sujet. Je vous remercie.
Bienvenue dans Stack Overflow. Veuillez prendre le temps de lire [The Tour] (http://stackoverflow.com/tour) et de consulter le contenu du [Centre d'aide] (http://stackoverflow.com/help/asking) quoi et comment vous pouvez demandez ici. –