From patchwork Tue May 8 18:36:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Rothenpieler X-Patchwork-Id: 8881 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp4335289jad; Tue, 8 May 2018 11:37:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp+10VybNpfBaHNmUj7IQRFxaFx8On4tINE9AK28uaMuyiuI7UOHjs5zHutXPGwBpX7292C X-Received: by 2002:a1c:e384:: with SMTP id a126-v6mr4371655wmh.93.1525804638399; Tue, 08 May 2018 11:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525804638; cv=none; d=google.com; s=arc-20160816; b=a//j4z0r837ua0ZC1KSn7vciHNBxO+CsNFBRjWBqdsQNIddNd1uIpnyqpnHDwGK0zW 12Ik57/ifAk38Do27Vrl0Wp9aZEuZIG9QJizpiq9oLOn8l1oRhw6+75F68SnaZ1LmnXq f+5VeFyHB7X4qpoOIn6gxR7uaF5AgqIjZrdyAzD+NQkbMqjhP0EXm5H2zugt1BJufbV7 5hx6+4uUsdTRxtikR021zvvnOcrfkNrCkSH/1VTha2zy5tDfzyFI2WDvn1LtbQISWkru GCotGAcM9bFPYwIkyW4XuFnw+jItiqS8Vl5C2z0yqNH3SPWCwDrzIvxUvsCFxkNeeb6h ht5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=4UJHWSgYgS5pLrqktdffvEADjT6SvPAZ0XjQBOzmwPQ=; b=IcdWZ4T4tX+ngWsE9UwoqRTtPbSdnk23xyhsa5uifAwCoiKH/XjhKzo0/uUdDBs0Is +zE80zKA8frh2UoyOV3QGG6hmaUEbhJTeNET1w33FmhMNS4oobmulO9SHXBzNIYFAORh FG5eZxyqGBzN759ULDI6fk1grEXWCgndZjY9bTgtNneXEsfpHTIrw99bMSNuVDPKBXYV XF3Z+MHEgRE2RZm3k25C04g3/JowJgHYfKb0hODBy9PIBMLm7GCojnaFNJLv7NepwxiV hEDxTjVkaEgp7LIWqhH2Xf5d+nVc3Zj7nLTMooOlb/J6hDtboHzg+pU4uw+kCCxKmZrh SUSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rothenpieler.org header.s=mail header.b=0RY9zcwN; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z3-v6si21996493wrz.413.2018.05.08.11.37.17; Tue, 08 May 2018 11:37:18 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@rothenpieler.org header.s=mail header.b=0RY9zcwN; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A42E568A788; Tue, 8 May 2018 21:36:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from btbn.de (btbn.de [5.9.118.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DB5EC68A743 for ; Tue, 8 May 2018 21:36:10 +0300 (EEST) Received: from localhost.localdomain (200116b864513a00ba975afffe10ec69.dip.versatel-1u1.de [IPv6:2001:16b8:6451:3a00:ba97:5aff:fe10:ec69]) by btbn.de (Postfix) with ESMTPSA id 1FCFD7395E; Tue, 8 May 2018 20:36:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rothenpieler.org; s=mail; t=1525804606; bh=wx4MVLfgRaukSKfDfI57kxEefQBnRc7cC12B6PYgImU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0RY9zcwNplBdPaSadjtbkAePBNCc3LE4f+YFP6qoJ86T+2d2JJi4n3pYn7DgSCMvW zTff6Z04Qmwo8uc1K8xa71Q+ZezgRlFEb+zhw8VZMUEQgZolOuntqLGshR5YImqErI 2CfTd5pb5t+RavTug4h5M2Od2RV9hS30ottzNwlk= From: Timo Rothenpieler To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 May 2018 20:36:39 +0200 Message-Id: <20180508183640.13605-4-timo@rothenpieler.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180508183640.13605-1-timo@rothenpieler.org> References: <20180508133132.28940-1-timo@rothenpieler.org> <20180508183640.13605-1-timo@rothenpieler.org> Subject: [FFmpeg-devel] [PATCH 4/5] avutil/hwcontext_cuda: explicitly synchronize cuMemcpy calls X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Timo Rothenpieler MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavutil/hwcontext_cuda.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c index f3e81680e9..668293bffc 100644 --- a/libavutil/hwcontext_cuda.c +++ b/libavutil/hwcontext_cuda.c @@ -258,13 +258,19 @@ static int cuda_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, .Height = src->height >> (i ? priv->shift_height : 0), }; - err = cu->cuMemcpy2D(&cpy); + err = cu->cuMemcpy2DAsync(&cpy, device_hwctx->stream); if (err != CUDA_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "Error transferring the data from the CUDA frame\n"); return AVERROR_UNKNOWN; } } + err = cu->cuStreamSynchronize(device_hwctx->stream); + if (err != CUDA_SUCCESS) { + av_log(ctx, AV_LOG_ERROR, "Error synchronizing CUDA stream\n"); + return AVERROR_UNKNOWN; + } + cu->cuCtxPopCurrent(&dummy); return 0; @@ -297,13 +303,19 @@ static int cuda_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, .Height = src->height >> (i ? priv->shift_height : 0), }; - err = cu->cuMemcpy2D(&cpy); + err = cu->cuMemcpy2DAsync(&cpy, device_hwctx->stream); if (err != CUDA_SUCCESS) { - av_log(ctx, AV_LOG_ERROR, "Error transferring the data from the CUDA frame\n"); + av_log(ctx, AV_LOG_ERROR, "Error transferring the data to the CUDA frame\n"); return AVERROR_UNKNOWN; } } + err = cu->cuStreamSynchronize(device_hwctx->stream); + if (err != CUDA_SUCCESS) { + av_log(ctx, AV_LOG_ERROR, "Error synchronizing CUDA stream\n"); + return AVERROR_UNKNOWN; + } + cu->cuCtxPopCurrent(&dummy); return 0;