From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 3DDD9385843E for ; Sat, 5 Nov 2022 10:54:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3DDD9385843E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-x333.google.com with SMTP id ay14-20020a05600c1e0e00b003cf6ab34b61so6847986wmb.2 for ; Sat, 05 Nov 2022 03:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=Hjkv8LC4IeTwzBBOCQO0MCr9F9PJUbIZOsVh6l40Ofg=; b=oKrsb+xh9KDEOgXlQCyROpKixu8A6QRlS+/2hFoFQmJLuA/dZr1fFdWNaO9OeAG6Np eZ6QTwLaZw29II9fLlKLFkrUV4uiFsiR/vPVyD+MBV6oa/1yYqdcYHV+N8uJ0qfqQBCd bE/12npZhwfDoeu6d9ZuYT4Ib+kTm5CILB2mKa7dICwZ1kidFD1AF947Y5tJshVTLpQ6 kXCib5s2mfw78Z1Q/KEMhb94iwtHc/R3D6gHm0OU23RV2Dm8tgPxXOinGzfozGChX41o vNxtweyfcGO/tGV0tf4jrCIfLNqZAEHdaibNMqRh8R8QjrM82x2788ru2EjNce7NN7Rx Sg+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:in-reply-to:message-id:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hjkv8LC4IeTwzBBOCQO0MCr9F9PJUbIZOsVh6l40Ofg=; b=co0mh6gIm76DPRbz5Jp79iVaFTqIkCr2yLas9VYnaDv474bvALZIWij7jf9w3fhAN+ MfGx9l+t1QUglKinAJgc1mr1OzobdGbw7LEPmBCZKypaZettaRSnrWohDZyRHh3e0lVx s42KIC0yYdpRVvwBA2CSjSn0UauSSppkwWohj+yAXIbgBZ3U9/LsaMbQLtF9HseqzIyV 0JnueVvbRNe122PAXx8fDNw6xfmoPVEHPo4wBQ6LB0/hytwiNuYFGESg9AqxGegW4fSb 0Pa1twMfAtQC+EmhD8QJ/TAb4ncSwZRMSkXTq0wQm/ly5PnmZGEi6019XI36fd2zXbI9 HqDw== X-Gm-Message-State: ACrzQf3zf3W/iZgUVan7g87HDpaLwK//iB7Hn6lvhz4uvuU3LW4UNN+h tKdkmw/RyY9SU3UqU9JE6Qo= X-Google-Smtp-Source: AMsMyM6Xe5GU+uFIPxlc1f9/tqH943X9TiO63EVugPIu4dzjjQHualbgMExU5DG5+iuVX97gyShbGw== X-Received: by 2002:a1c:f311:0:b0:3b5:18ca:fc5e with SMTP id q17-20020a1cf311000000b003b518cafc5emr26983143wmq.70.1667645660809; Sat, 05 Nov 2022 03:54:20 -0700 (PDT) Received: from nbbrfq ([2001:871:227:81c4:d7ff:3a0e:48da:5fe3]) by smtp.gmail.com with ESMTPSA id f19-20020adfb613000000b0022dc6e76bbdsm1813252wre.46.2022.11.05.03.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 03:54:20 -0700 (PDT) Date: Sat, 5 Nov 2022 11:54:16 +0100 From: Bernhard Reutner-Fischer To: Thomas Koenig Cc: rep.dot.nop@gmail.com, Dave Love via Fortran , Dave Love Subject: Re: adding attributes Message-ID: <20221105115416.6ae54e04@nbbrfq> In-Reply-To: <5e10f634-741c-e576-396c-a8741ef95888@netcologne.de> References: <87pmecdni6.fsf@manchester.ac.uk> <20221030084839.118ef0c8@nbbrfq> <87edund73d.fsf@manchester.ac.uk> <20221103001926.725fd9bf@nbbrfq> <20221104215921.79be6bff@nbbrfq> <5e10f634-741c-e576-396c-a8741ef95888@netcologne.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/exs/srKMe/b+wVGfy_d17De" X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SCC_5_SHORT_WORD_LINES,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --MP_/exs/srKMe/b+wVGfy_d17De Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sat, 5 Nov 2022 08:40:06 +0100 Thomas Koenig wrote: > On 04.11.22 21:59, Bernhard Reutner-Fischer via Fortran wrote: > > And not sure if fellow gfortraners would accept this attribute > > target_clones in there in the first place.. > > It might actually be useful. Is there any change about > the calling sequence or anything else that should be visible > in a Fortran module or the calling sequence? The module interface remains the same. And the call sequence remains the same, too. For a user nothing changes. An example: module m implicit none contains subroutine sub1() !GCC$ ATTRIBUTES target_clones("avx", "sse","default") :: sub1 print *, 4321 end end module m This used to compiles to: $ nm /tmp/pristine.o U _gfortran_st_write U _gfortran_st_write_done U _gfortran_transfer_integer_write 0000000000000000 T __m_MOD_sub1 And now compiles to: $ nm /tmp/new.o U __cpu_indicator_init U __cpu_model U _gfortran_st_write U _gfortran_st_write_done U _gfortran_transfer_integer_write 0000000000000000 i __m_MOD_sub1 000000000000006e t __m_MOD_sub1.avx 0000000000000000 t __m_MOD_sub1.default 0000000000000000 W __m_MOD_sub1.resolver 00000000000000dc t __m_MOD_sub1.sse I.e. the caller still calls __m_MOD_sub1 But this is now an ifunc, which looks at the cpu bits and dispatches to the appropriate ISA version. I'm attaching the assembler input for reference. If you think that we want to add support for that attribute, i can submit a proper patch. Just let me know please. thanks, --MP_/exs/srKMe/b+wVGfy_d17De Content-Type: text/plain Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename=new.s .file "attr_target_clones-1.F90" .text .section .rodata .align 8 .LC0: .string "/scratch/src/gcc-13.mine/gcc/testsuite/gfortran.dg/attr_target_clones-1.F90" .align 4 .LC1: .long 4321 .text .type __m_MOD_sub1.default, @function __m_MOD_sub1.default: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $528, %rsp movq $.LC0, -520(%rbp) movl $21, -512(%rbp) movl $128, -528(%rbp) movl $6, -524(%rbp) leaq -528(%rbp), %rax movq %rax, %rdi call _gfortran_st_write leaq -528(%rbp), %rax movl $4, %edx movl $.LC1, %esi movq %rax, %rdi call _gfortran_transfer_integer_write leaq -528(%rbp), %rax movq %rax, %rdi call _gfortran_st_write_done nop leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size __m_MOD_sub1.default, .-__m_MOD_sub1.default .type __m_MOD_sub1.avx, @function __m_MOD_sub1.avx: .LFB1: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $528, %rsp movq $.LC0, -520(%rbp) movl $21, -512(%rbp) movl $128, -528(%rbp) movl $6, -524(%rbp) leaq -528(%rbp), %rax movq %rax, %rdi call _gfortran_st_write leaq -528(%rbp), %rax movl $4, %edx movl $.LC1, %esi movq %rax, %rdi call _gfortran_transfer_integer_write leaq -528(%rbp), %rax movq %rax, %rdi call _gfortran_st_write_done nop leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE1: .size __m_MOD_sub1.avx, .-__m_MOD_sub1.avx .type __m_MOD_sub1.sse, @function __m_MOD_sub1.sse: .LFB2: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $528, %rsp movq $.LC0, -520(%rbp) movl $21, -512(%rbp) movl $128, -528(%rbp) movl $6, -524(%rbp) leaq -528(%rbp), %rax movq %rax, %rdi call _gfortran_st_write leaq -528(%rbp), %rax movl $4, %edx movl $.LC1, %esi movq %rax, %rdi call _gfortran_transfer_integer_write leaq -528(%rbp), %rax movq %rax, %rdi call _gfortran_st_write_done nop leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE2: .size __m_MOD_sub1.sse, .-__m_MOD_sub1.sse .section .text.__m_MOD_sub1.resolver,"axG",@progbits,__m_MOD_sub1.resolver,comdat .weak __m_MOD_sub1.resolver .type __m_MOD_sub1.resolver, @function __m_MOD_sub1.resolver: .LFB4: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 call __cpu_indicator_init movl __cpu_model+12(%rip), %eax andl $512, %eax testl %eax, %eax jle .L5 movl $__m_MOD_sub1.avx, %eax jmp .L4 .L5: movl __cpu_model+12(%rip), %eax andl $8, %eax testl %eax, %eax jle .L6 movl $__m_MOD_sub1.sse, %eax jmp .L4 .L6: movl $__m_MOD_sub1.default, %eax .L4: popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE4: .size __m_MOD_sub1.resolver, .-__m_MOD_sub1.resolver .globl __m_MOD_sub1 .type __m_MOD_sub1, @gnu_indirect_function .set __m_MOD_sub1,__m_MOD_sub1.resolver .ident "GCC: (GNU) 13.0.0 20220916 (experimental) [master r13-2694-g3e8c4b925a9]" .section .note.GNU-stack,"",@progbits --MP_/exs/srKMe/b+wVGfy_d17De--