diff --git a/README.md b/README.md index c40ab42..c86e4d3 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,17 @@ The command generates the following example.c.patch patch: { int i,x; ``` + +If you want to use a differnt target for your code you can create a file targets.conf + +For example + +``` +#if defined(i386__) || defined(__i386__) || defined(_M_IX86) || defined(_M_IX86) || defined(__X86__) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64) + __attribute__((target_clones("avx2","arch=haswell","default"))) +#endif +``` + ### 3. Apply the patch Using the example.c.patch file, apply the patch to example.c: diff --git a/make-fmv-patch.pl b/make-fmv-patch.pl index ddc54e7..69f7c3a 100644 --- a/make-fmv-patch.pl +++ b/make-fmv-patch.pl @@ -26,13 +26,27 @@ # USAGE: perl fmvpatches.pl - my %f; my $fmv = {}; my ($log_file, $source_path) = @ARGV; sub patch_function { - my $avx2 = '__attribute__((target_clones("avx2","arch=atom","default")))'."\n"; + + my $attribute = ""; + my $target_clones = 'targets.conf'; + + if (-e $target_clones) { + open(my $fh, '<:encoding(UTF-8)', $target_clones) + or die "Could not open file '$target_clones' $!"; + while (my $row = <$fh>) { + chomp $row; + $attribute= $attribute.$row."\n"; + } + + }else { + $attribute = '__attribute__((target_clones("avx2","arch=atom","default")))'."\n"; + } + my ($file,@patch_line) = @_; my $patch_file = "$file"."~"; @@ -48,7 +62,7 @@ sub patch_function { last if $. == ($line_num - 1); } - print $out $avx2; + print $out $attribute; } while( <$in> ) { print $out $_; diff --git a/targets.conf.txt b/targets.conf.txt new file mode 100644 index 0000000..ab742fd --- /dev/null +++ b/targets.conf.txt @@ -0,0 +1,3 @@ +#if defined(i386__) || defined(__i386__) || defined(_M_IX86) || defined(_M_IX86) || defined(__X86__) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64) + __attribute__((target_clones("avx2","arch=haswell","default"))) +#endif