From patchwork Wed Aug 8 14:29:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 955081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483401-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="s9GDnsO1"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lv1D0Z71z9s4Z for ; Thu, 9 Aug 2018 00:30:07 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=mN8YoRL9T587lPdVOuQGF9G6t+3MkS6unp0EQSXHhEbuYK37b8 J0NlAgWK4s6nfNNKeZN6stOTTUSMLoavkOxEtR6OG7P4i+WDDUGVFFQ9snmdMDuu z/fsQExxxfMyRlkFxBjQh5B2x6oRyxWPSio2InVEBATZr8qOrv9R4/Fxg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=iw3V4yuiRP5BhLQMms6iYQanrCA=; b=s9GDnsO1Og+a2KbCOwai 7ozxnLAeGMZZt+hXYGR5sV8MsnPc/72e+M+yj2zPtV8eaoMK7rOYt4MSiK0nZPby 5kUJvBnJH/qkMDRt4zhRMhJNGHEuhjP6UtsrcPvxvuymi46O+0PXln0caEjCHOYp Pe6tjvxOCYhtJFLCurKerFg= Received: (qmail 117366 invoked by alias); 8 Aug 2018 14:29:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 116113 invoked by uid 89); 8 Aug 2018 14:29:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Aug 2018 14:29:57 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A2564AE15; Wed, 8 Aug 2018 14:29:55 +0000 (UTC) Date: Wed, 8 Aug 2018 16:29:56 +0200 From: Tom de Vries To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek Subject: [committed][libgomp, nvptx] Allow cuGetErrorString to be NULL Message-ID: <20180808142955.GA22523@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi, Cuda driver api function cuGetErrorString is available in version 6.0 and higher. Currently, when the driver that is used does not contain this function, the libgomp nvptx plugin will not build (PLUGIN_NVPTX_DYNAMIC == 0) or run (PLUGIN_NVPTX_DYNAMIC == 1). This patch fixes this problem by testing for the presence of the function, and handling absence. Build on x86_64 with nvptx accelerator and reg-tested libgomp, both with and without --without-cuda-driver. Committed to trunk. Thanks, - Tom [libgomp, nvptx] Allow cuGetErrorString to be NULL 2018-08-08 Tom de Vries * plugin/cuda-lib.def (cuGetErrorString): Use CUDA_ONE_CALL_MAYBE_NULL. * plugin/plugin-nvptx.c (cuda_error): Handle if cuGetErrorString is not present. --- libgomp/plugin/cuda-lib.def | 2 +- libgomp/plugin/plugin-nvptx.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libgomp/plugin/cuda-lib.def b/libgomp/plugin/cuda-lib.def index be8e3b3ec4d6..6365cdbfcbe4 100644 --- a/libgomp/plugin/cuda-lib.def +++ b/libgomp/plugin/cuda-lib.def @@ -15,7 +15,7 @@ CUDA_ONE_CALL (cuEventQuery) CUDA_ONE_CALL (cuEventRecord) CUDA_ONE_CALL (cuEventSynchronize) CUDA_ONE_CALL (cuFuncGetAttribute) -CUDA_ONE_CALL (cuGetErrorString) +CUDA_ONE_CALL_MAYBE_NULL (cuGetErrorString) CUDA_ONE_CALL (cuInit) CUDA_ONE_CALL (cuLaunchKernel) CUDA_ONE_CALL (cuLinkAddData) diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index 589d6596cc2f..b549b7740039 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -161,13 +161,17 @@ init_cuda_lib (void) static const char * cuda_error (CUresult r) { + const char *fallback = "unknown cuda error"; const char *desc; + if (!CUDA_CALL_EXISTS (cuGetErrorString)) + return fallback; + r = CUDA_CALL_NOCHECK (cuGetErrorString, r, &desc); - if (r != CUDA_SUCCESS) - desc = "unknown cuda error"; + if (r == CUDA_SUCCESS) + return desc; - return desc; + return fallback; } static unsigned int instantiated_devices = 0;