Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Sequential version done.
  • Loading branch information
rjm11010 committed Apr 18, 2017
1 parent c29b142 commit 17398eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 18 additions & 0 deletions README.md
Expand Up @@ -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
```
6 changes: 4 additions & 2 deletions sequential/gibbs_metropolis.cpp
Expand Up @@ -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

Expand Down Expand Up @@ -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.