/[escript]/trunk/paso/src/SystemMatrixPattern_unrollBlocks.c
ViewVC logotype

Diff of /trunk/paso/src/SystemMatrixPattern_unrollBlocks.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/paso/src/SystemMatrixPattern_unrollBlocks.c revision 432 by gross, Fri Jan 13 07:38:54 2006 UTC temp_trunk_copy/paso/src/SystemMatrixPattern_unrollBlocks.c revision 1384 by phornby, Fri Jan 11 02:29:38 2008 UTC
# Line 1  Line 1 
1    
2  /* $Id$ */  /* $Id$ */
3    
4    /*******************************************************
5     *
6     *           Copyright 2003-2007 by ACceSS MNRF
7     *       Copyright 2007 by University of Queensland
8     *
9     *                http://esscc.uq.edu.au
10     *        Primary Business: Queensland, Australia
11     *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16  /**************************************************************/  /**************************************************************/
17    
18  /* Paso: SystemMatrixPatternPattern */  /* Paso: SystemMatrixPattern_unrollBlocks */
19    
20  /**************************************************************/  /**************************************************************/
21    
 /* Copyrights by ACcESS Australia 2003, 2004, 2005 */  
22  /* Author: gross@access.edu.au */  /* Author: gross@access.edu.au */
23    
24  /**************************************************************/  /**************************************************************/
25    
 #include "Paso.h"  
26  #include "SystemMatrixPattern.h"  #include "SystemMatrixPattern.h"
27    
28  /**************************************************************/  /**************************************************************/
29    
30  /* creates SystemMatrixPattern  */  /* creates SystemMatrixPattern  */
31    
32  Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_unrollBlocks(Paso_SystemMatrixPattern* pattern, \  Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_unrollBlocks(Paso_SystemMatrixPattern* pattern,
33                                             int type, dim_t row_block_size,dim_t col_block_size) {                                             int type, dim_t output_block_size,dim_t input_block_size) {
   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;  
   }  
34    Paso_SystemMatrixPattern*out=NULL;    Paso_SystemMatrixPattern*out=NULL;
35    index_t *ptr=NULL,*index=NULL,iPtr;    Paso_Pattern *new_mainPattern=NULL, *new_couplePattern=NULL;
36    dim_t i,j,k,l;    Paso_Distribution* new_output_distribution=NULL, *new_input_distribution=NULL;
37    Paso_resetError();    Paso_Coupler *new_coupler=NULL;
38    dim_t block_size=row_block_size*col_block_size;  
39    dim_t new_n_ptr=(pattern->n_ptr)*row_block_size;    new_mainPattern=Paso_Pattern_unrollBlocks(pattern->mainPattern,type,output_block_size,input_block_size);
40    dim_t new_len=(pattern->len)*block_size;    new_couplePattern=Paso_Pattern_unrollBlocks(pattern->couplePattern,type,output_block_size,input_block_size);
41      new_output_distribution=Paso_Distribution_alloc(pattern->output_distribution->mpi_info,
42    ptr=MEMALLOC(new_n_ptr+1,index_t);                                                    pattern->output_distribution->first_component,
43    index=MEMALLOC(new_len,index_t);                                                    output_block_size,0);
44      new_input_distribution=Paso_Distribution_alloc(pattern->input_distribution->mpi_info,
45                                                      pattern->input_distribution->first_component,
46    if (! ( Paso_checkPtr(ptr) || Paso_checkPtr(index) ) )  {                                                    input_block_size,0);
47       #pragma omp parallel    new_coupler=Paso_Coupler_unroll(pattern->coupler,input_block_size);
48       {    if (Paso_noError()) {
49          #pragma omp for private(i) schedule(static)       out=Paso_SystemMatrixPattern_alloc(type,
50          for (i=0;i<new_n_ptr+1;++i) ptr[i]=index_offset_out;                                          new_output_distribution,
51                                            new_input_distribution,
52          #pragma omp master                                          new_mainPattern,
53          ptr[new_n_ptr]=new_len+index_offset_out;                                          new_couplePattern,
54                                            new_coupler);
55          #pragma omp for private(i,k) schedule(static)    }
56          for (i=0;i<pattern->n_ptr;++i)    Paso_Pattern_free(new_mainPattern);
57              for (k=0;k<row_block_size;++k) ptr[i*row_block_size+k]=(pattern->ptr[i]-index_offset_in)*block_size+(pattern->ptr[i+1]-pattern->ptr[i])*col_block_size*k+index_offset_out;    Paso_Pattern_free(new_couplePattern);
58                Paso_Distribution_free(new_output_distribution);
59          #pragma omp for private(i,iPtr) schedule(static)    Paso_Distribution_free(new_input_distribution);
60          for (i=0;i<new_n_ptr;++i)    Paso_Coupler_free(new_coupler);
61              for (iPtr=ptr[i]-index_offset_out;iPtr<ptr[i+1]-index_offset_out;++iPtr) index[iPtr]=index_offset_out;  
62      if (Paso_noError()) {
63          #pragma omp for private(i,j,iPtr,k) schedule(static)       return out;
64          for (i=0;i<pattern->n_ptr;++i) {    } else {
65             for (iPtr=pattern->ptr[i]-index_offset_in;iPtr<pattern->ptr[i+1]-index_offset_in;++iPtr)  {       Paso_SystemMatrixPattern_free(out);
66                for (k=0;k<row_block_size;++k) {       return NULL;
                  for (j=0;j<col_block_size;++j) {  
                     index[ptr[i*row_block_size+k]-index_offset_out+(iPtr-(pattern->ptr[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);  
67    }    }
   return out;  
68  }  }
 /*  
  * $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.  
  *  
  *  
  */  

Legend:
Removed from v.432  
changed lines
  Added in v.1384

  ViewVC Help
Powered by ViewVC 1.1.26