Commit b5f3aaa6 authored by Cianciosa, Mark's avatar Cianciosa, Mark
Browse files

Merge branch 'hot_plasma' into 'main'

Separate out cuda init and max_concurrency and make these static methods to...

See merge request !15
parents d108a547 f0cdc3c0
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -108,11 +108,11 @@ register_sanitizer_option (float-divide-by-zero ON)

target_compile_options (sanitizer
                        INTERFACE
                        $<$<CONFIG:Sanitized>:-fsanitize-trap=all>
                        $<$<AND:$<CONFIG:Sanitized>,$<PLATFORM_ID:Darwin>>:-fsanitize-trap=all>
)
target_link_options (sanitizer
                     INTERFACE
                     $<$<CONFIG:Sanitized>:-fsanitize-trap=all>
                     $<$<AND:$<CONFIG:Sanitized>,$<PLATFORM_ID:Darwin>>:-fsanitize-trap=all>
)

#-------------------------------------------------------------------------------
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ int main(int argc, const char * argv[]) {
    const size_t num_steps = num_times/sub_steps;
    const size_t num_rays = 100000;

    std::vector<std::thread> threads(std::max(std::min(static_cast<unsigned int> (jit::context<base, use_safe_math>::max_concurrency),
    std::vector<std::thread> threads(std::max(std::min(static_cast<unsigned int> (jit::context<base, use_safe_math>::max_concurrency()),
                                                       static_cast<unsigned int> (num_rays)),
                                              static_cast<unsigned int> (1)));

+8 −4
Original line number Diff line number Diff line
@@ -16,8 +16,12 @@
#include "node.hpp"

namespace gpu {
//  Initialize the cuda driver.
    static const CUresult init = cuInit(0);
//------------------------------------------------------------------------------
///   @brief Initalize cuda.
//------------------------------------------------------------------------------
    static void init() {
        cuInit(0);
    }

//------------------------------------------------------------------------------
///  @brief Class representing a cuda gpu context.
@@ -74,7 +78,7 @@ namespace gpu {
///  @params[in] result Result code of the operation.
///  @params[in] name   Name of the operation.
//------------------------------------------------------------------------------
        static void check_error_async(CUresult result,
        void check_error_async(CUresult result,
                               const std::string &name) {
            check_error(result, name);
#ifndef NDEBUG
+20 −2
Original line number Diff line number Diff line
@@ -18,12 +18,24 @@
#ifdef USE_METAL
#define START_GPU @autoreleasepool {
#define END_GPU }
#elif defined (USE_CUDA)
#define START_GPU jit::init();
#define END_GPU
#else
#define START_GPU
#define END_GPU
#endif

namespace jit {
//------------------------------------------------------------------------------
///   @brief Initalize the gpu\_context.
//------------------------------------------------------------------------------
    static void init() {
#ifdef USE_CUDA
        gpu::init();
#endif
    }

//------------------------------------------------------------------------------
///  @brief Class for JIT compile of the GPU kernels.
//------------------------------------------------------------------------------
@@ -52,8 +64,14 @@ namespace jit {
        gpu_context_type gpu_context;

    public:
///  The maximum available concurrency.
        static inline size_t max_concurrency = gpu_context_type::max_concurrency();
//------------------------------------------------------------------------------
///  @brief Get the maximum number of concurrent instances.
///
///  @returns The maximum available concurrency.
//------------------------------------------------------------------------------
        static size_t max_concurrency() {
            return gpu_context_type::max_concurrency();
        }

//------------------------------------------------------------------------------
///  @brief Construct a jit context object.