- Timestamp:
- 09/26/19 18:49:01 (5 years ago)
- Location:
- codes/icosagcm/devel
- Files:
-
- 2 added
- 1 deleted
- 3 edited
- 5 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/devel/Python/dev/unstructured.pyx
r952 r977 82 82 ['dynamico_scalar_laplacian', c_void_p,2], 83 83 ['dynamico_curl_laplacian', c_void_p,2], 84 ['dynamico_partition_graph', c_int,2, c_void_p,3, c_int, c_void_p],85 84 ['dynamico_init_transfer', c_int, c_int,2,c_void_p,3, c_int,2,c_void_p,3], 86 ['dynamico_update_halo', c_int,3,c_void_p], 87 ['dynamico_morton_encode', c_int,c_void_p,4] 88 ]) 85 ['dynamico_update_halo', c_int,3,c_void_p] ]) 89 86 90 87 # set/get global variables -
codes/icosagcm/devel/Python/dynamico/meshes.py
r959 r977 1 1 from __future__ import absolute_import 2 3 from dynamico.dev import unstructured as unst4 2 5 3 import time … … 15 13 from dynamico.util import list_stencil, BaseClass, inverse_list 16 14 from dynamico import getargs 17 # TODO from dynamico.parmetis import partition_mesh 18 from dynamico.dev.unstructured import partition_mesh 15 from dynamico.partition import partition_mesh 19 16 20 17 log_master, log_world = getargs.getLogger(__name__) … … 419 416 vertex_lat[cell, ivertex] = vlat 420 417 return vertex_lon, vertex_lat 421 mesh.primal_bounds_lon, mesh.primal_bounds_lat = bounds(mesh.primal_ deg, mesh.primal_vertex, mesh.lon_v, mesh.lat_v)418 mesh.primal_bounds_lon, mesh.primal_bounds_lat = bounds(mesh.primal_own_deg, mesh.primal_vertex, mesh.lon_v, mesh.lat_v) 422 419 mesh.dual_bounds_lon, mesh.dual_bounds_lat = bounds(mesh.dual_deg, mesh.dual_vertex, mesh.lon_i, mesh.lat_i) 423 420 … … 766 763 nn, xx, yy, zz = x.size, toint(x), toint(y), toint(z) 767 764 idx=np.zeros(nn, dtype=np.int64) 768 unst.ker.dynamico_morton_encode(nn, xx,yy,zz, idx)765 partition.dynamico_morton_encode(nn, xx,yy,zz, idx) 769 766 return idx 770 767 -
codes/icosagcm/devel/Python/dynamico/partition.h
r952 r977 3 3 #include <parmetis.h> 4 4 5 void dynamico_partition_graph(int mpi_rank, int mpi_size,5 static inline void dynamico_partition_graph(int mpi_rank, int mpi_size, 6 6 idx_t vtxdist[], idx_t xadj_loc[], idx_t adjncy_loc[], 7 7 idx_t nparts, idx_t part[]) … … 49 49 } 50 50 51 void dynamico_morton_encode(int n, const int *x, const int *y, const int *z, uint64_t *m)51 static inline void dynamico_morton_encode(int n, const int *x, const int *y, const int *z, uint64_t *m) 52 52 { 53 53 for(int i=0; i<n; i++) -
codes/icosagcm/devel/Python/test/py/partition.py
r825 r977 3 3 from dynamico import meshes 4 4 from dynamico import parallel 5 from dynamico.dev import unstructured as unst6 5 from dynamico import maps 7 from dynamico .parmetis import partition_graph6 from dynamico import partition 8 7 9 8 from mpi4py import MPI … … 11 10 mpi_rank, mpi_size = comm.Get_rank(), comm.Get_size() 12 11 print '%d/%d starting'%(mpi_rank,mpi_size) 13 14 #from dynamico import partition15 12 16 13 import math as math … … 50 47 part = 0*xadj_loc[0:-1]; 51 48 52 # unst.ker.dynamico_partition_graph(mpi_rank, mpi_size, vtxdist, xadj_loc, adjncy_loc, 4, part) 53 partition_graph(comm, vtxdist, xadj_loc, adjncy_loc, part, nparts=4) 49 partition.partition_graph(comm, vtxdist, xadj_loc, adjncy_loc, part, nparts=4) 54 50 55 51 for i in range(len(part)): … … 66 62 mydegree, mybounds = [get_mycells(x) for x in primal_deg, primal_vertex] 67 63 print '%d : len(mydegree)=%d'%(mpi_rank, len(mydegree)) 68 vertex_list = sorted(set( unst.list_stencil(mydegree,mybounds)))64 vertex_list = sorted(set(partition.list_stencil(mydegree,mybounds))) 69 65 print '%d : len(vertex_list))=%d'%(mpi_rank, len(vertex_list)) 70 66 get_myvertices = parallel.Get_Indices(dim_vertex, vertex_list) … … 116 112 plt.xlim(-190.,190.) 117 113 plt.ylim(-90.,90.) 118 plt.savefig('fig_partition/A%03d.p df'%mpi_rank, dpi=1600)114 plt.savefig('fig_partition/A%03d.png'%mpi_rank, dpi=160) 119 115 120 116 fig, ax = plt.subplots() … … 124 120 plt.xlim(-190.,190.) 125 121 plt.ylim(-90.,90.) 126 plt.savefig('fig_partition/B%03d.p df'%mpi_rank, dpi=1600)122 plt.savefig('fig_partition/B%03d.png'%mpi_rank, dpi=160) -
codes/icosagcm/devel/make_python
r941 r977 13 13 rm -rf *.o *.so build/ 14 14 } 15 16 #------------------ Default action , invoked by : './make_python' --------------------17 15 18 16 function make_so() … … 33 31 } 34 32 35 36 function cmd_() 33 function check_python_modules() 37 34 { 38 echo "XIOS_ROOTDIR : $XIOS_ROOTDIR"39 35 MISSING="" 40 for module in netCDF4 jinja2 mpi4py; do36 for module in $*; do 41 37 echo "import $module" 42 38 python -c "import $module" || MISSING="$MISSING $module" … … 49 45 exit 50 46 fi 47 } 51 48 52 log mpicc -c -std=c99 -fPIC $PARMETIS_CFLAGS Python/src/partition.c -o obj/partition.o 53 make_so $XIOS_ROOTDIR/lib/libxios.a $LIBDIR/libxios.so "$NETCDF_LDFLAGS -lstdc++" 54 make_so $LIBDIR/libicosa.a $LIBDIR/libicosa.so "-L$LIBDIR -lxios $KERNELS_LDFLAGS" "physics_external_mod.o physics_mod.o timeloop_gcm_mod.o icosa_init_mod.o" obj/partition.o 55 56 # Cythonize Python modules 57 cd $DYNAMICO_ROOT/Python/src 58 NUMPY=$(python -c 'import numpy as np ; print np.get_include()') 59 CYTHONFLAGS="$SOFLAGS $LDFLAGS -L$LIBDIR -licosa $KERNELS_LDFLAGS" 60 LDSHARED="$LINK" CFLAGS="-fno-strict-aliasing -O2 -I$NUMPY" LDFLAGS="$CYTHONFLAGS" log python setup.py build_ext --inplace || exit 61 62 cp -fpr $DYNAMICO_ROOT/Python/dynamico $DYNAMICO_ROOT/lib 63 cp -fp *.so $DYNAMICO_ROOT/lib/dynamico/dev/ 49 function check_dynamico_modules() 50 { 64 51 cd $DYNAMICO_ROOT 65 66 for module in dev.cxios dev.unstructured meshes dyn time_step DCMIP; do 52 for module in $*; do 67 53 echo "import dynamico.$module" 68 54 LD_PRELOAD=$PYTHON_PRELOAD python -c "import dynamico.$module" 69 55 done 70 56 } 57 58 function cythonize() 59 { 60 EXTRA=$1 61 NUMPY=$(python -c 'import numpy as np ; print np.get_include()') 62 CYTHONFLAGS="$SOFLAGS $LDFLAGS -L$LIBDIR $KERNELS_LDFLAGS $EXTRA" 63 CC=mpicc LDSHARED="$LINK" CFLAGS="-fno-strict-aliasing -O2 -I$NUMPY $PARMETIS_CFLAGS" LDFLAGS="$CYTHONFLAGS" log python setup.py build_ext --inplace || exit 64 rm -rf build *.c # temp files 65 } 66 67 #------------------ Default action , invoked by : './make_python' -------------------- 68 69 function make_user() 70 { 71 check_python_modules netCDF4 mpi4py 72 # Cythonize Python modules 73 cd $DYNAMICO_ROOT/Python/dynamico 74 cythonize 75 rm -rf build *.c # temp files 76 cp -fpr $DYNAMICO_ROOT/Python/dynamico $DYNAMICO_ROOT/lib 77 check_dynamico_modules partition meshes dyn time_step DCMIP 78 } 79 80 function make_dev() 81 { 82 check_python_modules jinja2 83 echo "XIOS_ROOTDIR : $XIOS_ROOTDIR" 84 85 make_so $XIOS_ROOTDIR/lib/libxios.a $LIBDIR/libxios.so "$NETCDF_LDFLAGS -lstdc++" 86 make_so $LIBDIR/libicosa.a $LIBDIR/libicosa.so "-L$LIBDIR -lxios $KERNELS_LDFLAGS" "physics_external_mod.o physics_mod.o timeloop_gcm_mod.o icosa_init_mod.o" 87 88 cd $DYNAMICO_ROOT/Python/dev 89 cythonize "-licosa" 90 cp -fpr $DYNAMICO_ROOT/Python/dev $DYNAMICO_ROOT/lib/dynamico/ 91 check_dynamico_modules dev.cxios dev.unstructured 92 } 93 94 function cmd_() 95 { 96 make_user 97 } 98 99 function cmd_dev() 100 { 101 make_user 102 make_dev 103 } 104 71 105 72 106 #------------------------- script starts here ------------------------
Note: See TracChangeset
for help on using the changeset viewer.