Changeset 2417


Ignore:
Timestamp:
10/12/09 16:36:15 (15 years ago)
Author:
Eric.Larour
Message:

New multi-threading capability enabled for InterpFromMeshToMesh2d module.

Location:
issm/trunk
Files:
4 added
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/configs/linux64/linux64.sh

    r2065 r2417  
    11#!/bin/sh
    22
    3 ./configure --prefix=$ISSM_DIR --with-matlab-dir=$MATLAB_DIR --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install --with-metis-dir=$ISSM_DIR/externalpackages/metis/install --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich" --with-petsc-arch=$ISSM_ARCH --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/fblaslapack/$ISSM_ARCH --with-plapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32/$ISSM_ARCH --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/SCALAPACK/$ISSM_ARCH --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/MUMPS_4.6.3/$ISSM_ARCH --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/ -lgfortran" --with-graphics-lib=/usr/lib64/libX11.so --with-cxxoptflags="-march=opteron -O2"
     3./configure --prefix=$ISSM_DIR --with-matlab-dir=$MATLAB_DIR --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install --with-metis-dir=$ISSM_DIR/externalpackages/metis/install --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich" --with-petsc-arch=$ISSM_ARCH --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/fblaslapack/$ISSM_ARCH --with-plapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32/$ISSM_ARCH --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/SCALAPACK/$ISSM_ARCH --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/MUMPS_4.6.3/$ISSM_ARCH --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/ -lgfortran" --with-graphics-lib=/usr/lib64/libX11.so --with-cxxoptflags="-march=opteron -O2" --with-numthreads=16
  • issm/trunk/m4/issm_options.m4

    r2241 r2417  
    656656        dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%optimization-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    657657
     658        dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%multithreading-beginning%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     659        AC_ARG_WITH([numthreads],
     660                          AS_HELP_STRING([--with-numthreads = NUMTHREADS_VALUE],
     661                                                         [numthreads, default is 1. ]),
     662                          [NUMTHREADS_VALUE=$withval],[NUMTHREADS_VALUE=1])
     663        AC_MSG_CHECKING(for number of threads)
     664        dnl defaults
     665        MULTITHREADING=no
     666        MULTITHREADINLIB=""
     667        if test "$NUMTHREADS_VALUE" != "1"; then
     668                MULTITHREADINGLIB="-lpthread"
     669                AC_DEFINE([_MULTITHREADING_],[1],[with numthreads enabled])
     670                AC_DEFINE_UNQUOTED([_NUMTHREADS_],[$NUMTHREADS_VALUE],[number of threads])
     671        fi
     672        AC_SUBST([MULTITHREADINGLIB])
     673        AC_MSG_RESULT($NUMTHREADS_VALUE)
     674        dnl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%numthreads build-end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    658675
    659676])
  • issm/trunk/scripts/historyISSM.m

    r2406 r2417  
    3030md=setelementstype(md,'pattyn','all','stokes','all');
    3131md=setelementstype(md,'macayeal','all');
     32md=solve(md,'analysis_type','diagnostic','batch','yes');
     33md=solve(md,'analysis_type','thermal');
     34md=solve(md,'analysis_type','thermal','batch','yes');
    3235%  --  plots  --
    3336plotmodel(md,'data',md.results.diagnostic.vel)
    3437print -dpng vel.png
     38%  --  setup --
     39md=model;
     40md=parameterize(md,'Antarctica.par');
     41md=geography(md,'','');
     42md=geography(md,'Iceshelves.exp','Islands.exp');
     43md=extrude(md,8,1);
     44md=mesh(md,'DomainOutline.exp',5000);
  • issm/trunk/src/c/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp

    r2361 r2417  
    22 * \brief  "c" core code for interpolating values from a structured grid.
    33 */
     4
     5
     6#ifdef HAVE_CONFIG_H
     7        #include "config.h"
     8#else
     9#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
     10#endif
    411
    512#include "./InterpFromMeshToMesh2dx.h"
     
    815#undef __FUNCT__
    916#define __FUNCT__ "InterpFromMeshToMesh2dx"
    10 
    11 int InterpFromMeshToMesh2dx( Vec* pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,double default_value) {
     17int InterpFromMeshToMesh2dx( Vec* pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,double default_value){
    1218
    1319        /*Output*/
     
    1521
    1622        /*Intermediary*/
    17         int i,j;
     23        int i;
    1824        int interpolation_type;
    1925        bool debug;
    20         double area;
    21         double area_1,area_2,area_3;
    22         double data_value;
    2326        double x_prime_min,x_prime_max;
    2427        double y_prime_min,y_prime_max;
    25         double x_tria_min,y_tria_min;
    26         double x_tria_max,y_tria_max;
     28
     29        /*threading: */
     30        InterpFromMeshToMesh2dxThreadStruct gate;
     31        const int num=_NUMTHREADS_;
    2732
    2833        /*some checks*/
     
    5863        for (i=0;i<nods_prime;i++) VecSetValue(data_prime,i,default_value,INSERT_VALUES);
    5964
    60         /*Loop over the elements*/
    61         if (debug) printf("      interpolation progress:   %5.2lf %%",0.0);
    62         for (i=0;i<nels_data;i++){
     65        /*initialize thread parameters: */
     66        gate.debug=debug;
     67        gate.nods_prime=nods_prime;
     68        gate.nels_data=nels_data;
     69        gate.x_data=x_data;
     70        gate.y_data=y_data;
     71        gate.index_data=index_data;
     72        gate.x_prime=x_prime;
     73        gate.y_prime=y_prime;
     74        gate.data=data;
     75        gate.interpolation_type=interpolation_type;
     76        gate.default_value=default_value;
     77        gate.data_prime=data_prime;
     78        gate.x_prime_min=x_prime_min;
     79        gate.x_prime_max=x_prime_max;
     80        gate.y_prime_min=y_prime_min;
     81        gate.y_prime_max=y_prime_max;
    6382
    64                 /*display current iteration*/
    65                 if (debug && fmod((double)i,(double)100)==0) printf("\b\b\b\b\b\b\b%5.2lf %%",(double)i/nels_data*100);
    66 
    67                 /*Get extrema coordinates of current elements*/
    68                 x_tria_min=x_data[(int)index_data[3*i+0]-1]; x_tria_max=x_tria_min;
    69                 y_tria_min=y_data[(int)index_data[3*i+0]-1]; y_tria_max=y_tria_min;
    70                 for (j=1;j<3;j++){
    71                         if(x_data[(int)index_data[3*i+j]-1]<x_tria_min) x_tria_min=x_data[(int)index_data[3*i+j]-1];
    72                         if(x_data[(int)index_data[3*i+j]-1]>x_tria_max) x_tria_max=x_data[(int)index_data[3*i+j]-1];
    73                         if(y_data[(int)index_data[3*i+j]-1]<y_tria_min) y_tria_min=y_data[(int)index_data[3*i+j]-1];
    74                         if(y_data[(int)index_data[3*i+j]-1]>y_tria_max) y_tria_max=y_data[(int)index_data[3*i+j]-1];
    75                 }
    76 
    77                 /*if there is no point inside the domain, go to next iteration*/
    78                 if ( x_prime_max < x_tria_min ) continue;
    79                 if ( x_prime_min > x_tria_max ) continue;
    80                 if ( y_prime_max < y_tria_min ) continue;
    81                 if ( y_prime_min > y_tria_max ) continue;
    82 
    83                 /*get area of the current element (Jacobian = 2 * area)*/
    84                 //area =x2 * y3 - y2*x3 + x1 * y2 - y1 * x2 + x3 * y1 - y3 * x1;
    85                 area=x_data[(int)index_data[3*i+1]-1]*y_data[(int)index_data[3*i+2]-1]-y_data[(int)index_data[3*i+1]-1]*x_data[(int)index_data[3*i+2]-1]
    86                   +  x_data[(int)index_data[3*i+0]-1]*y_data[(int)index_data[3*i+1]-1]-y_data[(int)index_data[3*i+0]-1]*x_data[(int)index_data[3*i+1]-1]
    87                   +  x_data[(int)index_data[3*i+2]-1]*y_data[(int)index_data[3*i+0]-1]-y_data[(int)index_data[3*i+2]-1]*x_data[(int)index_data[3*i+0]-1];
    88 
    89                 /*loop over the prime nodes*/
    90                 for (j=0;j<nods_prime;j++){
    91 
    92                         /*if the current point is not in the triangle, continue*/
    93                         if ( x_prime[j] < x_tria_min ) continue;
    94                         if ( x_prime[j] > x_tria_max ) continue;
    95                         if ( y_prime[j] < y_tria_min ) continue;
    96                         if ( y_prime[j] > y_tria_max ) continue;
    97 
    98                         /*Get first area coordinate = det(x-x3  x2-x3 ; y-y3   y2-y3)/area*/
    99                         area_1=((x_prime[j]-x_data[(int)index_data[3*i+2]-1])*(y_data[(int)index_data[3*i+1]-1]-y_data[(int)index_data[3*i+2]-1])
    100                                                 -  (y_prime[j]-y_data[(int)index_data[3*i+2]-1])*(x_data[(int)index_data[3*i+1]-1]-x_data[(int)index_data[3*i+2]-1]))/area;
    101                         /*Get second area coordinate =det(x1-x3  x-x3 ; y1-y3   y-y3)/area*/
    102                         area_2=((x_data[(int)index_data[3*i+0]-1]-x_data[(int)index_data[3*i+2]-1])*(y_prime[j]-y_data[(int)index_data[3*i+2]-1])
    103                                                 - (y_data[(int)index_data[3*i+0]-1]-y_data[(int)index_data[3*i+2]-1])*(x_prime[j]-x_data[(int)index_data[3*i+2]-1]))/area;
    104                         /*Get third area coordinate = 1-area1-area2*/
    105                         area_3=1-area_1-area_2;
    106 
    107                         /*is the current point in the current element?*/
    108                         if (area_1>=0 && area_2>=0 && area_3>=0){
    109 
    110                                 /*Yes ! compute the value on the point*/
    111                                 if (interpolation_type==1){
    112                                         /*nodal interpolation*/
    113                                         data_value=area_1*data[(int)index_data[3*i+0]-1]+area_2*data[(int)index_data[3*i+1]-1]+area_3*data[(int)index_data[3*i+2]-1];
    114                                 }
    115                                 else{
    116                                         /*element interpolation*/
    117                                         data_value=data[i];
    118                                 }
    119                                 if (isnan(data_value)) data_value=default_value;
    120 
    121                                 /*insert value and go to the next point*/
    122                                 VecSetValue(data_prime,j,data_value,INSERT_VALUES);
    123                         }
    124                 }
    125         }
    126          if (debug) printf("\b\b\b\b\b\b\b%5.2lf %%\n",100.0);
     83        /*launch the thread manager with InterpFromMeshToMesh2dxt as a core: */
     84        LaunchThread(InterpFromMeshToMesh2dxt,(void*)&gate,num);
    12785
    12886        /*Assign output pointers:*/
    12987        *pdata_prime=data_prime;
    13088}
     89
     90
     91
  • issm/trunk/src/c/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h

    r2292 r2417  
    88#include "../toolkits/toolkits.h"
    99
     10
     11
     12/*threading: */
     13typedef struct{
     14
     15        int debug;
     16        int nels_data;
     17        double* x_data;
     18        double* y_data;
     19        double* index_data;
     20        int nods_prime;
     21        double* x_prime;
     22        double* y_prime;
     23        double* data;
     24        int     interpolation_type;
     25        double  default_value;
     26        Vec     data_prime;
     27        double  x_prime_min;
     28        double  x_prime_max;
     29        double  y_prime_min;
     30        double  y_prime_max;
     31
     32} InterpFromMeshToMesh2dxThreadStruct;
     33
     34
    1035int InterpFromMeshToMesh2dx( Vec* pdata_prime,double* index_data, double* x_data, double* y_data, int nods_data,int nels_data, double* data, int data_length, double* x_prime, double* y_prime, int nods_prime,double default_value);
     36void* InterpFromMeshToMesh2dxt(void* vInterpFromMeshToMesh2dxThreadStruct);
     37
    1138
    1239#endif /* _INTERPFROMMESHTOMESH2DX_H */
  • issm/trunk/src/c/Makefile.am

    r2383 r2417  
    8787                                        ./shared/Alloc/alloc.h\
    8888                                        ./shared/Alloc/alloc.cpp\
     89                                        ./shared/Threads/issm_threads.h\
     90                                        ./shared/Threads/LaunchThread.cpp\
    8991                                        ./shared/Matlab/matlabshared.h\
    9092                                        ./shared/Matlab/PrintfFunction.cpp\
     
    248250                                        ./InterpFromGridToMeshx/InterpFromGridToMeshx.h\
    249251                                        ./InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp\
     252                                        ./InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dxt.cpp\
    250253                                        ./InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h\
    251254                                        ./InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp\
     
    381384                                        ./DataSet/DataSet.h\
    382385                                        ./shared/shared.h\
     386                                        ./shared/Threads/issm_threads.h\
     387                                        ./shared/Threads/LaunchThread.cpp\
    383388                                        ./shared/Alloc/alloc.h\
    384389                                        ./shared/Alloc/alloc.cpp\
     
    541546                                        ./InterpFromGridToMeshx/InterpFromGridToMeshx.h\
    542547                                        ./InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp\
     548                                        ./InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dxt.cpp\
    543549                                        ./InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.h\
    544550                                        ./InterpFromMeshToMesh3dx/InterpFromMeshToMesh3dx.cpp\
  • issm/trunk/src/c/objects/Tria.cpp

    r2355 r2417  
    36683668
    36693669                /*Calculate scalar parameter*/
    3670                 scalar_ocean=gauss_weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_velocity*t_pmp/(heatcapacity*rho_ice);
     3670                scalar_ocean=gauss_weight*Jdet*rho_water*mixed_layer_capacity*thermal_exchange_velocity*(t_pmp)/(heatcapacity*rho_ice);
    36713671                if(dt){
    36723672                        scalar_ocean=dt*scalar_ocean;
  • issm/trunk/src/c/shared/shared.h

    r679 r2417  
    1818#include "Dofs/dofs.h"
    1919#include "String/sharedstring.h" //to avoid confusion with <string.h> standard header file
     20#include "Threads/issm_threads.h"
    2021
    2122
  • issm/trunk/src/m/classes/public/basalstress.m

    r1314 r2417  
    1 function [bx by b]=basalstress(md,options_structure,width,i,type);
     1function [bx by b]=basalstress(md)
    22%BASALSTRESS - compute basal stress from basal drag and geometric information.
    33%
    44%   Usage:
    5 %      basalstress(md,options_structure,width,i,type);
     5%      [bx by b]=basalstress(md);
    66%
    77%   See also: plot_basaldrag
    88
    9 %check layer
    10 if strcmpi(md.type,'3d')
    11         if options_structure.layer~=1,
    12                 disp('plot_basaldrag warning: basal drag is displayed in the lower layer')
    13                 options_structure.layer=1;
    14         end
    15 end
    169
    1710%compute exponents
  • issm/trunk/src/mex/Makefile.am

    r2333 r2417  
    5757
    5858
    59 #LDADD =   $(TRIANGLELIB)  $(PETSCLIB)  ../c/libISSM.a  $(METISLIB) $(FLIBS)  $(PLAPACKLIB) $(SCALAPACKLIB) $(BLASLAPACKLIB) $(MUMPSLIB) $(BLACSLIB) $(DAKOTALIB)  $(MPILIB) $(MEXLIB) $(MATHLIB) $(FORTRANLIB)
    60 
    61 LDADD =   $(TRIANGLELIB) ../c/libISSM.a $(PETSCLIB)   $(FLIBS)  $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB)  $(DAKOTALIB) $(METISLIB) $(BLASLAPACKLIB)  $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB)
     59LDADD =   $(TRIANGLELIB) ../c/libISSM.a $(PETSCLIB)   $(FLIBS)  $(PLAPACKLIB)  $(MUMPSLIB) $(SCALAPACKLIB)  $(BLACSLIB)  $(DAKOTALIB) $(METISLIB) $(BLASLAPACKLIB)  $(MPILIB) $(MATHLIB) $(FORTRANLIB) $(GRAPHICSLIB) $(MULTITHREADINGLIB)
    6260
    6361AM_LDFLAGS = $(MEXLINK)
Note: See TracChangeset for help on using the changeset viewer.