<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Alunduil&#039;s Hosting &#187; cflags</title>
	<atom:link href="http://www.alunduil.com/tag/cflags/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alunduil.com</link>
	<description>Gentoo Hackery and Other Fun ...</description>
	<lastBuildDate>Sun, 01 May 2011 22:00:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Optimizing Gentoo CFLAGS (Part II)</title>
		<link>http://www.alunduil.com/2011/02/20/optimizing-gentoo-cflags-part-ii/</link>
		<comments>http://www.alunduil.com/2011/02/20/optimizing-gentoo-cflags-part-ii/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 23:00:46 +0000</pubDate>
		<dc:creator>Alex Brandt</dc:creator>
				<category><![CDATA[Linux Guides]]></category>
		<category><![CDATA[cflags]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://www.alunduil.com/?p=205</guid>
		<description><![CDATA[Introduction As I mentioned las﻿t time, you want to be comfortable with the existing documentation on CFLAGS before going crazy trying to play with. It also helps to have a good understanding of what you&#8217;re doing to the code when you modify these &#8220;sacred&#8221; parameters. Alright, now that the CYA is out of the way <a href='http://www.alunduil.com/2011/02/20/optimizing-gentoo-cflags-part-ii/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<h1>Introduction</h1>
<p>As I mentioned <a href="http://www.alunduil.com/2009/12/18/optimizing-gentoo-cflags/">las﻿t time</a>, you want to be comfortable with the existing documentation on CFLAGS before going crazy trying to play with.  It also helps to have a good understanding of what you&#8217;re doing to the code when you modify these &#8220;sacred&#8221; parameters.</p>
<p>Alright, now that the CYA is out of the way let&#8217;s take this one step further.  Last time we talked about figuring out which instruction sets your processor understood and how to figure out what `-m` flags would get those instruction sets into the binaries on your system.  This time we&#8217;ll be talking about making sure those same flags are in your use flags (just to be sure they&#8217;re picked up by the system).</p>
<h1>Finding Flag Names</h1>
<p>So how do we find the flags that do what we want?  Well, as always BASH is our friend and can be used to find this answer in a mostly automated fashion:</p>
<pre>. /etc/make.conf &amp;&amp; gcc -Q -c -v ${CFLAGS} --help=target | grep enabled</pre>
<p>This displays the currently enabled flags based on your CFLAGS parameter and allows us to find which flags have use flags with the following one liner:</p>
<pre>gawk '/-m.*/ { print $1 }' | cut -d 'm' --complement -f 1 | xargs -I{} equery h "{}"</pre>
<h1>Conclusion</h1>
<p>Using a little scripting we can extract the necessary information to quickly determine if there are any use flags we should be adding for particular compiler flags that our system might support.  With this last level of optimization beyond the previous time&#8217;s we should be ready to move on to -O3 (for the daring) and watch our machine&#8217;s nose bleed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alunduil.com/2011/02/20/optimizing-gentoo-cflags-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing Gentoo CFLAGS</title>
		<link>http://www.alunduil.com/2009/12/18/optimizing-gentoo-cflags/</link>
		<comments>http://www.alunduil.com/2009/12/18/optimizing-gentoo-cflags/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 06:39:52 +0000</pubDate>
		<dc:creator>Alex Brandt</dc:creator>
				<category><![CDATA[Linux Guides]]></category>
		<category><![CDATA[cflags]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[instructions]]></category>
		<category><![CDATA[isa]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://www.alunduil.com/?p=63</guid>
		<description><![CDATA[Starting Off Make sure you&#8217;ve at least looked at the following document: Gentoo Optimization Guide. Checking Flags The only real change we want to make to our system are simple things we know will not break it. Thus, we only look at making sure that we have the correct flags for enabling all of the <a href='http://www.alunduil.com/2009/12/18/optimizing-gentoo-cflags/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<h1><strong>Starting Off</strong></h1>
<p>Make sure you&#8217;ve at least looked at the following document: <a href="http://www.gentoo.org/doc/en/gcc-optimization.xml">Gentoo Optimization Guide</a>.</p>
<h1><strong>Checking Flags</strong></h1>
<p>The only real change we want to make to our system are simple things we know will not break it.  Thus, we only look at making sure that we have the correct flags for enabling all of the instruction sets that our processor has available.</p>
<h1><strong>Checking Processor</strong></h1>
<p>grep flags /proc/cpuinfo | grep uniq</p>
<p>This pulls out all of the features of the processor as detected by the kernel.  Example output is shown (line breaks added for readability):</p>
<p>alunduil@elijah ~ $ grep flags /proc/cpuinfo | uniq<br />
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr<br />
pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall<br />
nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good<br />
extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic<br />
cr8_legacy 3dnowprefetch</p>
<h1><strong>Checking Default Flags</strong></h1>
<p>gcc does a great job of determining what flags should be set by using the new -march=native flag (which you should have set by this point).  Using the following command we can double check that all of the instructions we want enabled are enabled:</p>
<p>gcc -Q -c -v -march=native &#8211;help=target | grep disabled</p>
<p>If anything appears in the resulting list, it&#8217;s not enabled and should be enabled by adding the appropriate -m flag.  For my cpu this results in: -msse3 -m3dnow.</p>
<h1><strong>Putting it Together</strong></h1>
<p>By adding the original guide with a check for instructions, we allow gcc to utilize the instructions that were specifically created for uses we may have (multimedia, extended math, etc).</p>
<p>The resulting CFLAG variable that I placed in my make.conf from the above discussion:</p>
<p>CFLAGS=&#8221;-march=native -O2 -pipe -msse3 -m3dnow&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alunduil.com/2009/12/18/optimizing-gentoo-cflags/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached (User agent is rejected)
Database Caching 2/6 queries in 0.006 seconds using memcached
Object Caching 293/293 objects using memcached

Served from: www.alunduil.com @ 2012-02-06 10:24:14 -->
