Skip to content
Permalink
Browse files

Sequential version done.

  • Loading branch information
rjm11010 committed Apr 18, 2017
1 parent c29b142 commit 17398eb2c4af0b2d8c5c7c4cc3622433b8673e2c
Showing with 22 additions and 2 deletions.
  1. +18 −0 README.md
  2. +4 −2 sequential/gibbs_metropolis.cpp
@@ -2,3 +2,21 @@ Parallel MCMC On GPU
===========================

This project compares the performance of MCMC on a single threaded CPU, and a multicore, multithreaded GPU (using CUDA).


## Sequential

#### Dependencies
* gcc 5.4.0 or newer

#### How to compile
```
cd ./sequential
g++ -std=c++11 gibbs_metropolis.cpp -o gibbs_metropolis
```

##### Run
**Small Example**
``
./gibbs_metropolis smallData.txt
```
@@ -46,7 +46,7 @@ specifically http://docs.nvidia.com/cuda/curand/index.html#topic_1_2_1
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// #include <curand_kernel.h>
#include <random>

#define PI 3.14159265359f

@@ -272,11 +272,13 @@ void sample_theta(float *theta, float *log_theta, int *y, float *n,
float a, float b, int K){

float hyperA, hyperB;
std::default_random_engine generator;

for ( int i = 0; i < K; i++ ){
hyperA = a + y[i];
hyperB = b + n[i];
theta[i] = rgamma(hyperA, hyperB);
std::gamma_distribution<double> distribution(hyperA, hyperB);
theta[i] = distribution(generator);
log_theta[i] = log(theta[i]);
}
}

0 comments on commit 17398eb

Please sign in to comment.
You can’t perform that action at this time.