<commit_before>/*******************************************************
 * Copyright (c) 2019, ArrayFire
 * All rights reserved.
 *
 * This file is distributed under 3-clause BSD license.
 * The complete license agreement can be obtained at:
 * http://arrayfire.com/licenses/BSD-3-Clause
 ********************************************************/
#pragma once

#include <common/EventBase.hpp>
#include <cuda.h>
#include <cuda_runtime_api.h>

namespace cuda {

class CUDARuntimeEventPolicy {
   public:
    using EventType = CUevent;
    using QueueType = CUstream;
    using ErrorType = CUresult;

    static ErrorType createEvent(CUevent *e) noexcept {
      auto err = cuEventCreate(e, CU_EVENT_DISABLE_TIMING | CU_EVENT_BLOCKING_SYNC);
        // printf("create %p: error: %s\n", *e, cudaGetErrorName(err));
        return err;
    }

    static ErrorType markEvent(CUevent *e,
                               QueueType &stream) noexcept {
        auto err = cuEventRecord(*e, stream);
        // printf("mark   %p: error: %s\n", *e, cudaGetErrorName(err));
        return err;
    }

    static ErrorType waitForEvent(CUevent *e,
                                  QueueType &stream) noexcept {
      auto err = cuStreamWaitEvent(stream, *e, 0);
        // printf("wait   %p: error: %s\n", *e, cudaGetErrorName(err));
        return err;
    }

    static ErrorType syncForEvent(CUevent *e) noexcept {
        return cuEventSynchronize(*e);
    }

    static ErrorType destroyEvent(CUevent *e) noexcept {
        auto err = cuEventDestroy(*e);
        // printf("destroy %p: error: %s\n", *e, cudaGetErrorName(err));
        return err;
    }
};

using Event = common::EventBase<CUDARuntimeEventPolicy>;

/// \brief Creates a new event and marks it in the stream
Event make_event(cudaStream_t stream);

}  // namespace cuda<commit_msg>Remove Cuda CreateEvent SYNC flag<commit_after>/*******************************************************
 * Copyright (c) 2019, ArrayFire
 * All rights reserved.
 *
 * This file is distributed under 3-clause BSD license.
 * The complete license agreement can be obtained at:
 * http://arrayfire.com/licenses/BSD-3-Clause
 ********************************************************/
#pragma once

#include <common/EventBase.hpp>
#include <cuda.h>
#include <cuda_runtime_api.h>

namespace cuda {

class CUDARuntimeEventPolicy {
   public:
    using EventType = CUevent;
    using QueueType = CUstream;
    using ErrorType = CUresult;

    static ErrorType createEvent(CUevent *e) noexcept {
        // Creating events with the CU_EVENT_BLOCKING_SYNC flag 
        // severly impacts the speed if/when creating many arrays
        auto err = cuEventCreate(e, CU_EVENT_DISABLE_TIMING);
        return err;
    }

    static ErrorType markEvent(CUevent *e,
                               QueueType &stream) noexcept {
        auto err = cuEventRecord(*e, stream);
        return err;
    }

    static ErrorType waitForEvent(CUevent *e,
                                  QueueType &stream) noexcept {
        auto err = cuStreamWaitEvent(stream, *e, 0);
        return err;
    }

    static ErrorType syncForEvent(CUevent *e) noexcept {
        return cuEventSynchronize(*e);
    }

    static ErrorType destroyEvent(CUevent *e) noexcept {
        auto err = cuEventDestroy(*e);
        return err;
    }
};

using Event = common::EventBase<CUDARuntimeEventPolicy>;

/// \brief Creates a new event and marks it in the stream
Event make_event(cudaStream_t stream);

}  // namespace cuda
{'fraction_non_alphanumeric': 0.15647226173541964, 'fraction_numerical': 0.003982930298719772, 'mean_word_length': 2.9728813559322034, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1974675', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1006, 'n_words': 284}