From patchwork Wed Jun 21 10:06:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 778735 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 3wt0kF3RFtz9ryv for ; Wed, 21 Jun 2017 20:07:00 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="flAJGsi/"; 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 :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=uhYOudz/8M+HJ/NKu HJZKd/Y05YV0zfgE070AokTGseoGm9izjGtvGKRCcM0fbAt+ViQR766xVekaSrGe FpDQQSgbQwnPvvkjgqmSlXTPOo9ri4nLSEvGM0ylzxMCQ+YeMC8lBVnIlAksNvje Grj5KIc6ANbGeXyCT/yFzGOV1w= 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 :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=zrXGv2U5jjJZTmbZ/AYjHkL D39k=; b=flAJGsi/2psSM39dIfQa/ZPOOSot/V3Tc1IhqioHjz2D0gS8wvnNVSP Ls0bylijp8M8oeG5VOMr7Kwbovwn272MF37iZGxGuQoXdzEdJ6qY0NEukEctM4bK DkJ+kBIO7knbC/yNbsqYob/65AU7UT+/LRZ7HVyAo0JrMAqQ4eWs= Received: (qmail 30388 invoked by alias); 21 Jun 2017 10:06:52 -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 30360 invoked by uid 89); 21 Jun 2017 10:06:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=joined, H*M:9ad1 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Jun 2017 10:06:49 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1dNcX7-0000fe-Ao from Andrew_Stubbs@mentor.com ; Wed, 21 Jun 2017 03:06:45 -0700 Received: from [172.30.88.142] (137.202.0.87) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 21 Jun 2017 11:06:41 +0100 Subject: Re: [gcn][patch] Add -mgpu option and plumb in assembler/linker From: Andrew Stubbs To: Jan Hubicka , "gcc-patches@gcc.gnu.org" References: <20170529172734.f4gtlrhkg2ovtwve@virgil.suse.cz> <8189798b-48e3-7f72-5976-53ea947adc10@mentor.com> Message-ID: Date: Wed, 21 Jun 2017 11:06:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <8189798b-48e3-7f72-5976-53ea947adc10@mentor.com> X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) On 06/06/17 20:52, Andrew Stubbs wrote: > Thomas objects to the new option, and after talking with him the > reasoning seems sound. GCC has been moving away from -mcpu in any case, > so I guess I'll put -march and -mtune back, and use those for the same > purpose. > > I'll commit the patch with those changes soonish. I've finally got around to pushing the patch. It now uses -march to set the GPU name. Andrew Switch to HSACO2 2017-06-21 Andrew Stubbs gcc/ * config.gcc (amdgcn): Set default to "carrizo" * config/gcn/gcn-opts.h: New file. * config/gcn/gcn.c (output_file_start): Switch to HSACO version 2 and auto-detection of GPU type (from -mcpu). (gcn_arch, gcn_tune): Remove. * config/gcn/gcn.h: Include gcn-opts.h. (enum processor_type): Move to gcn-opts.h. (LIBGCC_SPEC, ASM_SPEC, LINK_SPEC): Define. (gcn_arch, gcn_tune): Remove. * config/gcn/gcn.opt: Include gcn-opts.h. (gpu_type): New Enum. (march, mtune): New options. diff --git a/gcc/config.gcc b/gcc/config.gcc index 32f0f4b..99c9c4a 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -3930,7 +3930,7 @@ case "${target}" in for which in arch tune; do eval "val=\$with_$which" case ${val} in - "" | fiji) + "" | carrizo | fiji) # OK ;; *) @@ -3939,6 +3939,7 @@ case "${target}" in ;; esac done + [ "x$with_arch" = x ] && with_arch=carrizo ;; hppa*-*-*) diff --git a/gcc/config/gcn/gcn-opts.h b/gcc/config/gcn/gcn-opts.h new file mode 100644 index 0000000..d0586d6 --- /dev/null +++ b/gcc/config/gcn/gcn-opts.h @@ -0,0 +1,27 @@ +/* Copyright (C) 2016-2017 Free Software Foundation, Inc. + + This file is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This file is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#ifndef GCN_OPTS_H +#define GCN_OPTS_H + +/* Which processor to generate code or schedule for. */ +enum processor_type +{ + PROCESSOR_CARRIZO, + PROCESSOR_FIJI +}; + +#endif diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c index eb6edd8..c80bdf5 100644 --- a/gcc/config/gcn/gcn.c +++ b/gcc/config/gcn/gcn.c @@ -60,11 +60,6 @@ /* This file should be included last. */ #include "target-def.h" -/* Which instruction set architecture to use. */ -int gcn_arch; -/* Which cpu are we tuning for. */ -int gcn_tune; - static REAL_VALUE_TYPE dconst4, dconst1over2pi; static bool ext_gcn_constants_init = 0; @@ -2006,8 +2001,8 @@ static void output_file_start (void) { fprintf (asm_out_file, "\t.hsatext\n"); - fprintf (asm_out_file, "\t.hsa_code_object_version 1,0\n"); - fprintf (asm_out_file, "\t.hsa_code_object_isa 8,0,1,\"AMD\",\"AMDGPU\"\n"); + fprintf (asm_out_file, "\t.hsa_code_object_version 2,0\n"); + fprintf (asm_out_file, "\t.hsa_code_object_isa\n"); /* Autodetect. */ fprintf (asm_out_file, "\t.section\t.AMDGPU.config\n"); fprintf (asm_out_file, "\t.hsatext\n"); } diff --git a/gcc/config/gcn/gcn.h b/gcc/config/gcn/gcn.h index 903022f..3b41095 100644 --- a/gcc/config/gcn/gcn.h +++ b/gcc/config/gcn/gcn.h @@ -14,18 +14,22 @@ along with GCC; see the file COPYING3. If not see . */ +#include "config/gcn/gcn-opts.h" + /* FIXME */ #define TARGET_CPU_CPP_BUILTINS() -/* Which processor to generate code or schedule for. */ -enum processor_type -{ - PROCESSOR_CARRIZO, -}; +/* Temporarily disable libgcc until one actually exists. */ +#undef LIBGCC_SPEC +#define LIBGCC_SPEC "" + +/* Use LLVM assembler options. */ +#undef ASM_SPEC +#define ASM_SPEC "-triple=amdgcn--amdhsa %{march=*:-mcpu=%*} -filetype=obj" -extern GTY(()) int gcn_arch; -extern GTY(()) int gcn_tune; +#undef LINK_SPEC +#define LINK_SPEC "" /* Support for a compile-time default architecture and tuning. The rules are: --with-arch is ignored if -march is specified. diff --git a/gcc/config/gcn/gcn.opt b/gcc/config/gcn/gcn.opt index 8fc02b7..ffb5547 100644 --- a/gcc/config/gcn/gcn.opt +++ b/gcc/config/gcn/gcn.opt @@ -17,3 +17,24 @@ ; You should have received a copy of the GNU General Public License ; along with GCC; see the file COPYING3. If not see ; . + +HeaderInclude +config/gcn/gcn-opts.h + +Enum +Name(gpu_type) Type(enum processor_type) +GCN GPU type to use: + +EnumValue +Enum(gpu_type) String(carrizo) Value(PROCESSOR_CARRIZO) + +EnumValue +Enum(gpu_type) String(fiji) Value(PROCESSOR_FIJI) + +march= +Target RejectNegative Joined ToLower Enum(gpu_type) Var(gcn_arch) Init(PROCESSOR_CARRIZO) +Specify the name of the target GPU. + +mtune= +Target RejectNegative Joined ToLower Enum(gpu_type) Var(gcn_tune) Init(PROCESSOR_CARRIZO) +Specify the name of the target GPU.