Code Monkey home page Code Monkey logo

cuda-permutation's Introduction

CUDA-Permutation(Game-Simulation)

用CUDA模擬 Slot machine 的排列組合,並能夠模擬指定盤面的出現的機率。

Input

定義符號和轉盤上的版面及數量,以及中獎盤面的檔案路徑。

input.csv(暫定格式)

input.csv

Winning Set

符號的索引值定義中獎的盤面

-1 代表任何相同的圖案

W1.txt

Output

輸出中獎的機率。

output.csv(暫定格式)

output.csv


Debug紀錄

多個Thread同時使用同個Memory進行累加,導致累加錯誤。

參考https://www.ptt.cc/bbs/C_and_CPP/M.1271911923.A.2B8.html

  1. 使用atomicAdd(&x, 1)代替x += 1。(效率較低,但比較好改)
  2. 每個Thread使用的memory切乾淨,最後再用CPU算Sum。(效率較高)

比較效率(左:atomicAdd, 右: Thread切乾淨後Sum)

compare01

compare02

compare03

cuda-permutation's People

Contributors

qwe321qwe321qwe321 avatar harrisonyei avatar

Watchers

James Cloos 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.