Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ doc\html
cscope.*
examples/cuda/multiple_streams*
examples/cuda/single_stream*
examples/hip/multiple_streams*
examples/hip/single_stream*
6 changes: 3 additions & 3 deletions doc/cuda.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[#cuda]
[section:cuda CUDA]

[@http://developer.nvidia.com/cuda-zone/ CUDA (Compute Unified Device Architecture)] is a platform for parallel computing
[@https://developer.nvidia.com/cuda/ CUDA (Compute Unified Device Architecture)] is a platform for parallel computing
on NVIDIA GPUs. The application programming interface of CUDA gives access to
GPU's instruction set and computation resources (Execution of compute kernels).

Expand Down Expand Up @@ -102,8 +102,8 @@ streams has finished.
}}}

[variablelist
[[Effects:] [Suspends active fiber till CUDA stream has finished its operations.]]
[[Returns:] [tuple of stream reference and the CUDA stream status]]
[[Effects:] [Suspends active fiber till CUDA stream or streams have finished their operations.]]
[[Returns:] [For a single stream, returns a tuple containing the stream and its CUDA status. For multiple streams, returns a vector of tuples containing each stream and its CUDA status.]]
]


Expand Down
10 changes: 5 additions & 5 deletions doc/hip.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
[#hip]
[section:hip ROCm/HIP]

[@http://github.com/ROCm-Developer-Tools/HIP/tree/roc-1.6.0/ HIP] is part of the
[@http://rocm.github.io/ ROC (Radeon Open Compute)] platform for parallel computing
[@https://github.com/ROCm-Developer-Tools/HIP/tree/roc-1.6.0/ HIP] is part of the
[@https://www.amd.com/en/products/software/rocm.html ROCm] platform for parallel computing
on AMD and NVIDIA GPUs. The application programming interface of HIP gives access to
GPU's instruction set and computation resources (Execution of compute kernels).

Expand Down Expand Up @@ -57,7 +57,7 @@ streams has finished.
for ( int i = 0; i < full_size; i += size) {
hipMemcpyAsync( dev_a, host_a + i, size * sizeof( int), hipMemcpyHostToDevice, stream);
hipMemcpyAsync( dev_b, host_b + i, size * sizeof( int), hipMemcpyHostToDevice, stream);
hipLaunchKernel(kernel, dim3(size / 256), dim3(256), 0, stream, size, dev_a, dev_b, dev_c);
hipLaunchKernelGGL( kernel, dim3(size / 256), dim3(256), 0, stream, size, dev_a, dev_b, dev_c);
hipMemcpyAsync( host_c + i, dev_c, size * sizeof( int), hipMemcpyDeviceToHost, stream);
}
auto result = boost::fibers::hip::waitfor_all( stream); // suspend fiber till HIP stream has finished
Expand Down Expand Up @@ -103,8 +103,8 @@ streams has finished.
}}}

[variablelist
[[Effects:] [Suspends active fiber till HIP stream has finished its operations.]]
[[Returns:] [tuple of stream reference and the HIP stream status]]
[[Effects:] [Suspends active fiber till HIP stream or streams have finished their operations.]]
[[Returns:] [For a single stream, returns a tuple containing the stream and its status. For multiple streams, returns a vector of tuples containing each stream and its status.]]
]


Expand Down
2 changes: 1 addition & 1 deletion examples/cuda/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ NVCC := $(CUDA_PATH)/bin/nvcc
CPPFLAGS := -O2 -std=c++11
LDFLAGS := -g -L/usr/local/lib
INCLUDES := -I/usr/local/include -I$(CUDA_PATH)/include
LIBRARIES := -lboost_fiber -lboost_context -lboost_system -lboost_filesystem
LIBRARIES := -lboost_fiber -lboost_context

all: build

Expand Down
3 changes: 0 additions & 3 deletions examples/cuda/multiple_streams.cu
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <random>
#include <tuple>

#include <cuda_runtime_api.h>

#include <boost/assert.hpp>
#include <boost/bind.hpp>
#include <boost/intrusive_ptr.hpp>

#include <boost/fiber/all.hpp>
#include <boost/fiber/cuda/waitfor.hpp>
Expand Down
3 changes: 0 additions & 3 deletions examples/cuda/single_stream.cu
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <random>
#include <tuple>

#include <cuda_runtime_api.h>

#include <boost/assert.hpp>
#include <boost/bind.hpp>
#include <boost/intrusive_ptr.hpp>

#include <boost/fiber/all.hpp>
#include <boost/fiber/cuda/waitfor.hpp>
Expand Down
8 changes: 4 additions & 4 deletions examples/hip/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
HIP_PATH := /opt/rocm/hip
HIP_PATH := /opt/rocm

HIPCC := $(HIP_PATH)/bin/hipcc

CPPFLAGS := -O2 -std=c++11
LDFLAGS := -L/usr/local/lib
INCLUDES := -I/usr/local/include -I$(HIP_PATH)/include
LIBRARIES := -lboost_fiber -lboost_context -lboost_system -lboost_filesystem
LIBRARIES := -lboost_fiber -lboost_context

all: build

build: single_stream multiple_streams

single_stream.o:single_stream.cpp
single_stream.o:single_stream.hip
$(HIPCC) $(INCLUDES) $(CPPFLAGS) -o $@ -c $<

single_stream: single_stream.o
$(HIPCC) $(LDFLAGS) -o $@ $+ $(LIBRARIES)

multiple_streams.o:multiple_streams.cpp
multiple_streams.o:multiple_streams.hip
$(HIPCC) $(INCLUDES) $(CPPFLAGS) -o $@ -c $<

multiple_streams: multiple_streams.o
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <random>
#include <tuple>

#include <hip/hip_runtime.h>

#include <boost/assert.hpp>
#include <boost/bind.hpp>
#include <boost/intrusive_ptr.hpp>

#include <boost/fiber/all.hpp>
#include <boost/fiber/hip/waitfor.hpp>
#include "boost/fiber/hip/waitfor.hpp"

__global__
void vector_add(hipLaunchParm lp, int * a, int * b, int * c, int size) {
void vector_add( int * a, int * b, int * c, int size) {
int idx = threadIdx.x + blockIdx.x * blockDim.x;
if ( idx < size) {
c[idx] = a[idx] + b[idx];
Expand Down Expand Up @@ -62,8 +59,8 @@ int main() {
hipMemcpyAsync( dev_a1, host_a + i + size, size * sizeof( int), hipMemcpyHostToDevice, stream1);
hipMemcpyAsync( dev_b0, host_b + i, size * sizeof( int), hipMemcpyHostToDevice, stream0);
hipMemcpyAsync( dev_b1, host_b + i + size, size * sizeof( int), hipMemcpyHostToDevice, stream1);
hipLaunchKernel( vector_add, dim3(size / 256), dim3(256), 0, stream0, dev_a0, dev_b0, dev_c0, size);
hipLaunchKernel( vector_add, dim3(size / 256), dim3(256), 0, stream1, dev_a1, dev_b1, dev_c1, size);
hipLaunchKernelGGL( vector_add, dim3(size / 256), dim3(256), 0, stream0, dev_a0, dev_b0, dev_c0, size);
hipLaunchKernelGGL( vector_add, dim3(size / 256), dim3(256), 0, stream1, dev_a1, dev_b1, dev_c1, size);
hipMemcpyAsync( host_c + i, dev_c0, size * sizeof( int), hipMemcpyDeviceToHost, stream0);
hipMemcpyAsync( host_c + i + size, dev_c1, size * sizeof( int), hipMemcpyDeviceToHost, stream1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <random>
#include <tuple>

#include <hip/hip_runtime.h>

#include <boost/assert.hpp>
#include <boost/bind.hpp>
#include <boost/intrusive_ptr.hpp>

#include <boost/fiber/all.hpp>
#include <boost/fiber/hip/waitfor.hpp>
#include "boost/fiber/hip/waitfor.hpp"

__global__
void vector_add(hipLaunchParm lp, int * a, int * b, int * c, int size) {
void vector_add( int * a, int * b, int * c, int size) {
int idx = threadIdx.x + blockIdx.x * blockDim.x;
if ( idx < size) {
c[idx] = a[idx] + b[idx];
Expand Down Expand Up @@ -55,7 +52,7 @@ int main() {
for ( int i = 0; i < full_size; i += size) {
hipMemcpyAsync( dev_a, host_a + i, size * sizeof( int), hipMemcpyHostToDevice, stream);
hipMemcpyAsync( dev_b, host_b + i, size * sizeof( int), hipMemcpyHostToDevice, stream);
hipLaunchKernel( vector_add, dim3(size / 256), dim3(256), 0, stream, dev_a, dev_b, dev_c, size);
hipLaunchKernelGGL( vector_add, dim3(size / 256), dim3(256), 0, stream, dev_a, dev_b, dev_c, size);
hipMemcpyAsync( host_c + i, dev_c, size * sizeof( int), hipMemcpyDeviceToHost, stream);
}
auto result = boost::fibers::hip::waitfor_all( stream);
Expand Down
4 changes: 0 additions & 4 deletions include/boost/fiber/cuda/waitfor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@

#include <initializer_list>
#include <mutex>
#include <iostream>
#include <set>
#include <tuple>
#include <vector>

#include <boost/assert.hpp>
#include <boost/config.hpp>

#include <cuda_runtime_api.h>

#include <boost/fiber/detail/config.hpp>
Expand Down
12 changes: 4 additions & 8 deletions include/boost/fiber/hip/waitfor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_FIBERS_CUDA_WAITFOR_H
#define BOOST_FIBERS_CUDA_WAITFOR_H
#ifndef BOOST_FIBERS_HIP_WAITFOR_H
#define BOOST_FIBERS_HIP_WAITFOR_H

#include <initializer_list>
#include <mutex>
#include <iostream>
#include <set>
#include <tuple>
#include <vector>

#include <boost/assert.hpp>
#include <boost/config.hpp>

#include <hip/hip_runtime.h>

#include <boost/fiber/detail/config.hpp>
Expand All @@ -30,7 +26,7 @@

namespace boost {
namespace fibers {
namespace cuda {
namespace hip {
namespace detail {

template< typename Rendezvous >
Expand Down Expand Up @@ -136,4 +132,4 @@ std::vector< std::tuple< hipStream_t, hipError_t > > waitfor_all( hipStream_t st
# include BOOST_ABI_SUFFIX
#endif

#endif // BOOST_FIBERS_CUDA_WAITFOR_H
#endif // BOOST_FIBERS_HIP_WAITFOR_H