-
Notifications
You must be signed in to change notification settings - Fork 0
/
genipppc
executable file
·181 lines (156 loc) · 6.26 KB
/
genipppc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
import platform as pf
from sys import argv, exit, platform
#from string import split, lower
from os import getenv, readlink
from os.path import islink, join, dirname, isfile
from re import search
program = 'genipppc'
version = '0.3'
verdate = '20131105'
author = 'Walter Brisken <[email protected]>'
def usage(prog):
print('\n%s ver. %s %s %s\n' % (program, version, verdate, author))
print('Usage: %s [options] <ipp path> [<ipp version>]\n')
print('options can include:')
print(' -h, --help print help info\n')
print('<ipp path> is the install path of Intel Performance Primitives\n')
def getippversion(path):
if islink(path):
path = join(dirname(path), readlink(path))
# First try ippversion.h
ippheader = path+'/include/ippversion.h'
if not isfile(ippheader):
ippheader = path+'/ipp/include/ippversion.h'
if not isfile(ippheader):
ippheader = path+'/composerxe/ipp/include/ippversion.h'
if isfile(ippheader):
path += '/composerxe'
if not isfile(ippheader):
ippheader = path+'/oneapi/ipp/latest/include/ippversion.h'
if isfile(ippheader):
path += '/oneapi/ipp/latest/'
if not isfile(ippheader):
ippheader = ''
if (ippheader==''):
print("Warning: ippversion.h not found, relying on IPP path ", path)
s = path.split('/')
possibilities = []
for part in s:
t = path.split('.')
if len(t) > 1:
possibilities.append(part)
if len(possibilities) < 1:
print('Sorry, cannot determine ipp version from path')
exit(0)
if len(possibilities) > 1:
print('Guessing version == %s' % possibilities[-1])
return (path, possibilities[-1])
else:
print("Reading version from ", ippheader)
major = minor = None
for line in open(ippheader):
m = search('#define\s+IPP_VERSION_STR\s+"(\S+)"', line)
if (m != None):
print("Got version ", m.group(1))
return (path, m.group(1))
if (major == None):
major = search('#define\s+IPP_VERSION_MAJOR\s+(\S+)', line)
if (minor == None):
minor = search('#define\s+IPP_VERSION_MINOR\s+(\S+)', line)
if (major != None and minor != None):
print("Have version ", major.group(1) + "." + minor.group(1))
return (path, major.group(1) + "." + minor.group(1))
print("Sorry, cannot find IPP_VERSION_STR in ", ippheader)
exit(0)
# fixme: possibly should use uname to get this information
def getarch():
bs = getenv('DIFXBITS')
if bs != None and bs != "32" and bs != "64" and bs != "128":
print("Invalid DIFXBITS: " + bs)
bs = None
pybits = pf.architecture()[0][0:2]
if bs == None:
print("Note: DIFXBITS was not set - used platform.architecture to determine that bits is " + pybits)
return int(pybits)
if int(bs) != int(pybits):
print("WARNING! DIFXBITS is " + bs + " but platform.architecture says number of bits is " + pybits)
print("Assuming DIFXBITS was set correctly...")
return int(bs)
return int(bs)
def genipppc(path, ippversion):
# if no path supplied, take it from $IPPROOT
if path == '':
path = getenv('IPPROOT')
# Still not set?
if path == None:
print('Sorry, $IPPROOT not set and no path given')
return
# if no version actually supplied, try to guess from path
if ippversion == '':
(path, ippversion) = getippversion(path)
ipparch = getarch()
major = int(ippversion.split('.')[0])
out = open('ipp.pc', 'w')
out.write('base = %s\n' % path)
out.write('\n')
out.write('Name: ipp\n')
out.write('Description: Intel Performance Primitives\n')
out.write('Requires:\n')
out.write('Version: %s\n' % ippversion)
print("Platform=", platform)
print("ipparch=", ipparch)
if major == 6 or major == 5:
if platform == "darwin":
libdir = 'Libraries'
else:
libdir = 'sharedlib'
if ipparch == 64 and platform != 'darwin' :
out.write('Libs: -Wl,-rpath,${base}/%s -L${base}/%s -lippsem64t -lguide -lippvmem64t -lippcoreem64t\n' % (libdir,libdir))
else:
out.write('Libs: -Wl,-rpath,${base}/%s -L${base}/%s -lipps -lguide -lippvm -lippcore\n' % (libdir,libdir))
out.write('Cflags: -I${base}/include\n')
elif major == 7 or major == 8 or major == 9 or major >= 2017:
if platform == "darwin":
if major < 2021:
out.write('Libs: -Wl,-rpath,${base}/ipp/lib -L${base}/ipp/lib -lipps -lippvm -lippcore\n')
else:
out.write('Libs: -Wl,-rpath,${base}/lib -L${base}/lib -lipps -lippvm -lippcore\n')
else:
if ipparch == 32:
libdir = 'ia32'
else:
libdir = 'intel64'
out.write('Libs: -Wl,-rpath,${base}/lib/%s -Wl,-rpath,${base}/ipp/lib/%s -L${base}/lib/%s -L${base}/ipp/lib/%s -L${base}/compiler/lib/%s -lipps -lippvm -lippcore' % (libdir,libdir,libdir,libdir,libdir))
if major < 2000:
out.write(" -liomp5")
out.write("\n")
if major == 7 or major == 8:
out.write('Cflags: -I${base}/ipp/include\n')
elif major < 2021:
out.write('Cflags: -DIPP9 -I${base}/ipp/include\n')
else:
out.write('Cflags: -DIPP9 -I${base}/include\n') # oneapi setup
else:
print('Sorry, IPP %d not yet supported by this script\n' % major)
out.close()
ipppath = ''
ippversion = ''
for a in argv[1:]:
if a[0] == '-':
if a in ['--help', '-h']:
usage(argv[0])
exit(0)
else:
print('Unrecognised option: %s . See help with -h .' % a)
exit(0)
else:
if ipppath == '':
ipppath = a
elif ippversion == '':
ippversion = a
else:
print('Unexpected parameter: %s . See help with -h .' % a)
genipppc(ipppath, ippversion)