I get
jamie@wanderer:~$ llc-3.6 --version
LLVM (http://llvm.org/):
LLVM version 3.6.2
Optimized build.
Built Aug 18 2015 (08:39:18).
Default target: x86_64-pc-linux-gnu
Host CPU: core-avx2
If try to set the arch at runtime I get:
jamie@wanderer:~$ julia --cpu-target=native
ERROR: Julia and the system image were compiled for different architectures.
Please delete or regenerate sys.{so,dll,dylib}.
I eventually found the instructions at
http://docs.julialang.org/en/latest/devdocs/sysimg/ and now
julia> @code_native count_ones(0)
.text
Filename: int.jl
Source line: 133
pushq %rbp
movq %rsp, %rbp
Source line: 133
popcntq %rdi, %rax
popq %rbp
ret
So that fixes my problem. Thanks for the help :) Would me submitting a
PR to add that link to the error message be worthwhile?
On a meta note, is this expected behaviour? I had gotten the
impression from digging through past discussions on codegen that even
if the system image is compiled to the lowest common denominator, user
code would be compiled for the native arch. Is that not true?
On 4 January 2016 at 00:47, Erik Schnetter <[email protected]> wrote:
> If you built Julia yourself, you will find LLVM's `llc` utility in the
> staging directory (i.e. in Julia's source tree):
>
> $ ./usr/bin/llc --version
> LLVM (http://llvm.org/):
> LLVM version 3.3
> Optimized build.
> Built Dec 17 2015 (12:43:16).
> Default target: x86_64-apple-darwin15.2.0
> Host CPU: core-avx2
>
> Registered Targets:
> x86 - 32-bit X86: Pentium-Pro and above
> x86-64 - 64-bit X86: EM64T and AMD64
>
> Here, "Host CPU" tells you what LLVM thinks about your system.
>
> The same information is inquired in multiple places in Julia's C++
> code that talks to LLVM, but I don't think this information is made
> available to Julia code.
>
> -erik
>
>
>
> On Sun, Jan 3, 2016 at 6:59 PM, Jamie Brandon <[email protected]> wrote:
>> Contrary to
>> https://groups.google.com/forum/#!msg/julia-users/B_5SYRaY9YI/0Auz3c_IWr8J
>> I'm not seeing popcnt emitted on my machine. Is there something additional I
>> need to do? Is there a way to see what cpu-target julia is setting?
>>
>> cat /proc/cpuinfo | grep popcnt
>> flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
>> pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb
>> rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology
>> nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est
>> tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt
>> tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln
>> pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1
>> avx2 smep bmi2 erms invpcid xsaveopt
>> flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
>> pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb
>> rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology
>> nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est
>> tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt
>> tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln
>> pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1
>> avx2 smep bmi2 erms invpcid xsaveopt
>> flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
>> pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb
>> rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology
>> nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est
>> tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt
>> tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln
>> pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1
>> avx2 smep bmi2 erms invpcid xsaveopt
>> flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
>> pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb
>> rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology
>> nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est
>> tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt
>> tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb pln
>> pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1
>> avx2 smep bmi2 erms invpcid xsaveopt
>> ...
>>
>> julia> @code_native count_ones(0)
>> .text
>> Filename: int.jl
>> Source line: 133
>> pushq %rbp
>> movq %rsp, %rbp
>> Source line: 133
>> movq %rdi, %rax
>> shrq %rax
>> movabsq $6148914691236517205, %rcx # imm = 0x5555555555555555
>> andq %rax, %rcx
>> subq %rcx, %rdi
>> movabsq $3689348814741910323, %rcx # imm = 0x3333333333333333
>> movq %rdi, %rax
>> andq %rcx, %rax
>> shrq $2, %rdi
>> andq %rcx, %rdi
>> addq %rax, %rdi
>> movabsq $72340172838076673, %rcx # imm = 0x101010101010101
>> movabsq $1085102592571150095, %rax # imm = 0xF0F0F0F0F0F0F0F
>> movq %rdi, %rdx
>> shrq $4, %rdx
>> addq %rdi, %rdx
>> andq %rdx, %rax
>> imulq %rcx, %rax
>> shrq $56, %rax
>> popq %rbp
>> ret
>>
>> jamie@wanderer:~$ julia --version
>> julia version 0.4.2
>
>
>
> --
> Erik Schnetter <[email protected]>
> http://www.perimeterinstitute.ca/personal/eschnetter/