Skip to content

Commit 4081606

Browse files
michalkielannilfm99
authored andcommitted
Fix cuda build errors
1 parent 6280b59 commit 4081606

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

libvmaf/src/cuda/picture_cuda.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "picture_cuda.h"
2323
#include "common.h"
2424
#include "log.h"
25+
#include "ref.h"
2526

2627
#include <cuda.h>
2728
#include <errno.h>
@@ -41,7 +42,7 @@ int vmaf_cuda_picture_download_async(VmafPicture *cuda_pic, VmafPicture *pic,
4142

4243
VmafPicturePrivate *cuda_priv = cuda_pic->priv;
4344
for (int i = 0; i < 3; i++) {
44-
m.srcDevice = cuda_pic->data[i];
45+
m.srcDevice = (CUdeviceptr)cuda_pic->data[i];
4546
m.srcPitch = cuda_pic->stride[i];
4647
m.dstHost = pic->data[i];
4748
m.dstPitch = pic->stride[i];
@@ -68,7 +69,7 @@ int vmaf_cuda_picture_upload_async(VmafPicture *cuda_pic,
6869
for (int i = 0; i < 3; i++) {
6970
m.srcHost = pic->data[i];
7071
m.srcPitch = pic->stride[i];
71-
m.dstDevice = cuda_pic->data[i];
72+
m.dstDevice = (CUdeviceptr)cuda_pic->data[i];
7273
m.dstPitch = cuda_pic->stride[i];
7374
m.WidthInBytes = cuda_pic->w[i] * ((pic->bpc + 7) / 8);
7475
m.Height = cuda_pic->h[i];
@@ -84,6 +85,7 @@ int vmaf_cuda_picture_upload_async(VmafPicture *cuda_pic,
8485

8586
static int default_release_pinned_picture(VmafPicture *pic, void *cookie)
8687
{
88+
(void)cookie;
8789
if (!pic) return -EINVAL;
8890

8991
VmafPicturePrivate* priv = pic->priv;
@@ -197,7 +199,7 @@ int vmaf_cuda_picture_alloc(VmafPicture *pic, void *cookie)
197199
pic->data[1] = pic->data[2] = NULL;
198200
break;
199201
}
200-
CHECK_CUDA(cuMemAllocPitch(&pic->data[i], &pic->stride[i],
202+
CHECK_CUDA(cuMemAllocPitch((CUdeviceptr*)&pic->data[i], &pic->stride[i],
201203
pic->w[i] * ((pic->bpc + 7) / 8), pic->h[i],
202204
8 << hbd));
203205
}
@@ -223,7 +225,7 @@ int vmaf_cuda_picture_free(VmafPicture *pic, void *cookie)
223225

224226
for (int i = 0; i < 3; i++) {
225227
if (pic->data[i])
226-
CHECK_CUDA(cuMemFreeAsync(pic->data[i], priv->cuda.str));
228+
CHECK_CUDA(cuMemFreeAsync((CUdeviceptr)pic->data[i], priv->cuda.str));
227229
}
228230

229231
CHECK_CUDA(cuEventDestroy(priv->cuda.finished));

libvmaf/src/feature/cuda/integer_adm_cuda.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -838,14 +838,14 @@ static void integer_compute_adm_cuda(VmafFeatureExtractor *fex, AdmStateCuda *s,
838838
// consumes reference picture
839839
// produces buf->ref_dwt2, buf->dis_dwt2
840840
if (ref_pic->bpc == 8) {
841-
dwt2_8_device(s, (const uint8_t*)ref_pic->data[0], &buf->ref_dwt2, buf->i4_ref_dwt2, (int16_t*)buf->tmp_ref->data, buf, w, h, curr_ref_stride, buf_stride, &p, vmaf_cuda_picture_get_stream(ref_pic));
841+
dwt2_8_device(s, (const uint8_t*)ref_pic->data[0], &buf->ref_dwt2, buf->i4_ref_dwt2, (short2*)buf->tmp_ref->data, buf, w, h, curr_ref_stride, buf_stride, &p, vmaf_cuda_picture_get_stream(ref_pic));
842842

843-
dwt2_8_device(s, (const uint8_t*)dis_pic->data[0], &buf->dis_dwt2, buf->i4_dis_dwt2, (int16_t*)buf->tmp_dis->data, buf, w, h, curr_dis_stride, buf_stride, &p, vmaf_cuda_picture_get_stream(dis_pic));
843+
dwt2_8_device(s, (const uint8_t*)dis_pic->data[0], &buf->dis_dwt2, buf->i4_dis_dwt2, (short2*)buf->tmp_dis->data, buf, w, h, curr_dis_stride, buf_stride, &p, vmaf_cuda_picture_get_stream(dis_pic));
844844
}
845845
else {
846-
adm_dwt2_16_device(s,(uint16_t*)ref_pic->data[0], &buf->ref_dwt2, buf->i4_ref_dwt2, (int16_t*)buf->tmp_ref->data, buf, w, h, curr_ref_stride, buf_stride, ref_pic->bpc, &p, vmaf_cuda_picture_get_stream(ref_pic));
846+
adm_dwt2_16_device(s,(uint16_t*)ref_pic->data[0], &buf->ref_dwt2, buf->i4_ref_dwt2, (short2*)buf->tmp_ref->data, buf, w, h, curr_ref_stride, buf_stride, ref_pic->bpc, &p, vmaf_cuda_picture_get_stream(ref_pic));
847847

848-
adm_dwt2_16_device(s,(uint16_t*)dis_pic->data[0], &buf->dis_dwt2, buf->i4_dis_dwt2, (int16_t*)buf->tmp_dis->data, buf, w, h, curr_dis_stride, buf_stride, dis_pic->bpc, &p, vmaf_cuda_picture_get_stream(dis_pic));
848+
adm_dwt2_16_device(s,(uint16_t*)dis_pic->data[0], &buf->dis_dwt2, buf->i4_dis_dwt2, (short2*)buf->tmp_dis->data, buf, w, h, curr_dis_stride, buf_stride, dis_pic->bpc, &p, vmaf_cuda_picture_get_stream(dis_pic));
849849

850850
}
851851
CHECK_CUDA(cuEventRecord(s->ref_event, vmaf_cuda_picture_get_stream(ref_pic)));

libvmaf/src/feature/cuda/integer_motion_cuda.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static int init_fex_cuda(VmafFeatureExtractor *fex, enum VmafPixelFormat pix_fmt
173173
if (ret) goto free_ref;
174174
ret |= vmaf_cuda_buffer_alloc(fex->cu_state, &s->sad, sizeof(uint64_t));
175175
if (ret) goto free_ref;
176-
ret |= vmaf_cuda_buffer_host_alloc(fex->cu_state, &s->sad_host, sizeof(uint64_t));
176+
ret |= vmaf_cuda_buffer_host_alloc(fex->cu_state, (void**)&s->sad_host, sizeof(uint64_t));
177177
if (ret) goto free_ref;
178178

179179
s->feature_name_dict =
@@ -315,7 +315,7 @@ static int extract_fex_cuda(VmafFeatureExtractor *fex, VmafPicture *ref_pic,
315315
params->h = ref_pic->h[0];
316316
params->w = ref_pic->w[0];
317317
params->index = index;
318-
CHECK_CUDA(cuLaunchHostFunc(s->host_stream, write_scores, s->write_score_parameters));
318+
CHECK_CUDA(cuLaunchHostFunc(s->host_stream, (CUhostFn)write_scores, s->write_score_parameters));
319319
return 0;
320320
}
321321

libvmaf/src/feature/cuda/integer_vif_cuda.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -159,27 +159,27 @@ static int init_fex_cuda(VmafFeatureExtractor *fex, enum VmafPixelFormat pix_fmt
159159

160160
s->buf.ref = data; data += frame_size;
161161
s->buf.dis = data; data += frame_size;
162-
s->buf.mu1 = data; data += h * s->buf.stride_16;
163-
s->buf.mu2 = data; data += h * s->buf.stride_16;
164-
s->buf.mu1_32 = data; data += h * s->buf.stride_32;
165-
s->buf.mu2_32 = data; data += h * s->buf.stride_32;
166-
s->buf.ref_sq = data; data += h * s->buf.stride_32;
167-
s->buf.dis_sq = data; data += h * s->buf.stride_32;
168-
s->buf.ref_dis = data; data += h * s->buf.stride_32;
169-
s->buf.tmp.mu1 = data; data += s->buf.stride_tmp * h;
170-
s->buf.tmp.mu2 = data; data += s->buf.stride_tmp * h;
171-
s->buf.tmp.ref = data; data += s->buf.stride_tmp * h;
172-
s->buf.tmp.dis = data; data += s->buf.stride_tmp * h;
173-
s->buf.tmp.ref_dis = data; data += s->buf.stride_tmp * h;
174-
s->buf.tmp.ref_convol = data; data += s->buf.stride_tmp * h;
175-
s->buf.tmp.dis_convol = data; data += s->buf.stride_tmp * h;
176-
s->buf.tmp.padding = data; data += s->buf.stride_tmp * h;
162+
s->buf.mu1 = (uint16_t*)data; data += h * s->buf.stride_16;
163+
s->buf.mu2 = (uint16_t*)data; data += h * s->buf.stride_16;
164+
s->buf.mu1_32 = (uint32_t*)data; data += h * s->buf.stride_32;
165+
s->buf.mu2_32 = (uint32_t*)data; data += h * s->buf.stride_32;
166+
s->buf.ref_sq = (uint32_t*)data; data += h * s->buf.stride_32;
167+
s->buf.dis_sq = (uint32_t*)data; data += h * s->buf.stride_32;
168+
s->buf.ref_dis = (uint32_t*)data; data += h * s->buf.stride_32;
169+
s->buf.tmp.mu1 = (uint32_t*)data; data += s->buf.stride_tmp * h;
170+
s->buf.tmp.mu2 = (uint32_t*)data; data += s->buf.stride_tmp * h;
171+
s->buf.tmp.ref = (uint32_t*)data; data += s->buf.stride_tmp * h;
172+
s->buf.tmp.dis = (uint32_t*)data; data += s->buf.stride_tmp * h;
173+
s->buf.tmp.ref_dis = (uint32_t*)data; data += s->buf.stride_tmp * h;
174+
s->buf.tmp.ref_convol = (uint32_t*)data; data += s->buf.stride_tmp * h;
175+
s->buf.tmp.dis_convol = (uint32_t*)data; data += s->buf.stride_tmp * h;
176+
s->buf.tmp.padding = (uint32_t*)data; data += s->buf.stride_tmp * h;
177177

178178
CUdeviceptr data_accum;
179179
ret = vmaf_cuda_buffer_get_dptr(s->buf.accum_data, &data_accum);
180180
if (ret) goto free_ref;
181181

182-
s->buf.accum = data_accum;
182+
s->buf.accum = (uint64_t*)data_accum;
183183

184184
s->buf.cpu_param_buf = malloc(sizeof(write_score_parameters_vif));
185185
write_score_parameters_vif *data_p = s->buf.cpu_param_buf;
@@ -496,7 +496,7 @@ static int extract_fex_cuda(VmafFeatureExtractor *fex,
496496
write_score_parameters_vif *data = s->buf.cpu_param_buf;
497497
data->feature_collector = feature_collector;
498498
data->index = index;
499-
CHECK_CUDA(cuLaunchHostFunc(s->str, write_scores, data));
499+
CHECK_CUDA(cuLaunchHostFunc(s->str, (CUhostFn)write_scores, data));
500500
return 0;
501501
}
502502

0 commit comments

Comments
 (0)