From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sender4-pp-o91.zoho.com (sender4-pp-o91.zoho.com [136.143.188.91]) by sourceware.org (Postfix) with ESMTPS id 1F9A7387089F; Wed, 12 Jun 2024 12:22:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F9A7387089F Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=zoho.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zoho.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1F9A7387089F Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=136.143.188.91 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1718194922; cv=pass; b=XgXz7ulJA+i13VM+b/Wpx5pTl7eYckBbIdEfgMhe5QxN/wj9om9F5+FfoTawvj7EvDAJYXUyMnpDkYNmuOGrCTjCzxvwRfK2Hw/UknMPwhRTGWQWxV6QTechV2rL5XVYmb0bpLHrncZuFy4Ddc68d8pZVrb7zgPPyiGWEOCCwWw= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1718194922; c=relaxed/simple; bh=Ep2BcSxFe4pbKfMIx5JaKmI7dk3vBe+r/9oWm0M9ivI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=i2sH22azhX7hzlB5LraOinuTwFh2896k9JY3QOKCRhC8WTUXKHACm/kVSVi++WLNDkI0a81vMeagmNhTf7Ssmypk2aM/GS7OeDXDX/lqbv9oGwR+UmwhiTHSyufm2i6piJFqLolqYPAVizdweyiO/jR4UHW/IPV/IJ8cMPDjcBY= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1718194915; cv=none; d=zohomail.com; s=zohoarc; b=InW2s+K39SEV2U4X28fIEcAeF5DFIrVniMlPFvlmqE/q8qdPXSKXN1EjtNkmdKkQojrKIXhwvoMPXhpDnr2wn0u02K5kdTK77YrTp89k12UxJZHfllVWq9BrZYz1YagmTOCM8h/3fki4S2JxO8TG5FHj+rDPkCQcF7T7Qugkzrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718194915; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Oolu4SvGVVNVj1ytxpaD8hO5GtpfpJ59QCXCZm5/62c=; b=IiIeO/OG6UcqweGTtxlT94g/oMfueezwd/aYxR+nkiei4GhtsERGgrawgcmkXCAD9U5iA7VcAFmDsFKCk81Q1wloUY9+O3ctMz09m2IvSjMszzbxs7je9s6V8RIo7IAajW2Ji/frTpFBuApYno9ey4Z8hwhqkI+K7RyL57mN5IU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=bouanto@zoho.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1718194915; s=zm2022; d=zoho.com; i=bouanto@zoho.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:From:From:To:To:References:In-Reply-To:Content-Type:Content-Transfer-Encoding:Feedback-ID:Message-Id:Reply-To:Cc; bh=Oolu4SvGVVNVj1ytxpaD8hO5GtpfpJ59QCXCZm5/62c=; b=SgKE4htsSJywf0wiq+OZuroUYJuZD1BdjfZ3CQiqgTzyntQR96THe3bLAdrFsqN/ FKOM1yEbR5PesJxkilTUx8yI4tmpV2VOaGqlQeeRV6IAItYESGFEZmfO2Is0T5htTyj 3u0UjEBZ2xt5LECae5SzciNnDW+GHWBPJuzUUwZQ= Received: by mx.zohomail.com with SMTPS id 1718194913066477.4357345791833; Wed, 12 Jun 2024 05:21:53 -0700 (PDT) Message-ID: <7a192375-a8cc-479f-b780-b1b1fb180ede@zoho.com> Date: Wed, 12 Jun 2024 08:21:51 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Frontend access to target features (was Re: [PATCH] libgccjit: Add ability to get CPU features) From: Antoni Boucher To: David Malcolm , jit@gcc.gnu.org, gcc-patches@gcc.gnu.org References: <8b0199d9835f568b7bcde41bf9432c21f604e489.camel@zoho.com> <755705e37731c4fbc3ab7eb1a96d8df0147bb002.camel@redhat.com> <6050c91ae34a2cdaeebd79ada9e2b9ffaf881e21.camel@zoho.com> <997ddb068ca13f755accd03f38141e56c87b84a7.camel@redhat.com> <1f7f229f-5d42-4bb6-9a47-0f3c630bea44@zoho.com> <4d106b99-20b4-466e-9c25-89e00df164f2@zoho.com> Content-Language: en-US, fr In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Feedback-ID: rr08011228951d69e2a65cfdd616ca8a8a000088803e79ed17dcb6f5d2bd92d24cda7bb2c9d81b24338cf4eb85:zu08011226b85a2c1759a98482754e798600007a2ab7b4361b10b09d33a72ebab620e90dcae628a115f3ef:rf08011226a47554a8ad23bde260fff7f100002a06b058655bcced1652b70d0f97577d1b1d7f1df05614d5:ZohoMail X-ZohoMailClient: External X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,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: David: Ping. Le 2024-04-26 à 09 h 51, Antoni Boucher a écrit : > Now that we have a more general way to check if target-dependent types > are supported (see this commit: > https://github.com/rust-lang/gcc/commit/1c9a9b2f1fd914cad911467ec1d29f158643c2ce#diff-018089519ab2b14a34313ded0ae1a2f9fcab5f7bcb2fa31f147e1dc757bbdd7aR4016), perhaps we should remove gcc_jit_target_info_supports_128bit_int from this patch, or change it to include the more general way. > > David, what are your thoughts on this? > > Le 2024-04-19 à 08 h 34, Antoni Boucher a écrit : >> David: Ping. >> >> Le 2024-04-09 à 09 h 21, Antoni Boucher a écrit : >>> David: Ping. >>> >>> Le 2024-04-01 à 08 h 20, Antoni Boucher a écrit : >>>> David: Ping. >>>> >>>> Le 2024-03-19 à 07 h 03, Arthur Cohen a écrit : >>>>> Hi, >>>>> >>>>> On 3/5/24 16:09, David Malcolm wrote: >>>>>> On Thu, 2023-11-09 at 19:33 -0500, Antoni Boucher wrote: >>>>>>> Hi. >>>>>>> See answers below. >>>>>>> >>>>>>> On Thu, 2023-11-09 at 18:04 -0500, David Malcolm wrote: >>>>>>>> On Thu, 2023-11-09 at 17:27 -0500, Antoni Boucher wrote: >>>>>>>>> Hi. >>>>>>>>> This patch adds support for getting the CPU features in libgccjit >>>>>>>>> (bug >>>>>>>>> 112466) >>>>>>>>> >>>>>>>>> There's a TODO in the test: >>>>>>>>> I'm not sure how to test that gcc_jit_target_info_arch returns >>>>>>>>> the >>>>>>>>> correct value since it is dependant on the CPU. >>>>>>>>> Any idea on how to improve this? >>>>>>>>> >>>>>>>>> Also, I created a CStringHash to be able to have a >>>>>>>>> std::unordered_set. Is there any built-in way of >>>>>>>>> doing >>>>>>>>> this? >>>>>>>> >>>>>>>> Thanks for the patch. >>>>>>>> >>>>>>>> Some high-level questions: >>>>>>>> >>>>>>>> Is this specifically about detecting capabilities of the host that >>>>>>>> libgccjit is currently running on? or how the target was configured >>>>>>>> when libgccjit was built? >>>>>>> >>>>>>> I'm less sure about this part. I'll need to do more tests. >>>>>>> >>>>>>>> >>>>>>>> One of the benefits of libgccjit is that, in theory, we support all >>>>>>>> of >>>>>>>> the targets that GCC already supports.  Does this patch change >>>>>>>> that, >>>>>>>> or >>>>>>>> is this more about giving client code the ability to determine >>>>>>>> capabilities of the specific host being compiled for? >>>>>>> >>>>>>> This should not change that. If it does, this is a bug. >>>>>>> >>>>>>>> >>>>>>>> I'm nervous about having per-target jit code.  Presumably there's a >>>>>>>> reason that we can't reuse existing target logic here - can you >>>>>>>> please >>>>>>>> describe what the problem is.  I see that the ChangeLog has: >>>>>>>> >>>>>>>>>          * config/i386/i386-jit.cc: New file. >>>>>>>> >>>>>>>> where i386-jit.cc has almost 200 lines of nontrivial code.  Where >>>>>>>> did >>>>>>>> this come from?  Did you base it on existing code in our source >>>>>>>> tree, >>>>>>>> making modifications to fit the new internal API, or did you write >>>>>>>> it >>>>>>>> from scratch?  In either case, how onerous would this be for other >>>>>>>> targets? >>>>>>> >>>>>>> This was mostly copied from the same code done for the Rust and D >>>>>>> frontends. >>>>>>> See this commit and the following: >>>>>>> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b1c06fd9723453dd2b2ec306684cb806dc2b4fbb >>>>>>> The equivalent to i386-jit.cc is there: >>>>>>> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=22e3557e2d52f129f2bbfdc98688b945dba28dc9 >>>>>> >>>>>> [CCing Iain and Arthur re those patches; for reference, the patch >>>>>> being >>>>>> discussed is attached to : >>>>>> https://gcc.gnu.org/pipermail/jit/2024q1/001792.html ] >>>>>> >>>>>> One of my concerns about this patch is that we seem to be gaining >>>>>> code >>>>>> that's per-(frontend x config) which seems to be copied and pasted >>>>>> with >>>>>> a search and replace, which could lead to an M*N explosion. >>>>> >>>>> I think this is definitely already the case, and it would be worth >>>>> investigating if C/C++/Rust/jit can reuse a similar set of target >>>>> files, or how to factor them together. I imagine that all of these >>>>> components share similar needs for the targets they support. >>>>> >>>>>> >>>>>> Is there any real difference between the per-config code for the >>>>>> different frontends, or should there be a general "enumerate all >>>>>> features of the target" hook that's independent of the frontend? (but >>>>>> perhaps calls into it). >>>>>> >>>>>> Am I right in thinking that (rustc with default LLVM backend) has >>>>>> some >>>>>> set of feature strings that both (rustc with rustc_codegen_gcc) and >>>>>> gccrs are trying to emulate?  If so, is it presumably a goal that >>>>>> libgccjit gives identical results to gccrs?  If so, would it be crazy >>>>>> for libgccjit to consume e.g. config/i386/i386-rust.cc ? >>>>> >>>>> I think this would definitely make sense, and it could probably be >>>>> extended to other frontends. For the time being I think it makes >>>>> sense to try it out for gccrs and jit. But finding a fitting name >>>>> will be hard :) >>>>> >>>>> Best, >>>>> >>>>> Arthur >>>>> >>>>>> >>>>>> Dave >>>>>> >>>>>>> >>>>>>>> >>>>>>>> I'm not at expert at target hooks (or at the i386 backend), so if >>>>>>>> we >>>>>>>> do >>>>>>>> go with this approach I'd want someone else to review those parts >>>>>>>> of >>>>>>>> the patch. >>>>>>>> >>>>>>>> Have you verified that GCC builds with this patch with jit *not* >>>>>>>> enabled in the enabled languages? >>>>>>> >>>>>>> I will do. >>>>>>> >>>>>>>> >>>>>>>> [...snip...] >>>>>>>> >>>>>>>> A nitpick: >>>>>>>> >>>>>>>>> +.. function:: const char * \ >>>>>>>>> +              gcc_jit_target_info_arch (gcc_jit_target_info >>>>>>>>> *info) >>>>>>>>> + >>>>>>>>> +   Get the architecture of the currently running CPU. >>>>>>>> >>>>>>>> What does this string look like? >>>>>>>> How long does the pointer remain valid? >>>>>>> >>>>>>> It's the march string, like "znver2", for instance. >>>>>>> It remains valid until we free the gcc_jit_target_info object. >>>>>>> >>>>>>>> >>>>>>>> Thanks again; hope the above makes sense >>>>>>>> Dave >>>>>>>> >>>>>>> >>>>>>