Changeset 12431
- Timestamp:
- 06/15/12 16:30:09 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/toolkits
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/toolkits/petsc/patches/GetOwnershipBoundariesFromRange.cpp
r9320 r12431 28 28 29 29 /*Gather all range values into allranges, for all nodes*/ 30 allranges= (int*)xmalloc(num_procs*sizeof(int));30 allranges=xNew<int>(num_procs); 31 31 MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,MPI_COMM_WORLD); 32 32 … … 42 42 *plower_row=lower_row; 43 43 *pupper_row=upper_row; 44 45 /*Free ressources:*/ 46 xfree((void**)&allranges); 47 44 xDelete<int>(allranges); 48 45 } -
issm/trunk-jpl/src/c/toolkits/petsc/patches/MatMultPatch.cpp
r9826 r12431 64 64 } 65 65 else{ 66 result=1; \66 result=1; 67 67 } 68 68 return result; … … 89 89 range=upper_row-lower_row+1; 90 90 if (range){ 91 index= (int*)xmalloc(range*sizeof(int));92 values= (double*)xmalloc(range*sizeof(double));91 index=xNew<int>(range); 92 values=xNew<double>(range); 93 93 for (int i=0;i<range;i++){ 94 94 *(index+i)=lower_row+i; … … 103 103 104 104 /*Free ressources:*/ 105 x free((void**)&index);106 x free((void**)&values);105 xDelete<int>(index); 106 xDelete<double>(values); 107 107 108 108 /*Assign output pointers:*/ -
issm/trunk-jpl/src/c/toolkits/petsc/patches/MatPartition.cpp
r11911 r12431 77 77 count=0; 78 78 if (range){ 79 node_rows= (int*)xmalloc(range*sizeof(int)); //this is the maximum number of rows one node can extract.79 node_rows=xNew<int>(range); //this is the maximum number of rows one node can extract. 80 80 81 81 for (i=0;i<row_partition_vector_size;i++){ … … 98 98 99 99 /*Same deal for columns*/ 100 node_cols= (int*)xmalloc(col_partition_vector_size*sizeof(int));100 node_cols=xNew<int>(col_partition_vector_size); 101 101 for (i=0;i<col_partition_vector_size;i++){ 102 102 *(node_cols+i)=(int)*(col_partition_vector+i)-1; … … 128 128 129 129 /*Free ressources:*/ 130 x free((void**)&node_rows);131 x free((void**)&node_cols);130 xDelete<int>(node_rows); 131 xDelete<int>(node_cols); 132 132 ISFree(&col_index); 133 133 ISFree(&row_index); -
issm/trunk-jpl/src/c/toolkits/petsc/patches/MatToSerial.cpp
r11695 r12431 32 32 double* outmatrix=NULL; 33 33 34 35 34 /*get matrix size: */ 36 35 MatGetSize(matrix,&M,&N); … … 42 41 43 42 /*Local and global allocation*/ 44 if (my_rank==0)outmatrix= (double*)xmalloc(M*N*sizeof(double));43 if (my_rank==0)outmatrix=xNew<double>(M*N); 45 44 46 45 if (range){ 47 local_matrix= (double*)xmalloc(N*range*sizeof(double));48 idxm= (int*)xmalloc(range*sizeof(int));49 idxn= (int*)xmalloc(N*sizeof(int));46 local_matrix=xNew<double>(N*range); 47 idxm=xNew<int>(range); 48 idxn=xNew<int>(N); 50 49 51 50 for (i=0;i<N;i++){ … … 78 77 //Still have the local_matrix on node 0 to take care of. 79 78 memcpy(outmatrix,local_matrix,N*range*sizeof(double)); 80 81 79 } 82 80 83 81 /*Assign output pointer: */ 84 82 *poutmatrix=outmatrix; 85 86 xfree((void**)&idxm); 87 xfree((void**)&idxn); 88 xfree((void**)&local_matrix); 89 83 xDelete<int>(idxm); 84 xDelete<int>(idxn); 85 xDelete<double>(local_matrix); 90 86 } -
issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscMatrixToDoubleMatrix.cpp
r12102 r12431 36 36 MatGetSize(petsc_matrix,&rows,&cols); 37 37 38 idxm= (int*)xmalloc(rows*sizeof(int));39 idxn= (int*)xmalloc(cols*sizeof(int));38 idxm=xNew<int>(rows); 39 idxn=xNew<int>(cols); 40 40 41 41 for(i=0;i<rows;i++)idxm[i]=i; 42 42 for(i=0;i<cols;i++)idxn[i]=i; 43 43 44 matrix= (double*)xmalloc(rows*cols*sizeof(double));44 matrix=xNew<double>(rows*cols); 45 45 MatGetValues(petsc_matrix,rows,idxm,cols,idxn,matrix); 46 47 xDelete<int>(idxm); 48 xDelete<int>(idxn); 46 49 47 50 /*Assign output pointers: */ -
issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscVectorToDoubleVector.cpp
r12102 r12431 28 28 VecGetSize(petsc_vector,&rows); 29 29 if(rows){ 30 idxm= (int*)xmalloc(rows*sizeof(int));31 vector= (double*)xmalloc(rows*sizeof(double));30 idxm=xNew<int>(rows); 31 vector=xNew<double>(rows); 32 32 for(i=0;i<rows;i++)idxm[i]=i; 33 34 33 VecGetValues(petsc_vector,rows,idxm,vector); 34 xDelete<int>(idxm); 35 35 } 36 36 } -
issm/trunk-jpl/src/c/toolkits/petsc/patches/SerialToVec.cpp
r11843 r12431 38 38 39 39 if (range){ 40 idxn= (int*)xmalloc(range*sizeof(int));41 values= (double*)xmalloc(range*sizeof(double));40 idxn=xNew<int>(range); 41 values=xNew<double>(range); 42 42 for (i=0;i<range;i++){ 43 43 idxn[i]=lower_row+i; … … 54 54 55 55 /*Free ressources:*/ 56 x free((void**)&idxn);57 x free((void**)&values);56 xDelete<int>(idxn); 57 xDelete<double>(values); 58 58 59 59 return outvector; -
issm/trunk-jpl/src/c/toolkits/petsc/patches/VecMerge.cpp
r9320 r12431 45 45 if (range){ 46 46 /*This node owns rows of vector B, get them*/ 47 idxm= (int*)xmalloc(range*sizeof(int));48 values= (double*)xmalloc(range*sizeof(double));47 idxm=xNew<int>(range); 48 values=xNew<double>(range); 49 49 for (i=0;i<range;i++){ 50 50 *(idxm+i)=lower_row+i; … … 63 63 64 64 /*Free ressources:*/ 65 xfree((void**)&idxm); 66 xfree((void**)&values); 67 65 xDelete<int>(idxm); 66 xDelete<double>(values); 68 67 } -
issm/trunk-jpl/src/c/toolkits/petsc/patches/VecPartition.cpp
r9320 r12431 56 56 57 57 if (range){ 58 node_rows= (int*)xmalloc(range*sizeof(int)); //this is the maximum number of rows one node can extract.58 node_rows=xNew<int>(range); //this is the maximum number of rows one node can extract. 59 59 60 60 count=0; … … 71 71 72 72 if (count){ 73 values= (double*)xmalloc(count*sizeof(double)); //holder for the values to be extracted from vectorA73 values=xNew<double>(count); //holder for the values to be extracted from vectorA 74 74 } 75 75 else{ 76 x free((void**)&node_rows); //count=0 means no values was condensed out for this node. null node_rows for use in VecGetValues.76 xDelete<int>(node_rows); //count=0 means no values was condensed out for this node. null node_rows for use in VecGetValues. 77 77 values=NULL; 78 78 } … … 110 110 VecAssemblyBegin(outvector); 111 111 VecAssemblyEnd(outvector); 112 113 112 } 114 113 115 114 /*Assign output pointers:*/ 116 115 *poutvector=outvector; 117 118 /*Free ressources:*/ 119 xfree((void**)&node_rows); 120 xfree((void**)&values); 121 116 xDelete<int>(node_rows); 117 xDelete<double>(values); 122 118 } -
issm/trunk-jpl/src/c/toolkits/petsc/patches/VecToMPISerial.cpp
r11695 r12431 42 42 43 43 /*Allocate gathered vector on all nodes .*/ 44 gathered_vector= (double*)xmalloc(vector_size*sizeof(double));44 gathered_vector=xNew<double>(vector_size); 45 45 46 46 /*Allocate local vectors*/ … … 50 50 51 51 if (range){ 52 idxn= (int*)xmalloc(range*sizeof(int));52 idxn=xNew<int>(range); 53 53 for (i=0;i<range;i++){ 54 54 *(idxn+i)=lower_row+i; 55 55 } 56 local_vector= (double*)xmalloc(range*sizeof(double));56 local_vector=xNew<double>(range); 57 57 /*Extract values from MPI vector to serial local_vector on each node*/ 58 58 VecGetValues(vector,range,idxn,local_vector); … … 87 87 88 88 /*free ressources: */ 89 x free((void**)&idxn);90 x free((void**)&local_vector);89 xDelete<int>(idxn); 90 xDelete<double>(local_vector); 91 91 92 92 return 1; -
issm/trunk-jpl/src/c/toolkits/petsc/patches/VecTranspose.cpp
r1 r12431 33 33 34 34 if (range){ 35 idxm= (int*)xmalloc(range*sizeof(int));36 tidxm= (int*)xmalloc(range*sizeof(int));35 idxm=xNew<int>(range); 36 tidxm=xNew<int>(range); 37 37 for (i=0;i<range;i++){ 38 38 *(idxm+i)=lower_row+i; 39 39 } 40 values= (double*)xmalloc(range*sizeof(double));41 tvalues= (double*)xmalloc(range*sizeof(double));40 values=xNew<double>(range); 41 tvalues=xNew<double>(range); 42 42 43 43 VecGetValues(vector,range,idxm,values); … … 56 56 57 57 /*Free ressources: */ 58 x free((void**)&idxm);59 x free((void**)&values);60 x free((void**)&tidxm);61 x free((void**)&tvalues);58 xDelete<int>(idxm); 59 xDelete<double>(values); 60 xDelete<int>(tidxm); 61 xDelete<double>(tvalues); 62 62 63 63 /*Assign output pointers: */ -
issm/trunk-jpl/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp
r3595 r12431 44 44 int i; 45 45 46 decomp=x malloc(input*sizeof(int));46 decomp=xNew<int>(input); 47 47 *decomp=input; 48 48 for (i=0;i<input;i++){ … … 57 57 } 58 58 } 59 60 59 *pdecomp=decomp; 61 60 } -
issm/trunk-jpl/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp
r6412 r12431 13 13 #include "../../scalapack/FortranMapping.h" 14 14 15 void PlapackInvertMatrixLocalCleanup(PLA_Obj* pa,PLA_Template* ptempl,double** parrayA, 16 int** pidxnA,MPI_Comm* pcomm_2d); 15 void PlapackInvertMatrixLocalCleanup(PLA_Obj* pa,PLA_Template* ptempl,double** parrayA,int** pidxnA,MPI_Comm* pcomm_2d); 17 16 18 17 int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con){ 19 /*inv_A does not yet exist, inv_A was just xmalloced, that's all*/18 /*inv_A does not yet exist, inv_A was just allocated, that's all*/ 20 19 21 20 /*Error management*/ 22 21 int i,j; 23 24 22 25 23 /*input*/ … … 94 92 /* Set the datatype */ 95 93 datatype = MPI_DOUBLE; 96 97 94 98 95 /* Copy A into a*/ … … 104 101 upper_row--; 105 102 range=upper_row-lower_row+1; 106 arrayA =xmalloc(nA*sizeof(double));107 idxnA =xmalloc(nA*sizeof(int));103 arrayA = xNew<double>(nA); 104 idxnA = xNew<int>(nA); 108 105 for (i=0;i<nA;i++){ 109 106 *(idxnA+i)=i; … … 128 125 PLA_Obj_free(&a); 129 126 PLA_Temp_free(&templ); 130 x free((void**)&arrayA);131 x free((void**)&idxnA);127 xDelete<double>(arrayA); 128 xDelete<int>(idxnA); 132 129 133 130 /*Finalize PLAPACK*/ 134 131 PLA_Finalize(); 135 132 MPI_Comm_free(&comm_2d); 136 137 133 } -
issm/trunk-jpl/src/c/toolkits/plapack/patches/PlapackToPetsc.cpp
r3332 r12431 45 45 46 46 /*Vector physically based block cyclic distribution: */ 47 row_nodes=x malloc(mA*sizeof(int));48 col_nodes=x malloc(nA*sizeof(int));47 row_nodes=xNew<int>(mA); 48 col_nodes=xNew<int>(nA); 49 49 for (i=0;i<mA;i++){ 50 50 i0=i/nb; … … 60 60 PLA_Temp_comm_col_rank(templ,&myrow); 61 61 62 idxm=x malloc(mA*sizeof(int));62 idxm=xNew<int>(mA); 63 63 count=0; 64 64 for (i=0;i<mA;i++){ … … 70 70 idxm_count=count; 71 71 72 idxn=x malloc(nA*sizeof(int));72 idxn=xNew<int>(nA); 73 73 count=0; 74 74 for (i=0;i<nA;i++){ … … 92 92 93 93 /*Free ressources:*/ 94 x free((void**)&row_nodes);95 x free((void**)&col_nodes);96 x free((void**)&idxm);97 x free((void**)&idxn);94 xDelete<int>(row_nodes); 95 xDelete<int>(col_nodes); 96 xDelete<int>(idxm); 97 xDelete<int>(idxn); 98 98 }
Note:
See TracChangeset
for help on using the changeset viewer.