Git Product home page Git Product logo

algorithmcollection's Introduction

Educational Parallel Algorithm Collection

This is a parallel algorithm collection written in C. It contains fifteen programs that are explained in the book "The Art of Multiprocessor Programming (M. Herlihy, N. Shavit)".

Algorithms

Queue

  1. LLSCLockFreeQueue
  1. CASLockFreeQueue

List

  1. CoarseGrainedSynchroList
  • Coarse-Grained Synchronization Singly-linked List
  1. FineGrainedSynchroList
  • Fine-Grained Synchronization Singly-linked List
  1. LazySynchroList
  • Lazy Synchronization Singly-linked List
  1. NonBlockingList
  1. LockFreeList

SkipList

  1. Skiplist
  2. LazySkiplist
  1. LockFreeSkiplist

Hash

  1. Hash
  • (Chain) Hash Table
  1. OpenAddressHash
  • Open-Addressed Hash Table
  1. StripedHash
  • Striped Hash Table
  1. RefinableHash
  • Refinable Hash Table
  1. CuckooHash
  1. ConcurrentCuckooHash
  • Concurrent Cuckoo Hash Table

Compile on Linux(X86_64) and OSX

$ make
$ make test

How to use

Usage

$ ./queue/LLSCLockFreeQueue -h
simple algorithm test bench
usage: ./queue/LLSCLockFreeQueue [Options<default>]
		-t number_of_thread<10>
		-n number_of_item<1000>
		-v               :verbose
		-V               :debug mode
		-h               :help

Some programs have other options. Please check each.

Execute

By default, run 10 threads, and each thread inserts and deletes 1000 items.

$ ./queue/LLSCLockFreeQueue
<<simple algorithm test bench>>
RESULT: test OK
condition =>
	  10 threads run
	  1000 items inserted and deleted / thread, total 10000 items
performance =>
	    interval =  0.006693 [sec]
	    thread info:
	      ave. = 0.002807[sec], min = 0.000832[sec], max = 0.004397[sec]  

You can change the number of items and the number of threads.

$ ./queue/LLSCLockFreeQueue -t 20 -n 10000
<<simple algorithm test bench>>
RESULT: test OK
condition =>
	  20 threads run
	  10000 items inserted and deleted / thread, total 200000 items
performance =>
	    interval =  0.102954 [sec]
	    thread info:
	      ave. = 0.050064[sec], min = 0.008257[sec], max = 0.059089[sec]

Verbose & Debug mode

You can see how to work in the LLSCLockFreeQueue program.

$ ./queue/LLSCLockFreeQueue -t 2 -n 4 -V
<<simple algorithm test bench>>
thread[1] add: 5
[5]
thread[1] add: 6
[5][6]
thread[1] add: 7
[5][6][7]
thread[1] add: 8
[5][6][7][8]
thread[0] add: 1
[5][6][7][8][1]
thread[0] add: 2
[5][6][7][8][1][2]
thread[0] add: 3
[5][6][7][8][1][2][3]
thread[0] add: 4
[5][6][7][8][1][2][3][4]
thread[0] delete: 5
[6][7][8][1][2][3][4]
thread[0] delete: 6
[7][8][1][2][3][4]
thread[0] delete: 7
[8][1][2][3][4]
thread[0] delete: 8
[1][2][3][4]
thread[1] delete: 1
[2][3][4]
thread[1] delete: 2
[3][4]
thread[1] delete: 3
[4]
thread[1] delete: 4

thread(0) end 0.002006[sec]
thread(1) end 0.006205[sec]
RESULT: test OK
condition =>
	2 threads run
	4 items inserted and deleted / thread, total 8 items
performance =>
	interval =  0.006519 [sec]
	thread info:
	  ave. = 0.004106[sec], min = 0.002006[sec], max = 0.006205[sec]

Test

Run the LLSCLockFreeQueue_test. You can see more easily how to work this program.

$ ./queue/LLSCLockFreeQueue_test
[0]
[0][1]
[0][1][2]
[0][1][2][3]
[0][1][2][3][4]
[0][1][2][3][4][5]
[0][1][2][3][4][5][6]
[0][1][2][3][4][5][6][7]
[0][1][2][3][4][5][6][7][8]
[0][1][2][3][4][5][6][7][8][9]
[1][2][3][4][5][6][7][8][9]
[2][3][4][5][6][7][8][9]
[3][4][5][6][7][8][9]
[4][5][6][7][8][9]
[5][6][7][8][9]
[6][7][8][9]
[7][8][9]
[8][9]
[9]

algorithmcollection's People

Contributors

s-hironobu 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.