/*Copyright (c) 2011, Edgar Solomonik, all rights reserved.*/ /** \addtogroup examples * @{ * \defgroup slice_gemm * @{ * \brief Randomly permuted block write of symmetric matrices from matrix on COMM_SELF to symmetric matrix on COMM_WORLD */ #include #include #include #include #include #include #include #include #include #ifndef MIN #define MIN( a, b ) ( ((a) < (b)) ? (a) : (b) ) #endif /** * \brief tests sparse remote global write via permute function * \param[in] n dimension of global matrix * \param[in] b rough dimension of sparse blocks to write from each processor * \param[in] sym symmetry of the global matrix (and of each block) * \parma[in] dw world/communicator on which to define the global matrix */ int sparse_permuted_slice(int n, int b, int sym, CTF_World & dw){ int np, rank, pass, bi; long_int i, j, nvals; long_int * indices; double * data; int * perm; int ** perms; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &np); perms = (int**)malloc(sizeof(int*)*2); srand(rank*13+7); //make each block have somewhat different size bi = b + (rand()%b); perm = (int*)malloc(sizeof(int)*bi); perms[0] = perm; perms[1] = perm; //each block is random permuted symmetric submatrix for (i=0; i