From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id CE15A385772D for ; Thu, 7 Mar 2024 14:28:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE15A385772D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CE15A385772D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::535 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709821707; cv=none; b=DQpHv910xDqxuYaL3/XXuV+s1F69jbNVLTs9cKLtrVH5HYluVPo9SjX6OG9vyrl+CHLs4Meklzs1o8Ewp5nAVfcahsQ2h0aL0THFpY/2kk9DWFq9S/Qudmpoj0CX/Bzmu5FPUnqkNh6SV5Oz7bbKSDPgiXBNBAGqUFvwioGzz+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709821707; c=relaxed/simple; bh=XD8DfbZI/UMaDAs3nB1tWBcm/yKZoenPaMoSc3x2Ftw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=ngcDtLd5gK3EHoV0Gwi8PrK/CPsB1S6kv8VKn3BIyTOtZL/mvAmF+42kQcPs/+9UPBrA9xuIQJ0XbA+O2bPnCCf0zrTaASqOYv8QGRBMFPFCHbk0A6olMrM7OWpxxO0n1eZTo7/Hb9GDN8lAN7+l4atO6P241ZrEQMuXKG6mKOI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-55a5e7fa471so1432724a12.1 for ; Thu, 07 Mar 2024 06:28:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1709821704; x=1710426504; darn=gcc.gnu.org; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=eD2RSEn4jGLdHyGyAeSSAtg5MTcJf91ZodJbLWZ0TMM=; b=DQRkUWWK+OlGZeGp5QsRhCvGWKrDlJ1A8V8B2uKkgdjeJ1z+wUYKnqFE1pcxU2AW30 MkpRkEknoss6R0WTcyjQ7iysT78sNmPgoddXXxldUH5wmruGex5mqnwaeJS0RG7by8xL pJEKjIza15C+Bx/PcB10nxv22nYrML38AcFmJYdzlzwZQzraGUVotBM0DhKpfzY1oHhZ 8P2MWOsCBXfwg/vox/GaCUJx5KUxHCsJMjOQBst2R0Yj0M/0Ou3VQxH1++9ik1V69vgz vBt1dII7qVM+OGl85KUlyZS9UWVYrVWYIhsiEWKST10foC/hD4U5urHBDyvClweieTle AD5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709821704; x=1710426504; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=eD2RSEn4jGLdHyGyAeSSAtg5MTcJf91ZodJbLWZ0TMM=; b=nKy/JGsVa83Q+zfGTqffqZzCdYQ4IB/fLQ/tKpT8vF0R89+5M19J36K/FWEDwjEbMD NEziSh4rwjq5rgTyGKGh4WnjWWc12emNG2xSQbUGfPCNzdF5ee33cuR6WY0fHWbY9n94 xzJ5Zr9ih/4Ynin3oMnJ4L4u9OQ7ddmBOoxLxhcs45wLtIOJtWt6wv9yBc8EbtFy03WK Dp7R9KcipiKFWI6noMWo4EYZx2CjMMUKrQpMK0GEtAONEaQRDqjk/wy+Znb83aIX/WJF ZhSumf0AI3ln9v23I/fMqYXFG679+kh04u5uRC1/z61e3vIAhYhE8oisvzf21iQL/BWF EBlQ== X-Forwarded-Encrypted: i=1; AJvYcCWZk2c4JFBpO5RVlpfu2UF1NrSBiBibarI7PFZy9JkIw2UeTCmlwP4X7/RCd2tlX1QinzWHD3M3l0XtwUfk3/mkjqFRZ2DPnw== X-Gm-Message-State: AOJu0Yzq1ifS+AciQOoZK7DnTIuEP0/6/Av4R5e5PR8qxyDj011UlE+A GmgPW4LZAkZ8AvfqaCIx6IWhh87tQYCXmI4YTAlZLbQ32vicLZShzZx0V3uJckA= X-Google-Smtp-Source: AGHT+IGld61FcR0zlUxsElgdvd6DypbmMEsU6p5nkKraaonvxYtGb2JtP/9WI8RaDvdOdzFrTz1RCQ== X-Received: by 2002:a17:906:b014:b0:a44:c6b4:ee4b with SMTP id v20-20020a170906b01400b00a44c6b4ee4bmr11235988ejy.25.1709821703861; Thu, 07 Mar 2024 06:28:23 -0800 (PST) Received: from ?IPV6:2001:16b8:2a30:2d00:817a:ccdf:b4da:ce60? (200116b82a302d00817accdfb4dace60.dip.versatel-1u1.de. [2001:16b8:2a30:2d00:817a:ccdf:b4da:ce60]) by smtp.gmail.com with ESMTPSA id lz19-20020a170906fb1300b00a45b7f9e822sm1916595ejb.118.2024.03.07.06.28.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Mar 2024 06:28:23 -0800 (PST) Content-Type: multipart/alternative; boundary="------------TqCYGsiycZ8gSMCuTYIN7LTV" Message-ID: <200df3f7-3419-47f6-9fc9-1db257521229@baylibre.com> Date: Thu, 7 Mar 2024 15:28:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: nvptx: 'cuDeviceGetCount' failure is fatal Content-Language: en-US To: Thomas Schwinge , gcc-patches@gcc.gnu.org Cc: Jakub Jelinek References: <07fec82a-41cf-fdc5-6307-c068dd95ef1a@mentor.com> <87sf12dxon.fsf@euler.schwinge.ddns.net> From: Tobias Burnus In-Reply-To: <87sf12dxon.fsf@euler.schwinge.ddns.net> X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is a multi-part message in MIME format. --------------TqCYGsiycZ8gSMCuTYIN7LTV Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Thomas, Thomas Schwinge wrote: >> /* Return the number of GCN devices on the system. */ >> int >> -GOMP_OFFLOAD_get_num_devices (void) >> +GOMP_OFFLOAD_get_num_devices (unsigned int omp_requires_mask) >> { >> if (!init_hsa_context ()) >> return 0; >> + /* Return -1 if no omp_requires_mask cannot be fulfilled but >> + devices were present. */ >> + if (hsa_context.agent_count > 0 && omp_requires_mask != 0) >> + return -1; >> return hsa_context.agent_count; >> } ... > OK to push the attached "nvptx: 'cuDeviceGetCount' failure is fatal"? I think the real question is: what does a 'cuDeviceGetCount' fail mean? Does it mean a serious error – or could it just be a permissions issue such that the user has no device access but otherwise is fine? Because if it is, e.g., a permission problem – just returning '0' (no devices) would seem to be the proper solution. But if it is expected to be always something serious, well, then a fatal error makes more sense. The possible exit codes are: CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE which does not really help. My impression is that 0 is usually returned if something goes wrong (e.g. with permissions) such that an error is a real exception. But all three choices seem to make about equally sense: either host fallback (with 0 or -1) or a fatal error. Tobias --------------TqCYGsiycZ8gSMCuTYIN7LTV--