Skip to content

Commit

Permalink
fix boost::core::swap
Browse files Browse the repository at this point in the history
fix ComputationalRadiationPhysics#2714

Boost is shipping there swap implementation with support for the device side
if `BOOST_GPU_ENABLED` is `__host__ __device__` but is calling a pure host function `std::swap`
within the device code. Even if swap is not called on the device this implementation
can pull host only code inside the device compile path of CUDA.

- provide a device side empty implementation for swap if the arguments are `std:.string`
  • Loading branch information
psychocoderHPC authored and steindev committed Oct 16, 2018
1 parent f0378f0 commit cff54ee
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/picongpu/plugins/ResourceLog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@
#include <stdlib.h> /* itoa */
#include <stdint.h> /* uint32_t */

/* provide a specialization of swap for std::string
*
* workaround for: https://github.com/ComputationalRadiationPhysics/picongpu/issues/2714
* Boost is shipping a swap implementation with support for device
* if `BOOST_GPU_ENABLED` is `__host__ __device__` but is calling a pure host function `std::swap`
* within the device code. Even if swap is not called on the device this implementation
* can pull host only code inside the device compile path of CUDA.
*/
namespace boost_swap_impl
{
BOOST_GPU_ENABLED
void swap(std::string& s1, std::string& s2)
{
#ifndef __CUDA_ARCH__
std::swap(s1, s2);
#endif
}
}

namespace picongpu
{
using namespace pmacc;
Expand Down

0 comments on commit cff54ee

Please sign in to comment.