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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1284 - (show annotations)
Mon Sep 3 04:47:52 2007 UTC (11 years, 7 months ago) by ksteube
File MIME type: text/plain
File size: 3566 byte(s)
Pattern length was incorrect
Adjusted #pragma ivdep

1 /* $Id$ */
2
3 /*
4 ********************************************************************************
5 * Copyright 2006, 2007 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: Pattern_unrollBlocks */
17
18 /**************************************************************/
19
20 /* Author: gross@access.edu.au */
21
22 /**************************************************************/
23
24 #include "Paso.h"
25 #include "Pattern.h"
26
27 /**************************************************************/
28
29 /* creates Pattern */
30
31 Paso_Pattern* Paso_Pattern_unrollBlocks(Paso_Pattern* pattern, \
32 int type, dim_t output_block_size,dim_t input_block_size) {
33 Paso_Pattern*out=NULL;
34 index_t *ptr=NULL,*index=NULL,iPtr;
35 dim_t i,j,k,l, block_size, new_n_ptr, new_len, new_numOutput;
36 index_t index_offset_in=(pattern->type & PATTERN_FORMAT_OFFSET1 ? 1:0);
37 index_t index_offset_out=(type & PATTERN_FORMAT_OFFSET1 ? 1:0);
38
39 Paso_resetError();
40 if ((pattern->type & PATTERN_FORMAT_SYM) != (type & PATTERN_FORMAT_SYM)) {
41 Paso_setError(TYPE_ERROR,"Paso_Pattern_unrollBlocks: conversion between symmetric and non-symmetric is not implemented yet");
42 return NULL;
43 }
44 block_size=output_block_size*input_block_size;
45 new_len=(pattern->len)*block_size;
46 new_numOutput=(pattern->numOutput)*output_block_size;
47
48 ptr=MEMALLOC(new_numOutput+1,index_t);
49 index=MEMALLOC(new_len,index_t);
50 if (! ( Paso_checkPtr(ptr) || Paso_checkPtr(index) ) ) {
51 #pragma omp parallel
52 {
53 #pragma omp for private(i) schedule(static)
54 for (i=0;i<new_numOutput+1;++i) ptr[i]=index_offset_out;
55
56 #pragma omp master
57 ptr[new_numOutput]=new_len+index_offset_out;
58
59 #pragma omp for private(i,k) schedule(static)
60 for (i=0;i<pattern->numOutput;++i)
61 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;
62
63 #pragma omp for private(i,iPtr) schedule(static)
64 for (i=0;i<new_numOutput;++i) {
65 #pragma ivdep
66 for (iPtr=ptr[i]-index_offset_out;iPtr<ptr[i+1]-index_offset_out;++iPtr) index[iPtr]=index_offset_out;
67 }
68
69 #pragma omp for private(i,j,iPtr,k) schedule(static)
70 for (i=0;i<pattern->numOutput;++i) {
71 for (iPtr=pattern->ptr[i]-index_offset_in;iPtr<pattern->ptr[i+1]-index_offset_in;++iPtr) {
72 for (k=0;k<output_block_size;++k) {
73 #pragma ivdep
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 out=Paso_Pattern_alloc(type,new_numOutput,ptr,index);
82 }
83 if (! Paso_noError()) {
84 MEMFREE(index);
85 MEMFREE(ptr);
86 }
87 return out;
88 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26