Git Product home page Git Product logo

skiplist_cuda's Introduction

skiplist_cuda: A parallel/CUDA implementation of skiplist

Skiplists are a variant of linked lists that allow insertions in O(log n) time. Inspired by a GTC 2013 talk, we build a parallel implementation of skiplist where multiple GPU threads can insert simultaneously. We make heavy use of atomic compare-and-swap operation. By default, our skiplist contains integers; to use different types, modify the type definition E in skip_parallel.h.

We assume that you are using a 64-bit machine.

See here for a theoretical analysis of skiplists.

Usage

For more complete usage, see tester_parallel.cu.

Create a skiplist on the host:

#include "spmat_parallel.h"
...
// set heap size of 128 MB
cudaDeviceSetLimit(cudaLimitMallocHeapSize, 128*1024*1024);
Skiplist *sl = skiplist_create();
...

Important: It is crucial to set heap size large enough to contain all the elements to be inserted. When skiplist_insert() crashes in the middle, try increasing the heap size.

Insert elements to the skiplist Simply call skiplist_insert(). The following code stub will insert all elements in the array a into the skiplist sl:

#include "spmat_parallel.h"
...
__global__ void add(Skiplist *sl, int *a, int N)
{
  int x = threadIdx.x + blockIdx.x * blockDim.x;

  while (x < N) {
    skiplist_insert(sl, a[x]);
    x += blockDim.x * gridDim.x;
  }
}
...
add<<<100, 320>>>(sl, a_dev, N);

Remove elements from the list: Unfortunately, this feature is not completed yet. We'll try to make some time in the future.

Collect the content to the host:

E *result = skiplist_gather(sl, &result_dim);
// result points to a host buffer
// result_dim contains the number of elements

This function will allocate a buffer on the host and return its pointer. At the same time, it will return the number of elements via the second argument.

De-allocate the skiplist

skiplist_destroy(sl);

How to compile the library

make

This will compile the library, along with a sample program in tester_parallel.cu.

How to link your program with the library

nvcc -o [your executable] [your object files] skip_parallel.o safety.o

safety.o contains a little macro that checks the return value of all CUDA API functions.

Credits

Hyunsu "Philip" Cho and Sam Johnson, Trinity College, Hartford, CT

skiplist_cuda's People

Contributors

hcho3 avatar samcarljohnson avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.