Tutorials:ALPS USERCODE ALPSize
Languages: |
English • 日本語 (ja) • 繁體中文 (zh-tw) • 简体中文 (zh) |
Contents
- 1 ALPSize Introduction
- 2 Packaging with Cmake
- 3 Tutorial
- 3.1 Packaging with Cmake
- 3.2 Implementation of the Wolff algorithm in C language
- 3.3 Implementation of the Wolff algorithm in C++ language
- 3.4 Using Standard Template Library
- 3.5 Using Boost C++ Library
- 3.6 Using ALPS/parameters
- 3.7 Using ALPS/alea
- 3.8 Using ALPS/lattice
- 3.9 Full ALPSize using ALPS/Parapack Scheduler
ALPSize Introduction
ALPS scheduler functions and calculations, such as Parameters and Alea will be able to use easily by packaging with Cmake and setting the link with the ALPS library.There is the following advantage by using an ALPS scheduler.
- Easy parameter parallelization.
- To work on PC,Server,even supercomputer.
- Easy processing of the results.
- Multiple parallelization of the already parallelized code is also easy.
- That is aleady available,such as adapters for exchange method.
Packaging with Cmake
To package the program is using CMake(2.8.0-).CMake is cross-platform system for managing the build process of software. it can compile using cmake&make with configure file CMakeLists.txt.
The following figure is an image of the flow of packaging. The packaging is done by editing the CMakeList.txt.
CMakeList.txt should be edited,setting headers,read of ALPS environment and dependencies to target, and if necessary,edit test setting.
Headers
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
project(hello)
read ALPS environment
find_package(ALPS REQUIRED NO_SYSTEM_ENVIRONMENT_PATH)
include(${ALPS_USE_FILE})
dependencies to target
add_executable(hello hello.cpp)
test setting
Tutorial
The tutorial sample code can be found at http://todo.ap.t.u-tokyo.ac.jp/public/archive/alpsize-2.0b1.tar.gz.
Packaging with Cmake
00_cmake
$ cmake . $ make $ ./hello
Implementation of the Wolff algorithm in C language
01_original-c
$ cmake . $ make $ ./wolff
Implementation of the Wolff algorithm in C++ language
02_basic-cpp
- modify header file: <math.h> to <cmath>,etc..
- std name space
- modify "printf","fprintf" to "std::cout","std::cerr"
- format of comment
$ cmake . $ make $ ./wolff
Using Standard Template Library
03_stl
- std::vector<>:1D-array
- std::stack<>:stack
- The required size will be allocate/deallocate automatically
- The type of the elements of the stack and array (which may be user-defined types) specified in the template parameter
$ cmake . $ make $ ./wolff
Using Boost C++ Library
04_boost
- <boost/array.hpp>
- fixed-length array
- <boost/random.hpp>
- random number generation
- variety of random number generation method,Mersenne Twister,、Lagged Fibonacci,...
- uniform distribution,normal distribution,Poisson distribution,exponential distribution...
- random number generation
- <boost/timer.hpp>
- timer(execution time measurements)
$ cmake . $ make $ ./wolff
Using ALPS/parameters
- 05_parameters
$ cmake . $ make $ ./wolff <wolff.ip
Using ALPS/alea
- 06_alea
$ cmake . $ make $ ./wolff wolff.ip
Using ALPS/lattice
- 07_lattice
$ cmake . $ make $ ./lattice <lattice.ip $ ./wolff <wolff.ip
Full ALPSize using ALPS/Parapack Scheduler
08_scheduler
- encapsulated code: Worker class
- Function, must be implement by Worker Class
- constructor、init_obserbables member function
- run member function
- is_thermalized&progress member function
- save&load member function
- Worker registration to the scheduler running the macro of PARAPACK_REGISTER_WORKER
- preparation of Parameters and ObservableSet by scheduler,and setting constructor、init_observables-function、run-function
- Because lattice_mc_workerはlattice_helper has inherited rng_helper、that can activate the function of lattice_helper,rng_helper.
$ cmake . $ make $ ./hello < hello.ip $ ./wolff < wolff.ip