/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* the research papers on the package. Check out http://www.gromacs.org.
*/
-#include <stdlib.h>
+#include "gmxpre.h"
-#include "gmx_fatal.h"
-#include "smalloc.h"
-#include "typedefs.h"
#include "cudautils.cuh"
+#include <stdlib.h>
+
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/utility/smalloc.h"
+
/*** Generic CUDA data operation wrappers ***/
/*! Launches synchronous or asynchronous host to device memory copy.
*
* The copy is launched in stream s or if not specified, in stream 0.
*/
-static int cu_copy_D2H_generic(void * h_dest, void * d_src, size_t bytes,
+static int cu_copy_D2H_generic(void * h_dest, void * d_src, size_t bytes,
bool bAsync = false, cudaStream_t s = 0)
{
cudaError_t stat;
-
+
if (h_dest == NULL || d_src == NULL || bytes == 0)
+ {
return -1;
+ }
if (bAsync)
{
}
int cu_copy_D2H_alloc(void ** h_dest, void * d_src, size_t bytes)
-{
+{
if (h_dest == NULL || d_src == NULL || bytes == 0)
+ {
return -1;
+ }
smalloc(*h_dest, bytes);
*
* The copy is launched in stream s or if not specified, in stream 0.
*/
-static int cu_copy_H2D_generic(void * d_dest, void * h_src, size_t bytes,
+static int cu_copy_H2D_generic(void * d_dest, void * h_src, size_t bytes,
bool bAsync = false, cudaStream_t s = 0)
{
cudaError_t stat;
if (d_dest == NULL || h_src == NULL || bytes == 0)
+ {
return -1;
+ }
if (bAsync)
{
}
int cu_copy_H2D(void * d_dest, void * h_src, size_t bytes)
-{
+{
return cu_copy_H2D_generic(d_dest, h_src, bytes, false);
}
* The copy is launched in stream s or if not specified, in stream 0.
*/
int cu_copy_H2D_async(void * d_dest, void * h_src, size_t bytes, cudaStream_t s = 0)
-{
+{
return cu_copy_H2D_generic(d_dest, h_src, bytes, true, s);
}
cudaError_t stat;
if (d_dest == NULL || h_src == NULL || bytes == 0)
+ {
return -1;
+ }
stat = cudaMalloc(d_dest, bytes);
CU_RET_ERR(stat, "cudaMalloc failed in cu_copy_H2D_alloc");
float cu_event_elapsed(cudaEvent_t start, cudaEvent_t end)
{
- float t = 0.0;
+ float t = 0.0;
cudaError_t stat;
stat = cudaEventElapsedTime(&t, start, end);
return 0;
}
-/*!
+/*!
* If time != NULL it also calculates the time elapsed between start and end and
* return this is milliseconds.
- */
+ */
int cu_wait_event_time(cudaEvent_t end, cudaEvent_t start, float *time)
{
cudaError_t s;
}
/*!
- * Reallocation of the memory pointed by d_ptr and copying of the data from
- * the location pointed by h_src host-side pointer is done. Allocation is
- * buffered and therefore freeing is only needed if the previously allocated
+ * Reallocation of the memory pointed by d_ptr and copying of the data from
+ * the location pointed by h_src host-side pointer is done. Allocation is
+ * buffered and therefore freeing is only needed if the previously allocated
* space is not enough.
- * The H2D copy is launched in stream s and can be done synchronously or
+ * The H2D copy is launched in stream s and can be done synchronously or
* asynchronously (the default is the latter).
*/
void cu_realloc_buffered(void **d_dest, void *h_src,
return;
}
- /* reallocate only if the data does not fit = allocation size is smaller
+ /* reallocate only if the data does not fit = allocation size is smaller
than the current requested size */
if (req_size > *curr_alloc_size)
{