--- trunk/paso/src/SystemMatrixPattern_unrollBlocks.c 2007/03/14 00:15:24 1028 +++ trunk/paso/src/SystemMatrixPattern_unrollBlocks.c 2007/09/24 06:18:44 1312 @@ -1,101 +1,68 @@ + /* $Id$ */ -/* -******************************************************************************** -* Copyright 2006 by ACcESS MNRF * -* * -* http://www.access.edu.au * -* Primary Business: Queensland, Australia * -* Licensed under the Open Software License version 3.0 * -* http://www.opensource.org/licenses/osl-3.0.php * -******************************************************************************** -*/ +/******************************************************* + * + * Copyright 2003-2007 by ACceSS MNRF + * Copyright 2007 by University of Queensland + * + * http://esscc.uq.edu.au + * Primary Business: Queensland, Australia + * Licensed under the Open Software License version 3.0 + * http://www.opensource.org/licenses/osl-3.0.php + * + *******************************************************/ /**************************************************************/ -/* Paso: SystemMatrixPatternPattern */ +/* Paso: SystemMatrixPattern_unrollBlocks */ /**************************************************************/ -/* Copyrights by ACcESS Australia 2003, 2004, 2005 */ /* Author: gross@access.edu.au */ /**************************************************************/ -#include "Paso.h" #include "SystemMatrixPattern.h" /**************************************************************/ /* creates SystemMatrixPattern */ -Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_unrollBlocks(Paso_SystemMatrixPattern* pattern, \ - int type, dim_t row_block_size,dim_t col_block_size) { +Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_unrollBlocks(Paso_SystemMatrixPattern* pattern, + int type, dim_t output_block_size,dim_t input_block_size) { Paso_SystemMatrixPattern*out=NULL; - index_t *ptr=NULL,*index=NULL,iPtr; - dim_t i,j,k,l, block_size, new_n_ptr, new_len; - index_t index_offset_in=(pattern->type & PATTERN_FORMAT_OFFSET1 ? 1:0); - index_t index_offset_out=(type & PATTERN_FORMAT_OFFSET1 ? 1:0); - - if ((pattern->type & PATTERN_FORMAT_SYM) != (type & PATTERN_FORMAT_SYM)) { - Paso_setError(TYPE_ERROR,"Paso_SystemMatrixPattern_unrollBlocks: conversion between symmetric and non-symmetric is not implemented yet"); - return NULL; + Paso_Pattern *new_mainPattern=NULL, *new_couplePattern=NULL; + Paso_Distribution* new_output_distribution=NULL, *new_input_distribution=NULL; + Paso_Coupler *new_coupler=NULL; + + new_mainPattern=Paso_Pattern_unrollBlocks(pattern->mainPattern,type,output_block_size,input_block_size); + new_couplePattern=Paso_Pattern_unrollBlocks(pattern->couplePattern,type,output_block_size,input_block_size); + new_output_distribution=Paso_Distribution_alloc(pattern->output_distribution->mpi_info, + pattern->output_distribution->first_component, + output_block_size,0); + new_input_distribution=Paso_Distribution_alloc(pattern->input_distribution->mpi_info, + pattern->input_distribution->first_component, + input_block_size,0); + new_coupler=Paso_Coupler_unroll(pattern->coupler,input_block_size); + if (Paso_noError()) { + out=Paso_SystemMatrixPattern_alloc(type, + new_output_distribution, + new_input_distribution, + new_mainPattern, + new_couplePattern, + new_coupler); } - Paso_resetError(); - block_size=row_block_size*col_block_size; - new_n_ptr=(pattern->n_ptr)*row_block_size; - new_len=(pattern->len)*block_size; - - ptr=MEMALLOC(new_n_ptr+1,index_t); - index=MEMALLOC(new_len,index_t); - - - if (! ( Paso_checkPtr(ptr) || Paso_checkPtr(index) ) ) { - #pragma omp parallel - { - #pragma omp for private(i) schedule(static) - for (i=0;in_ptr;++i) - for (k=0;kptr[i]-index_offset_in)*block_size+(pattern->ptr[i+1]-pattern->ptr[i])*col_block_size*k+index_offset_out; - - #pragma omp for private(i,iPtr) schedule(static) - for (i=0;in_ptr;++i) { - for (iPtr=pattern->ptr[i]-index_offset_in;iPtrptr[i+1]-index_offset_in;++iPtr) { - for (k=0;kptr[i]-index_offset_in))*col_block_size+j]=(pattern->index[iPtr]-index_offset_in)*col_block_size+j+index_offset_out; - } - } - } - } - } - /* create return value */ - out=Paso_SystemMatrixPattern_alloc(type,new_n_ptr,ptr,index); - } - if (! Paso_noError()) { - MEMFREE(index); - MEMFREE(ptr); + Paso_Pattern_free(new_mainPattern); + Paso_Pattern_free(new_couplePattern); + Paso_Distribution_free(new_output_distribution); + Paso_Distribution_free(new_input_distribution); + Paso_Coupler_free(new_coupler); + + if (Paso_noError()) { + return out; + } else { + Paso_SystemMatrixPattern_free(out); + return NULL; } - return out; } -/* - * $Log$ - * Revision 1.2 2005/09/15 03:44:39 jgs - * Merge of development branch dev-02 back to main trunk on 2005-09-15 - * - * Revision 1.1.2.1 2005/09/05 06:29:47 gross - * These files have been extracted from finley to define a stand alone libray for iterative - * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but - * has not been tested yet. - * - * - */