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

Contents of /trunk-mpi-branch/paso/src/SystemMatrixPattern_unrollBlocks.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1016 - (show annotations)
Thu Mar 8 06:31:28 2007 UTC (12 years, 5 months ago) by gross
File MIME type: text/plain
File size: 4290 byte(s)
MPI version compiles and starts to run now. 
Important:

   * the mpi library needs to be shared.
   * the path needs to be added to LD_LIBRARY path.

The program stucks in the matrix assemblage.


1 /* $Id$ */
2
3 /*
4 ********************************************************************************
5 * Copyright 2006 by ACcESS MNRF *
6 * *
7 * http://www.access.edu.au *
8 * Primary Business: Queensland, Australia *
9 * Licensed under the Open Software License version 3.0 *
10 * http://www.opensource.org/licenses/osl-3.0.php *
11 ********************************************************************************
12 */
13
14 /**************************************************************/
15
16 /* Paso: SystemMatrixPatternPattern */
17
18 /**************************************************************/
19
20 /* Copyrights by ACcESS Australia 2003, 2004, 2005 */
21 /* Author: gross@access.edu.au */
22
23 /**************************************************************/
24
25 #include "Paso.h"
26 #include "SystemMatrixPattern.h"
27
28 /**************************************************************/
29
30 /* creates SystemMatrixPattern */
31
32 Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_unrollBlocks(Paso_SystemMatrixPattern* pattern, \
33 int type, dim_t output_block_size,dim_t input_block_size) {
34 index_t index_offset_in=(pattern->type & PATTERN_FORMAT_OFFSET1 ? 1:0);
35 index_t index_offset_out=(type & PATTERN_FORMAT_OFFSET1 ? 1:0);
36
37 if ((pattern->type & PATTERN_FORMAT_SYM) != (type & PATTERN_FORMAT_SYM)) {
38 Paso_setError(TYPE_ERROR,"Paso_SystemMatrixPattern_unrollBlocks: conversion between symmetric and non-symmetric is not implemented yet");
39 return NULL;
40 }
41 Paso_MPIInfo* mpi_info=pattern->mpi_info;
42 Paso_SystemMatrixPattern*out=NULL;
43 Paso_Distribution *input_dist=NULL,*output_dist=NULL;
44 index_t *ptr=NULL,*index=NULL,iPtr;
45 dim_t i,j,k,l;
46 Paso_resetError();
47 dim_t block_size=output_block_size*input_block_size;
48 dim_t new_myNumOutput=(pattern->myNumOutput)*output_block_size;
49 dim_t new_myLen=(pattern->myLen)*block_size;
50
51 ptr=MEMALLOC(new_myNumOutput+1,index_t);
52 index=MEMALLOC(new_myLen,index_t);
53 if (! ( Paso_checkPtr(ptr) || Paso_checkPtr(index) ) ) {
54 #pragma omp parallel
55 {
56 #pragma omp for private(i) schedule(static)
57 for (i=0;i<new_myNumOutput+1;++i) ptr[i]=index_offset_out;
58
59 #pragma omp master
60 ptr[new_myNumOutput]=new_myLen+index_offset_out;
61
62 #pragma omp for private(i,k) schedule(static)
63 for (i=0;i<pattern->myNumOutput;++i)
64 for (k=0;k<output_block_size;++k) ptr[i*output_block_size+k]=(pattern->ptr[i]-index_offset_in)*block_size+(pattern->ptr[i+1]-pattern->ptr[i])*input_block_size*k+index_offset_out;
65
66 #pragma omp for private(i,iPtr) schedule(static)
67 for (i=0;i<new_myNumOutput;++i)
68 for (iPtr=ptr[i]-index_offset_out;iPtr<ptr[i+1]-index_offset_out;++iPtr) index[iPtr]=index_offset_out;
69
70 #pragma omp for private(i,j,iPtr,k) schedule(static)
71 for (i=0;i<pattern->myNumOutput;++i) {
72 for (iPtr=pattern->ptr[i]-index_offset_in;iPtr<pattern->ptr[i+1]-index_offset_in;++iPtr) {
73 for (k=0;k<output_block_size;++k) {
74 for (j=0;j<input_block_size;++j) {
75 index[ptr[i*output_block_size+k]-index_offset_out+(iPtr-(pattern->ptr[i]-index_offset_in))*input_block_size+j]=(pattern->index[iPtr]-index_offset_in)*input_block_size+j+index_offset_out;
76 }
77 }
78 }
79 }
80 }
81 /* create return value */
82 input_dist=Paso_Distribution_alloc(mpi_info,pattern->input_distribution->first_component,
83 input_block_size, -index_offset_in*input_block_size+index_offset_out);
84 output_dist=Paso_Distribution_alloc(mpi_info,pattern->output_distribution->first_component,
85 output_block_size, -index_offset_in*output_block_size+index_offset_out);
86 out=Paso_SystemMatrixPattern_alloc(type,output_dist,input_dist,ptr,index);
87 }
88 if (! Paso_noError()) {
89 MEMFREE(index);
90 MEMFREE(ptr);
91 }
92 Paso_Distribution_free(input_dist);
93 Paso_Distribution_free(output_dist);
94 return out;
95 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26