/GPU-OpenCL-VFI-in-Julia

GPU + OpenCL Value Function Iteration for Macro Models

Primary LanguageJupyter Notebook

GPU/OpenCL Value Function Iteration in Julia

made in | Konstanz

Tested on: Julia v0.6.4, MacOS 10.12+


JuliaCon 2018 Presentation: "GPU-Accelerated Value Function Iteration in Julia: Faster Macroeconomic Modeling"


Ideas on using Julia to apply GPGPU computing to Economics:

Notebook Description
GPU Computing for Value Function Iteration in OpenCL Implementation of the basic RBC model in Julia and in pure OpenCL code.
Value Function Iteration with GPUArray.jl Solving the simple RBC model on the GPU, but by using higher-level Julia code using GPUArrays.jl and CLArrays.jl.
GPU Value Function Iteration under Uncertainty Introducing uncertainty in the RBC model through the mean of a simple Markov process for productivity, and solving it with the GPU.
OLG Model with Individual Uncertainty [!] Experimental [!]
Usage of an OLG model similar to that developed by Huggett (1993) to show the computational advantages of using GPUs to run the VFI algorithm.

A Basic Model & the Solution

Since this is supposed to work as a simple example, the model used is a simple Real Business Cycle model. The value function is:

For both the CPU and the GPU algorithm we employ a "brute force" algorithm:

  1. Start with a guess for the value function, V0;
  2. Take the capital grid point k;
  3. Iterate from k_lower_bound to k_u(k), where k_u is such that implied consumption is not negative;
  4. Save the results in the new value function approxiamtion V1;
  5. Iterate until convergence;

Acknowledgements

The main concepts behind this work are from "Tapping the Supercomputer under your Desk: Solving Dynamic Equilibrium Models with Graphics Processors" by Eric M. Aldrich, Jesús Fernández-Villaverde, A. Ronald Gallant and Juan F. Rubio-Ramírez.

I would like to thank Simon Danish, who develops GPUArrays.jl and CPUArrays.jl, for his great help on using said packages.

Notes:

  • The OpenCL.jl, GPUArrays.jl and CLArrays.jl packages are required to run the GPU code.
  • The IJulia package is necessary to run the IJupyter notebook.
  • The OpenCL kernel used is available standalone in the repository.