<commit_before>// Copyright (c) 2013-2016 <NAME>, <NAME>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that 
// the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 
//    following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions 
//    and the following disclaimer in the documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/** \file gpu.h
 *   
 *  \brief Interface to CUDA related functions.
 */

#include <complex>

#ifndef __GPU_H__
#define __GPU_H__

typedef std::complex<double> cuDoubleComplex;

/* cufftHandle is a handle type used to store and access CUFFT plans. */
typedef int cufftHandle;

extern "C" {

void cuda_initialize();

void cuda_device_info();

void* cuda_malloc(size_t size);

void cuda_free(void* ptr);

void* cuda_malloc_host(size_t size);

void cuda_free_host(void* ptr);

void cuda_memset(void *ptr, int value, size_t size);

void cuda_host_register(void* ptr, size_t size);

void cuda_host_unregister(void* ptr);

void cuda_device_synchronize();

void cuda_create_streams(int num_streams);

void cuda_destroy_streams();

int get_num_cuda_streams();

void cuda_stream_synchronize(int stream_id);

void cuda_copy_to_device(void* target, void const* source, size_t size);
void cuda_async_copy_to_device(void* target, void const* source, size_t size, int stream_id);
void cuda_copy2d_to_device(void* dst__, size_t ld1__, const void* src__, size_t ld2__, size_t nrow__,
                           size_t ncol__, int elem_size__);
void cuda_async_copy2d_to_device(void* dst__, size_t ld1__, const void* src__, size_t ld2__,
                                 size_t nrow__, size_t ncol__, int elem_size__, int stream_id__);

void cuda_copy_to_host(void* target, void const* source, size_t size);
void cuda_async_copy_to_host(void* target, void const* source, size_t size, int stream_id);
void cuda_copy2d_to_host(void* dst__, size_t ld1__, const void* src__, size_t ld2__, size_t nrow__, 
                         size_t ncol__, int elem_size__);
void cuda_async_copy2d_to_host(void* dst__, size_t ld1__, const void* src__, size_t ld2__,
                               size_t nrow__, size_t ncol__, int elem_size__, int stream_id__);

void cuda_copy_device_to_device(void* target, void const* source, size_t size);
void cuda_copy2d_device_to_device(void* dst__, size_t ld1__, const void* src__, size_t ld2__,
                                  size_t nrow__, size_t ncol__, int elem_size__);
void cuda_async_copy2d_device_to_device(void* dst__, size_t ld1__, const void* src__, size_t ld2__, size_t nrow__,
                                        size_t ncol__, int elem_size__, int stream_id__);

size_t cuda_get_free_mem();

void cuda_device_reset();

void cuda_check_last_error();

bool cuda_check_device_ptr(void const* ptr__);

void cuda_memset2d(void* ptr__, int ld__, int nrow__, int ncol__, int elem_size__, int value__);

#ifdef __GPU_NVTX
void cuda_begin_range_marker(const char* label__);

void cuda_end_range_marker();
#endif

void cublas_zgemm(int transa, int transb, int32_t m, int32_t n, int32_t k, 
                  cuDoubleComplex const* alpha, cuDoubleComplex const* a, int32_t lda, cuDoubleComplex const* b, 
                  int32_t ldb, cuDoubleComplex const* beta, cuDoubleComplex* c, int32_t ldc, int stream_id);

void cublas_dgemm(int transa, int transb, int32_t m, int32_t n, int32_t k, 
                  double const* alpha, double const* a, int32_t lda, double const* b, 
                  int32_t ldb, double const* beta, double* c, int32_t ldc, int stream_id);

void cublas_dtrmm(char side__, char uplo__, char transa__, char diag__, int m__, int n__,
                  double const* alpha__, double* A__, int lda__, double* B__, int ldb__);

void cublas_ztrmm(char side__, char uplo__, char transa__, char diag__, int m__, int n__,
                  cuDoubleComplex const* alpha__, cuDoubleComplex* A__, int lda__, cuDoubleComplex* B__, int ldb__);

void cublas_create_handles(int num_handles);

void cublas_destroy_handles(int num_handles);

void cublas_zgemv(int transa, int32_t m, int32_t n, cuDoubleComplex const* alpha, cuDoubleComplex* a, int32_t lda, 
                  cuDoubleComplex* x, int32_t incx, cuDoubleComplex const* beta, cuDoubleComplex* y, int32_t incy, 
                  int stream_id);

void cublas_zaxpy(int n__,
                  cuDoubleComplex const* alpha__,
                  cuDoubleComplex const* x__,
                  int incx__,
                  cuDoubleComplex* y__,<commit_msg>move function declarations to a separate header<commit_after>// Copyright (c) 2013-2016 <NAME>, <NAME>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that 
// the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 
//    following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions 
//    and the following disclaimer in the documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/** \file gpu.h
 *   
 *  \brief Interface to CUDA related functions.
 */

#include <complex>
#include "GPU/cuda_interface.h"

#ifndef __GPU_H__
#define __GPU_H__

typedef std::complex<double> cuDoubleComplex;

/* cufftHandle is a handle type used to store and access CUFFT plans. */
typedef int cufftHandle;

extern "C" {

void cublas_zgemm(int transa, int transb, int32_t m, int32_t n, int32_t k, 
                  cuDoubleComplex const* alpha, cuDoubleComplex const* a, int32_t lda, cuDoubleComplex const* b, 
                  int32_t ldb, cuDoubleComplex const* beta, cuDoubleComplex* c, int32_t ldc, int stream_id);

void cublas_dgemm(int transa, int transb, int32_t m, int32_t n, int32_t k, 
                  double const* alpha, double const* a, int32_t lda, double const* b, 
                  int32_t ldb, double const* beta, double* c, int32_t ldc, int stream_id);

void cublas_dtrmm(char side__, char uplo__, char transa__, char diag__, int m__, int n__,
                  double const* alpha__, double* A__, int lda__, double* B__, int ldb__);

void cublas_ztrmm(char side__, char uplo__, char transa__, char diag__, int m__, int n__,
                  cuDoubleComplex const* alpha__, cuDoubleComplex* A__, int lda__, cuDoubleComplex* B__, int ldb__);

void cublas_create_handles(int num_handles);

void cublas_destroy_handles(int num_handles);

void cublas_zgemv(int transa, int32_t m, int32_t n, cuDoubleComplex const* alpha, cuDoubleComplex* a, int32_t lda, 
                  cuDoubleComplex* x, int32_t incx, cuDoubleComplex const* beta, cuDoubleComplex* y, int32_t incy, 
                  int stream_id);

void cublas_zaxpy(int n__,
                  cuDoubleComplex const* alpha__,
                  cuDoubleComplex const* x__,
                  int incx__,
                  cuDoubleComplex* y__,
{'fraction_non_alphanumeric': 0.07279780921953447, 'fraction_numerical': 0.012209036969420356, 'mean_word_length': 3.630216587427364, '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': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3657278', 'n_tokens_mistral': 2808, 'n_tokens_neox': 2614, 'n_words': 1004}