/[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

revision 414 by jgs, Wed Nov 9 02:02:19 2005 UTC revision 415 by gross, Wed Jan 4 05:37:33 2006 UTC
# Line 19  Line 19 
19  /* creates SystemMatrixPattern  */  /* creates SystemMatrixPattern  */
20    
21  Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_unrollBlocks(Paso_SystemMatrixPattern* pattern, \  Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_unrollBlocks(Paso_SystemMatrixPattern* pattern, \
22                                             dim_t row_block_size,dim_t col_block_size) {                                             int type, dim_t row_block_size,dim_t col_block_size) {
23      index_t index_offset_in=(pattern->type & PATTERN_FORMAT_OFFSET1 ? 1:0);
24      index_t index_offset_out=(type & PATTERN_FORMAT_OFFSET1 ? 1:0);
25      
26      if ((pattern->type & PATTERN_FORMAT_SYM) != (type & PATTERN_FORMAT_SYM)) {
27          Paso_setError(TYPE_ERROR,"Paso_SystemMatrixPattern_unrollBlocks: conversion between symmetric and non-symmetric is not implemented yet");
28          return NULL;
29      }
30    Paso_SystemMatrixPattern*out=NULL;    Paso_SystemMatrixPattern*out=NULL;
31    index_t *ptr=NULL,*index=NULL,iPtr;    index_t *ptr=NULL,*index=NULL,iPtr;
32    dim_t i,j,k,l;    dim_t i,j,k,l;
# Line 36  Paso_SystemMatrixPattern* Paso_SystemMat Line 43  Paso_SystemMatrixPattern* Paso_SystemMat
43       #pragma omp parallel       #pragma omp parallel
44       {       {
45          #pragma omp for private(i) schedule(static)          #pragma omp for private(i) schedule(static)
46          for (i=0;i<new_n_ptr+1;++i) ptr[i]=0;          for (i=0;i<new_n_ptr+1;++i) ptr[i]=index_offset_out;
47    
48          #pragma omp master          #pragma omp master
49          ptr[new_n_ptr]=new_len;          ptr[new_n_ptr]=new_len+index_offset_out;
50    
51          #pragma omp for private(i,k) schedule(static)          #pragma omp for private(i,k) schedule(static)
52          for (i=0;i<pattern->n_ptr;++i)          for (i=0;i<pattern->n_ptr;++i)
53              for (k=0;k<row_block_size;++k) ptr[i*row_block_size+k]=(pattern->ptr[i]-PTR_OFFSET)*block_size+(pattern->ptr[i+1]-pattern->ptr[i])*col_block_size*k;              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;
54                        
55          #pragma omp for private(i,iPtr) schedule(static)          #pragma omp for private(i,iPtr) schedule(static)
56          for (i=0;i<new_n_ptr;++i)          for (i=0;i<new_n_ptr;++i)
57              for (iPtr=ptr[i];iPtr<ptr[i+1];++iPtr) index[iPtr]=0;              for (iPtr=ptr[i];iPtr<ptr[i+1];++iPtr) index[iPtr]=index_offset_out;
58    
59          #pragma omp for private(i,j,iPtr,k) schedule(static)          #pragma omp for private(i,j,iPtr,k) schedule(static)
60          for (i=0;i<pattern->n_ptr;++i) {          for (i=0;i<pattern->n_ptr;++i) {
61             for (iPtr=pattern->ptr[i];iPtr<pattern->ptr[i+1];++iPtr)  {             for (iPtr=pattern->ptr[i]-index_offset_in;iPtr<pattern->ptr[i+1]-index_offset_in;++iPtr)  {
62                for (k=0;k<row_block_size;++k) {                for (k=0;k<row_block_size;++k) {
63                   for (j=0;j<col_block_size;++j) {                   for (j=0;j<col_block_size;++j) {
64                      index[ptr[i*row_block_size+k]+(iPtr-pattern->ptr[i])*col_block_size+j]=(pattern->index[iPtr]-INDEX_OFFSET)*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;
65                   }                   }
66                }                }
67             }             }
68          }          }
69       }       }
70       /* create return value */       /* create return value */
71       out=Paso_SystemMatrixPattern_alloc(new_n_ptr,ptr,index);       out=Paso_SystemMatrixPattern_alloc(type,new_n_ptr,ptr,index);
72    }      }  
73    if (! Paso_noError()) {    if (! Paso_noError()) {
74       MEMFREE(index);       MEMFREE(index);

Legend:
Removed from v.414  
changed lines
  Added in v.415

  ViewVC Help
Powered by ViewVC 1.1.26