Skip to content

BaderLab/ecuda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

661 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues Apache 2.0


ecuda logo

ecuda

STL-style abstractions for CUDA.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contant
  8. Acknowledgements

About The Project

ecuda is a C++ wrapper around the CUDA C API designed to closely resemble and be functionally equivalent to the C++ Standard Template Library (STL). Specifically: algorithms, containers, and iterators. These elements play nice with host containers and can be used in device code.

(back to top)

Built With

  • C++
  • CUDA
  • doctest

(back to top)

Getting Started

Prerequisites

  • CUDA
    sudo apt-get -y install cuda # Debian
    sudo pacman -S cuda # Arch

Installation

Option 1

  1. Clone the repo
git clone https://github.com/BaderLab/ecuda
  1. Compile and run the tests (optional)
cd ecuda
mkdir build
cmake -DECUDA_BUILD_TESTS=ON
make
ctest --output-on-failure

Option 2

Use FetchContent to add to your own project's CMakeLists.txt.

# the start of your CMakeLists.txt...

include( FetchContent )

FetchContent_Declare(
    ecuda
    GIT_REPOSITORY https://github.com/BaderLab/ecuda
    GIT_TAG        "master"
    SOURCE_DIR     "${CMAKE_BINARY_DIR}/_deps/ecuda-src"
    BINARY_DIR     "${CMAKE_BINARY_DIR}/_deps/ecuda-build"
)

FetchContent_MakeAvailable( ecuda )

find_package( CUDAToolkit REQUIRED )

# ... the rest of your CMakeLists.txt

target_link_libraries( YourExecutable PUBLIC ecuda::ecuda PRIVATE CUDA::cudart )

(back to top)

Usage

#include <ecuda.hpp>
template<class Container>
__global__
void
reverse_order(
  typename Container::const_kernel_argument in,
  typename Container::kernel_argument out
)
{
  const int t = threadIdx.x;
  if( t < in.size() ) {
    auto value = *(in.begin()+t);
	*(out.begin()+(out.size()-t-1)) = value;
  }
}
std::vector<double> hostVector( 1000 );
// ... fill hostVector with data
ecuda::vector<double> deviceVector1( hostVector.begin(), hostVector.end() );
ecuda::vector<double> deviceVector2( 1000 );
CUDA_CALL_KERNEL_AND_WAIT( reverse_order<<<1,1000>>>( deviceVector1, deviceVector2 ) );
ecuda::copy( deviceVector2.begin(), deviceVector2.end(), hostVector.begin() );
std::vector<double> hostMatrix( 10*10 );
// ... fill hostMatrix with data
ecuda::matrix<double> deviceMatrix1( 10, 10 );
ecuda::matrix<double> deviceMatrix2( 10, 10 );
ecuda::copy( hostMatrix.begin(), hostMatrix.end(), deviceMatrix1.begin() );
CUDA_CALL_KERNEL_AND_WAIT( reverse_order<<<1,10*10>>>( deviceMatrix1, deviceMatrix2 ) );
ecuda::copy( deviceMatrix2.begin(), deviceMatrix2.end(), hostVector.begin() );
std::vector<double> hostCube( 10*10*10 );
// ... fill hostCube with data
ecuda::cube<double> deviceCube1( 10, 10, 10 );
ecuda::cube<double> deviceCube2( 10, 10, 10 );
ecuda::copy( hostCube.begin(), hostCube.end(), deviceCube1.begin() );
CUDA_CALL_KERNEL_AND_WAIT( reverse_order<<<1,10*10>>>( deviceCube1, deviceCube2 ) );
ecuda::copy( deviceCube2.begin(), deviceCube2.end(), hostVector.begin() );

(back to top)

Roadmap

A quick conversion to doctest for unit testing was performed but it was extremely quick and dirty. A more comprehensive testing regime is needed.

A modernization review is needed. So far only the parts of the API needed for other projects has been reviewed and tested.

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Top contributors:

contrib.rocks image

License

Distributed under the Apache 2.0 license. See LICENSE.txt for more information.

(back to top)

Contact

Scott D. Zuyderduyn - scott.zuyderduyn@utoronto.ca

Project Link: https://github.com/BaderLab/ecuda

Acknowledgements

(back to top)

About

STL-style abstractions for CUDA.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors