Simple GPU 1.0
Fortran GPU Computing Library with transparent CPU/GPU support
Loading...
Searching...
No Matches
gpu_cpu.c File Reference
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
+ Include dependency graph for gpu_cpu.c:

Go to the source code of this file.

Functions

int gpu_ndevices ()
 
void gpu_set_device (int32_t i)
 
void gpu_get_memory (size_t *free, size_t *total)
 
void gpu_allocate (void **ptr, const int64_t n)
 
void gpu_deallocate (void **ptr)
 
void gpu_free (void **ptr)
 
void gpu_upload (const void *cpu_ptr, void *gpu_ptr, const int64_t n)
 
void gpu_download (const void *gpu_ptr, void *cpu_ptr, const int64_t n)
 
void gpu_copy (const void *gpu_ptr_src, void *gpu_ptr_dest, const int64_t n)
 
void gpu_stream_create (void **ptr)
 
void gpu_stream_destroy (void **ptr)
 
void gpu_set_stream (void *handle, void *stream)
 
void gpu_synchronize ()
 
void gpu_stream_synchronize (void *stream)
 
static bool check_int32_overflow (int64_t value, const char *name)
 Check if an int64_t value can be safely converted to int32_t.
 
void gpu_blas_create (void **handle)
 
void gpu_blas_destroy (void **handle)
 
double ddot_ (const int32_t *n, const double *x, const int32_t *incx, const double *y, const int32_t *incy)
 
void gpu_ddot (void *handle, const int64_t n, const double *x, const int64_t incx, const double *y, const int64_t incy, double *result)
 
float sdot_ (const int32_t *n, const float *x, const int32_t *incx, const float *y, const int32_t *incy)
 
void gpu_sdot (void *handle, const int64_t n, const float *x, const int64_t incx, const float *y, const int64_t incy, float *result)
 
void dgemv_ (const char *transa, const int32_t *m, const int32_t *n, const double *alpha, const double *a, const int32_t *lda, const double *x, const int32_t *incx, const double *beta, double *y, const int32_t *incy)
 
void gpu_dgemv (void *handle, const char *transa, const int64_t m, const int64_t n, const double *alpha, const double *a, const int64_t lda, const double *x, const int64_t incx, const double *beta, double *y, const int64_t incy)
 
void sgemv_ (const char *transa, const int32_t *m, const int32_t *n, const float *alpha, const float *a, const int32_t *lda, const float *x, const int32_t *incx, const float *beta, float *y, const int32_t *incy)
 
void gpu_sgemv (void *handle, const char *transa, const int64_t m, const int64_t n, const float *alpha, const float *a, const int64_t lda, const float *x, const int64_t incx, const float *beta, float *y, const int64_t incy)
 
void dgemm_ (const char *transa, const char *transb, const int32_t *m, const int32_t *n, const int32_t *k, const double *alpha, const double *a, const int32_t *lda, const double *b, const int32_t *ldb, const double *beta, double *c, const int32_t *ldc)
 
void gpu_dgemm (void *handle, const char *transa, const char *transb, const int64_t m, const int64_t n, const int64_t k, const double *alpha, const double *a, const int64_t lda, const double *b, const int64_t ldb, const double *beta, double *c, const int64_t ldc)
 
void sgemm_ (const char *transa, const char *transb, const int32_t *m, const int32_t *n, const int32_t *k, const float *alpha, const float *a, const int32_t *lda, const float *b, const int32_t *ldb, const float *beta, float *c, const int32_t *ldc)
 
void gpu_sgemm (void *handle, const char *transa, const char *transb, const int64_t m, const int64_t n, const int64_t k, const float *alpha, const float *a, const int64_t lda, const float *b, const int64_t ldb, const float *beta, float *c, const int64_t ldc)
 
void gpu_dgeam (void *handle, const char *transa, const char *transb, const int64_t m, const int64_t n, const double *alpha, const double *a, const int64_t lda, const double *beta, const double *b, const int64_t ldb, double *c, const int64_t ldc)
 
void gpu_sgeam (void *handle, const char *transa, const char *transb, const int64_t m, const int64_t n, const float *alpha, const float *a, const int64_t lda, const float *beta, const float *b, const int64_t ldb, float *c, const int64_t ldc)
 

Function Documentation

◆ check_int32_overflow()

static bool check_int32_overflow ( int64_t  value,
const char *  name 
)
inlinestatic

Check if an int64_t value can be safely converted to int32_t.

Parameters
valueThe int64_t value to check
nameThe name of the parameter (for error messages)
Returns
true if overflow would occur, false otherwise

Definition at line 110 of file gpu_cpu.c.

+ Here is the caller graph for this function:

◆ ddot_()

double ddot_ ( const int32_t *  n,
const double *  x,
const int32_t *  incx,
const double *  y,
const int32_t *  incy 
)
+ Here is the caller graph for this function:

◆ dgemm_()

void dgemm_ ( const char *  transa,
const char *  transb,
const int32_t *  m,
const int32_t *  n,
const int32_t *  k,
const double *  alpha,
const double *  a,
const int32_t *  lda,
const double *  b,
const int32_t *  ldb,
const double *  beta,
double *  c,
const int32_t *  ldc 
)
+ Here is the caller graph for this function:

◆ dgemv_()

void dgemv_ ( const char *  transa,
const int32_t *  m,
const int32_t *  n,
const double *  alpha,
const double *  a,
const int32_t *  lda,
const double *  x,
const int32_t *  incx,
const double *  beta,
double *  y,
const int32_t *  incy 
)
+ Here is the caller graph for this function:

◆ gpu_allocate()

void gpu_allocate ( void **  ptr,
const int64_t  n 
)

Definition at line 26 of file gpu_cpu.c.

◆ gpu_blas_create()

void gpu_blas_create ( void **  handle)

Definition at line 118 of file gpu_cpu.c.

◆ gpu_blas_destroy()

void gpu_blas_destroy ( void **  handle)

Definition at line 123 of file gpu_cpu.c.

◆ gpu_copy()

void gpu_copy ( const void *  gpu_ptr_src,
void *  gpu_ptr_dest,
const int64_t  n 
)

Definition at line 69 of file gpu_cpu.c.

◆ gpu_ddot()

void gpu_ddot ( void *  handle,
const int64_t  n,
const double *  x,
const int64_t  incx,
const double *  y,
const int64_t  incy,
double *  result 
)

Definition at line 131 of file gpu_cpu.c.

+ Here is the call graph for this function:

◆ gpu_deallocate()

void gpu_deallocate ( void **  ptr)

Definition at line 38 of file gpu_cpu.c.

+ Here is the caller graph for this function:

◆ gpu_dgeam()

void gpu_dgeam ( void *  handle,
const char *  transa,
const char *  transb,
const int64_t  m,
const int64_t  n,
const double *  alpha,
const double *  a,
const int64_t  lda,
const double *  beta,
const double *  b,
const int64_t  ldb,
double *  c,
const int64_t  ldc 
)

Definition at line 291 of file gpu_cpu.c.

◆ gpu_dgemm()

void gpu_dgemm ( void *  handle,
const char *  transa,
const char *  transb,
const int64_t  m,
const int64_t  n,
const int64_t  k,
const double *  alpha,
const double *  a,
const int64_t  lda,
const double *  b,
const int64_t  ldb,
const double *  beta,
double *  c,
const int64_t  ldc 
)

Definition at line 233 of file gpu_cpu.c.

+ Here is the call graph for this function:

◆ gpu_dgemv()

void gpu_dgemv ( void *  handle,
const char *  transa,
const int64_t  m,
const int64_t  n,
const double *  alpha,
const double *  a,
const int64_t  lda,
const double *  x,
const int64_t  incx,
const double *  beta,
double *  y,
const int64_t  incy 
)

Definition at line 177 of file gpu_cpu.c.

+ Here is the call graph for this function:

◆ gpu_download()

void gpu_download ( const void *  gpu_ptr,
void *  cpu_ptr,
const int64_t  n 
)

Definition at line 61 of file gpu_cpu.c.

◆ gpu_free()

void gpu_free ( void **  ptr)

Definition at line 46 of file gpu_cpu.c.

+ Here is the call graph for this function:

◆ gpu_get_memory()

void gpu_get_memory ( size_t *  free,
size_t *  total 
)

Definition at line 18 of file gpu_cpu.c.

◆ gpu_ndevices()

int gpu_ndevices ( )

Definition at line 10 of file gpu_cpu.c.

◆ gpu_sdot()

void gpu_sdot ( void *  handle,
const int64_t  n,
const float *  x,
const int64_t  incx,
const float *  y,
const int64_t  incy,
float *  result 
)

Definition at line 155 of file gpu_cpu.c.

+ Here is the call graph for this function:

◆ gpu_set_device()

void gpu_set_device ( int32_t  i)

Definition at line 14 of file gpu_cpu.c.

◆ gpu_set_stream()

void gpu_set_stream ( void *  handle,
void *  stream 
)

Definition at line 89 of file gpu_cpu.c.

◆ gpu_sgeam()

void gpu_sgeam ( void *  handle,
const char *  transa,
const char *  transb,
const int64_t  m,
const int64_t  n,
const float *  alpha,
const float *  a,
const int64_t  lda,
const float *  beta,
const float *  b,
const int64_t  ldb,
float *  c,
const int64_t  ldc 
)

Definition at line 423 of file gpu_cpu.c.

◆ gpu_sgemm()

void gpu_sgemm ( void *  handle,
const char *  transa,
const char *  transb,
const int64_t  m,
const int64_t  n,
const int64_t  k,
const float *  alpha,
const float *  a,
const int64_t  lda,
const float *  b,
const int64_t  ldb,
const float *  beta,
float *  c,
const int64_t  ldc 
)

Definition at line 264 of file gpu_cpu.c.

+ Here is the call graph for this function:

◆ gpu_sgemv()

void gpu_sgemv ( void *  handle,
const char *  transa,
const int64_t  m,
const int64_t  n,
const float *  alpha,
const float *  a,
const int64_t  lda,
const float *  x,
const int64_t  incx,
const float *  beta,
float *  y,
const int64_t  incy 
)

Definition at line 205 of file gpu_cpu.c.

+ Here is the call graph for this function:

◆ gpu_stream_create()

void gpu_stream_create ( void **  ptr)

Definition at line 80 of file gpu_cpu.c.

◆ gpu_stream_destroy()

void gpu_stream_destroy ( void **  ptr)

Definition at line 84 of file gpu_cpu.c.

◆ gpu_stream_synchronize()

void gpu_stream_synchronize ( void *  stream)

Definition at line 97 of file gpu_cpu.c.

◆ gpu_synchronize()

void gpu_synchronize ( )

Definition at line 93 of file gpu_cpu.c.

◆ gpu_upload()

void gpu_upload ( const void *  cpu_ptr,
void *  gpu_ptr,
const int64_t  n 
)

Definition at line 53 of file gpu_cpu.c.

◆ sdot_()

float sdot_ ( const int32_t *  n,
const float *  x,
const int32_t *  incx,
const float *  y,
const int32_t *  incy 
)
+ Here is the caller graph for this function:

◆ sgemm_()

void sgemm_ ( const char *  transa,
const char *  transb,
const int32_t *  m,
const int32_t *  n,
const int32_t *  k,
const float *  alpha,
const float *  a,
const int32_t *  lda,
const float *  b,
const int32_t *  ldb,
const float *  beta,
float *  c,
const int32_t *  ldc 
)
+ Here is the caller graph for this function:

◆ sgemv_()

void sgemv_ ( const char *  transa,
const int32_t *  m,
const int32_t *  n,
const float *  alpha,
const float *  a,
const int32_t *  lda,
const float *  x,
const int32_t *  incx,
const float *  beta,
float *  y,
const int32_t *  incy 
)
+ Here is the caller graph for this function: