More error checks

This commit is contained in:
jpekkila
2019-10-07 17:00:23 +03:00
parent 48c6174319
commit 66cfcefb34
2 changed files with 10 additions and 7 deletions

View File

@@ -417,7 +417,7 @@ acDeviceSwapBuffers(const Device device)
AcResult AcResult
acDeviceLoadScalarUniform(const Device device, const Stream stream, const AcRealParam param, acDeviceLoadScalarUniform(const Device device, const Stream stream, const AcRealParam param,
const AcReal value) const AcReal value)
{ {
cudaSetDevice(device->id); cudaSetDevice(device->id);
const size_t offset = (size_t)&d_mesh_info.real_params[param] - (size_t)&d_mesh_info; const size_t offset = (size_t)&d_mesh_info.real_params[param] - (size_t)&d_mesh_info;
@@ -428,7 +428,7 @@ acDeviceLoadScalarUniform(const Device device, const Stream stream, const AcReal
AcResult AcResult
acDeviceLoadVectorUniform(const Device device, const Stream stream, const AcReal3Param param, acDeviceLoadVectorUniform(const Device device, const Stream stream, const AcReal3Param param,
const AcReal3 value) const AcReal3 value)
{ {
cudaSetDevice(device->id); cudaSetDevice(device->id);
const size_t offset = (size_t)&d_mesh_info.real3_params[param] - (size_t)&d_mesh_info; const size_t offset = (size_t)&d_mesh_info.real3_params[param] - (size_t)&d_mesh_info;
@@ -439,7 +439,7 @@ acDeviceLoadVectorUniform(const Device device, const Stream stream, const AcReal
AcResult AcResult
acDeviceLoadIntUniform(const Device device, const Stream stream, const AcIntParam param, acDeviceLoadIntUniform(const Device device, const Stream stream, const AcIntParam param,
const int value) const int value)
{ {
cudaSetDevice(device->id); cudaSetDevice(device->id);
const size_t offset = (size_t)&d_mesh_info.int_params[param] - (size_t)&d_mesh_info; const size_t offset = (size_t)&d_mesh_info.int_params[param] - (size_t)&d_mesh_info;
@@ -450,7 +450,7 @@ acDeviceLoadIntUniform(const Device device, const Stream stream, const AcIntPara
AcResult AcResult
acDeviceLoadInt3Uniform(const Device device, const Stream stream, const AcInt3Param param, acDeviceLoadInt3Uniform(const Device device, const Stream stream, const AcInt3Param param,
const int3 value) const int3 value)
{ {
cudaSetDevice(device->id); cudaSetDevice(device->id);
const size_t offset = (size_t)&d_mesh_info.int3_params[param] - (size_t)&d_mesh_info; const size_t offset = (size_t)&d_mesh_info.int3_params[param] - (size_t)&d_mesh_info;
@@ -465,9 +465,9 @@ acDeviceLoadScalarArray(const Device device, const Stream stream, const ScalarAr
{ {
cudaSetDevice(device->id); cudaSetDevice(device->id);
ERRCHK(start + num <= max(device->local_config.int_params[AC_mx], ERRCHK((int)(start + num) <= max(device->local_config.int_params[AC_mx],
max(device->local_config.int_params[AC_my], max(device->local_config.int_params[AC_my],
device->local_config.int_params[AC_mz]))); device->local_config.int_params[AC_mz])));
ERRCHK_CUDA(cudaMemcpyAsync(&device->vba.profiles[handle][start], data, sizeof(data[0]) * num, ERRCHK_CUDA(cudaMemcpyAsync(&device->vba.profiles[handle][start], data, sizeof(data[0]) * num,
cudaMemcpyHostToDevice, device->streams[stream])); cudaMemcpyHostToDevice, device->streams[stream]));

View File

@@ -29,6 +29,9 @@
#include <assert.h> #include <assert.h>
static_assert(NUM_VTXBUF_HANDLES > 0,
"ERROR: NUM_VTXBUF_HANDLES (uniform ScalarFields) must be > 0");
static __device__ constexpr int static __device__ constexpr int
IDX(const int i) IDX(const int i)
{ {