Coder Social home page Coder Social logo

cuda2hipcpu's Introduction

CUDA To HIP-CPU

Build Status

cuda2hipcpu provides necessary environments to allow CPU to run CUDA code. You don't need a GPU plugged in.

It uses ROCm-HIP toolkits to port CUDA code to HIP-capable code, then build it with HIP-CPU runtime to run on completely CPU platform.

The related tools are HIPIFY, Intel TBB, HIP-CPU runtime library.

Now the Dockerfile is based on CUDA 10.1 image, the version >= 11.0 is not supported yet due to the conflicts between clang and CUDA11+.

You can use the command blow to start a container with enough tools easily:

docker run --rm -it \
       --name cuda2hipcpu \
       ueqri/cuda2hipcpu:latest

or build from Dockerfile:

git clone https://github.com/ueqri/cuda2hipcpu.git
docker build -t cuda2hipcpu:latest .
docker run --rm -it \
       --name cuda2hipcpu \
       cuda2hipcpu:latest

Usage

A CUDA vector addition sample is provided as sample/vectorAdd.cu and the generic CMakeLists.txt is in the same directory.

Note that, the CMakeLists.txt is not prepare for CUDA code, but for HIP-CPU capable code with file suffix .cpp.

So, just follow the steps below to run a CUDA project in CPU:

  1. change to a CUDA source directory
  2. run convertAllCuda to port all CUDA codes in the directory (non-recursive) to HIP-CPU capable code
  3. copy the CMakeLists.txt to the directory, and optimize it to meet your demand
  4. use that CMakeLists.txt to build code with HIP-CPU runtime library
cd /path/to/
convertAllCuda
mkdir build
cd build
# make sure CMakeLists.txt exists
cmake ..
cmake --build .
# run the target with a default name
./test-HIP

Test

If you want to run the official test of HIP-CPU, just execute cd /hip-cpu/build && make test in the container,

or you can run docker run -it cuda2hipcpu:latest sh -c "cd /hip-cpu/build && make test" in the host.

Utilities

Here are some useful utilities of cuda2hipcpu:

convertAllCuda

Usage:

  1. convertAllCuda (non-recursive) only deals with the *.cu in current directory
  2. convertAllCuda -r deals with all *.cu recursively. Use it carefully
  3. convertAllCuda SINGLE_FILE deals with the certain CUDA code

Note: A symbolic link of this script was created to /usr/bin/convertAllCuda during the docker build, so just use convertAllCuda for convenience.

more...

TODO

cuda2hipcpu's People

Contributors

ueqri avatar

Watchers

 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.