From patchwork Tue Sep 29 19:47:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 523997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 C0358140180 for ; Wed, 30 Sep 2015 05:48:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=XFX6dNS1; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=nfBNZa03ntKbDaYKhEFbEXKGrP8xdu9mq+uzGHbZ/4sne3NPZk DJ/s+NxHdHR/17SeUKPQk07H76mPkoYC3VJDaC05YH9ErBxwyPaXAOtSZpdzcBn8 NeIyf2iXNYEj5PfsxP5gmFBhurbLybecxbaf2e+nfcc+/56pI/CbaFx1w= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=7bMpz0nEU8sfhg0efuP9rbwZZeM=; b=XFX6dNS1G/h2G9I3VzSu zhfvYzILF0dRPJqq2wly2Yx11hfywyGdr+hXv+f5kmNdwdqw4NlzYjyjdSwLzUX6 dyE8G1uAZrc9Q5NAkCNAqsvJkVdxM3m8GjrdkXJrxudO5fK3vwVJx6PgW1rSwWBJ YxGrqiM5NijNTj7MXosldII= Received: (qmail 92978 invoked by alias); 29 Sep 2015 19:48:05 -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 92229 invoked by uid 89); 29 Sep 2015 19:48:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=BAYES_20, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-qg0-f52.google.com Received: from mail-qg0-f52.google.com (HELO mail-qg0-f52.google.com) (209.85.192.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 29 Sep 2015 19:48:02 +0000 Received: by qgt47 with SMTP id 47so16270150qgt.2 for ; Tue, 29 Sep 2015 12:48:00 -0700 (PDT) X-Received: by 10.140.32.200 with SMTP id h66mr30130474qgh.99.1443556080147; Tue, 29 Sep 2015 12:48:00 -0700 (PDT) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id r74sm1354176qkl.18.2015.09.29.12.47.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2015 12:47:59 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [openacc] use cuda error routine Message-ID: <560AEAEE.1020003@acm.org> Date: Tue, 29 Sep 2015 15:47:58 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 The cuda library has provided cuGetErrorString since at least 5.5, along with documentation of same. What's been missing until cuda 7.0 is a declaration in the cuda header file. I've merged this patch from the gomp4 branch to the nvptx libgomp plugin. nathan 2015-09-29 Nathan Sidwell * plugin/plugin-nvptx.c (ARRAYSIZE): Delete. (cuda_errlist): Delete. (cuda_error): Reimplement. Index: libgomp/plugin/plugin-nvptx.c =================================================================== --- libgomp/plugin/plugin-nvptx.c (revision 228242) +++ libgomp/plugin/plugin-nvptx.c (working copy) @@ -47,84 +47,21 @@ #include #include -#define ARRAYSIZE(X) (sizeof (X) / sizeof ((X)[0])) - -static const struct -{ - CUresult r; - const char *m; -} cuda_errlist[]= -{ - { CUDA_ERROR_INVALID_VALUE, "invalid value" }, - { CUDA_ERROR_OUT_OF_MEMORY, "out of memory" }, - { CUDA_ERROR_NOT_INITIALIZED, "not initialized" }, - { CUDA_ERROR_DEINITIALIZED, "deinitialized" }, - { CUDA_ERROR_PROFILER_DISABLED, "profiler disabled" }, - { CUDA_ERROR_PROFILER_NOT_INITIALIZED, "profiler not initialized" }, - { CUDA_ERROR_PROFILER_ALREADY_STARTED, "already started" }, - { CUDA_ERROR_PROFILER_ALREADY_STOPPED, "already stopped" }, - { CUDA_ERROR_NO_DEVICE, "no device" }, - { CUDA_ERROR_INVALID_DEVICE, "invalid device" }, - { CUDA_ERROR_INVALID_IMAGE, "invalid image" }, - { CUDA_ERROR_INVALID_CONTEXT, "invalid context" }, - { CUDA_ERROR_CONTEXT_ALREADY_CURRENT, "context already current" }, - { CUDA_ERROR_MAP_FAILED, "map error" }, - { CUDA_ERROR_UNMAP_FAILED, "unmap error" }, - { CUDA_ERROR_ARRAY_IS_MAPPED, "array is mapped" }, - { CUDA_ERROR_ALREADY_MAPPED, "already mapped" }, - { CUDA_ERROR_NO_BINARY_FOR_GPU, "no binary for gpu" }, - { CUDA_ERROR_ALREADY_ACQUIRED, "already acquired" }, - { CUDA_ERROR_NOT_MAPPED, "not mapped" }, - { CUDA_ERROR_NOT_MAPPED_AS_ARRAY, "not mapped as array" }, - { CUDA_ERROR_NOT_MAPPED_AS_POINTER, "not mapped as pointer" }, - { CUDA_ERROR_ECC_UNCORRECTABLE, "ecc uncorrectable" }, - { CUDA_ERROR_UNSUPPORTED_LIMIT, "unsupported limit" }, - { CUDA_ERROR_CONTEXT_ALREADY_IN_USE, "context already in use" }, - { CUDA_ERROR_PEER_ACCESS_UNSUPPORTED, "peer access unsupported" }, - { CUDA_ERROR_INVALID_SOURCE, "invalid source" }, - { CUDA_ERROR_FILE_NOT_FOUND, "file not found" }, - { CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND, - "shared object symbol not found" }, - { CUDA_ERROR_SHARED_OBJECT_INIT_FAILED, "shared object init error" }, - { CUDA_ERROR_OPERATING_SYSTEM, "operating system" }, - { CUDA_ERROR_INVALID_HANDLE, "invalid handle" }, - { CUDA_ERROR_NOT_FOUND, "not found" }, - { CUDA_ERROR_NOT_READY, "not ready" }, - { CUDA_ERROR_LAUNCH_FAILED, "launch error" }, - { CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES, "launch out of resources" }, - { CUDA_ERROR_LAUNCH_TIMEOUT, "launch timeout" }, - { CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING, - "launch incompatibe texturing" }, - { CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED, "peer access already enabled" }, - { CUDA_ERROR_PEER_ACCESS_NOT_ENABLED, "peer access not enabled " }, - { CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE, "primary cotext active" }, - { CUDA_ERROR_CONTEXT_IS_DESTROYED, "context is destroyed" }, - { CUDA_ERROR_ASSERT, "assert" }, - { CUDA_ERROR_TOO_MANY_PEERS, "too many peers" }, - { CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED, - "host memory already registered" }, - { CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED, "host memory not registered" }, - { CUDA_ERROR_NOT_PERMITTED, "not permitted" }, - { CUDA_ERROR_NOT_SUPPORTED, "not supported" }, - { CUDA_ERROR_UNKNOWN, "unknown" } -}; - static const char * cuda_error (CUresult r) { - int i; - - for (i = 0; i < ARRAYSIZE (cuda_errlist); i++) - { - if (cuda_errlist[i].r == r) - return cuda_errlist[i].m; - } - - static char errmsg[30]; +#if CUDA_VERSION < 7000 + /* Specified in documentation and present in library from at least + 5.5. Not declared in header file prior to 7.0. */ + extern CUresult cuGetErrorString (CUresult, const char **); +#endif + const char *desc; - snprintf (errmsg, sizeof (errmsg), "unknown error code: %d", r); + r = cuGetErrorString (r, &desc); + if (r != CUDA_SUCCESS) + desc = "unknown cuda error"; - return errmsg; + return desc; } static unsigned int instantiated_devices = 0;