Skip to content

Commit

Permalink
DBM: Avoid zero-sized GPU memory allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Mar 20, 2023
1 parent 5d1502a commit 5e5e632
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/dbm/dbm_multiply_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ void dbm_multiply_gpu_start(const int max_batch_size, const int nshards,
ctx->shards_c_dev =
(dbm_shard_gpu_t *)malloc(nshards * sizeof(dbm_shard_gpu_t));
for (int i = 0; i < nshards; i++) {
offloadStreamCreate(&ctx->shards_c_dev[i].stream);
ctx->shards_c_dev[i].data_size = ctx->shards_c_host[i].data_size;
ctx->shards_c_dev[i].data_allocated = ctx->shards_c_dev[i].data_size;
const size_t size = ctx->shards_c_dev[i].data_allocated * sizeof(double);
ctx->shards_c_dev[i].data = (double *)dbm_mempool_device_malloc(size);
offloadMemcpyAsyncHtoD(ctx->shards_c_dev[i].data,
ctx->shards_c_host[i].data, size,
ctx->shards_c_dev[i].stream);
const dbm_shard_t *shard_c_host = &ctx->shards_c_host[i];
dbm_shard_gpu_t *shard_c_dev = &ctx->shards_c_dev[i];
offloadStreamCreate(&shard_c_dev->stream);
shard_c_dev->data_size = shard_c_host->data_size;
shard_c_dev->data_allocated = shard_c_host->data_allocated;
shard_c_dev->data = (double *)dbm_mempool_device_malloc(
shard_c_dev->data_allocated * sizeof(double));
offloadMemcpyAsyncHtoD(shard_c_dev->data, shard_c_host->data,
shard_c_dev->data_size * sizeof(double),
shard_c_dev->stream);
}
}

Expand Down

0 comments on commit 5e5e632

Please sign in to comment.