-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix pyilmbase tests, static compilation
- python extensions must be shared, so can not follow the overall lib type for the library. - the code should be compiled fPIC when building a static library such that it can be linked into a .so - remove the dependency on the particle python extension in the numpy test - add environment variables such that the python tests will work in the build tree without a "make install" (win32 doesn't neede ld_library_path, but it doesn't hurt, but may need path?) Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
- Loading branch information
1 parent
4481442
commit 75c918b
Showing
10 changed files
with
585 additions
and
619 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
ADD_TEST ( PyIexTest | ||
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pyIexTest.in | ||
) | ||
) | ||
|
||
SET_TESTS_PROPERTIES ( PyIexTest PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/../PyIex;LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/../../IlmBase/Iex:${CMAKE_CURRENT_BINARY_DIR}/../PyIex" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
ADD_TEST ( PyImathMumpyTest | ||
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pyImathMumpyTest.in | ||
ADD_TEST ( PyImathNumpyTest | ||
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pyImathNumpyTest.in -nocuda | ||
) | ||
|
||
SET_TESTS_PROPERTIES ( PyImathNumpyTest PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/../PyIex:${CMAKE_CURRENT_BINARY_DIR}/../PyImath:${CMAKE_CURRENT_BINARY_DIR}/../PyImathNumpy;LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/../../IlmBase/Iex:${CMAKE_CURRENT_BINARY_DIR}/../../IlmBase/IexMath:${CMAKE_CURRENT_BINARY_DIR}/../../IlmBase/Imath:${CMAKE_CURRENT_BINARY_DIR}/../PyIex:${CMAKE_CURRENT_BINARY_DIR}/../PyImath:${CMAKE_CURRENT_BINARY_DIR}/../PyImathNumpy" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,33 @@ | ||
import sys | ||
|
||
if len(sys.argv) != 2 or sys.argv[1] not in ['-cuda','-nocuda']: | ||
print "Usage: %s <-cuda|-nocuda>" % (sys.argv[0]) | ||
sys.exit(1) | ||
|
||
use_cuda = False | ||
if sys.argv[1] == '-cuda': | ||
use_cuda = True | ||
|
||
if use_cuda: | ||
import pycuda.autoinit | ||
import pycuda.driver as drv | ||
from pycuda.compiler import SourceModule | ||
mod = SourceModule(""" | ||
__global__ void multiply_them(float *dest, float *a, float *b) | ||
{ | ||
const int i = threadIdx.x; | ||
dest[i] = a[i] * b[i]; | ||
} | ||
__global__ void multiply_them_int(int *dest, int *a, int *b) | ||
{ | ||
const int i = threadIdx.x; | ||
dest[i] = a[i] * b[i]; | ||
} | ||
""") | ||
multiply_them = mod.get_function("multiply_them") | ||
multiply_them_int = mod.get_function("multiply_them_int") | ||
from __future__ import print_function | ||
|
||
import sys | ||
import numpy | ||
import imathnumpy | ||
from imath import FloatArray, IntArray | ||
import particle | ||
|
||
length = 10 | ||
fa = particle.random(1,5,length) | ||
fb = particle.random(1,5,length) | ||
a = numpy.random.uniform(1,5,length) | ||
b = numpy.random.uniform(1,5,length) | ||
fdest = FloatArray(length) | ||
|
||
a = imathnumpy.arrayToNumpy(fa) | ||
b = imathnumpy.arrayToNumpy(fb) | ||
dest = imathnumpy.arrayToNumpy(fdest) | ||
dest[:] = a * b | ||
|
||
if use_cuda: | ||
multiply_them(drv.Out(dest), drv.In(a), drv.In(b), block=(length,1,1)) | ||
else: | ||
dest[:] = a * b | ||
results = fdest - a*b | ||
|
||
results = fdest - fa*fb | ||
print( "a: {}".format(a) ) | ||
print( "b: {}".format(b) ) | ||
print( "dest: {}".format(fdest) ) | ||
print( "diff: {}".format(results) ) | ||
|
||
print "a:", particle.join(fa,' ') | ||
print "b:", particle.join(fb,' ') | ||
print "dest:", particle.join(fdest,' ') | ||
print "diff:", particle.join(results,' ') | ||
|
||
ia = particle.floor(particle.random(1,5,length)) | ||
ib = particle.floor(particle.random(1,5,length)) | ||
ia = numpy.floor(numpy.random.uniform(1,5,length)) | ||
ib = numpy.floor(numpy.random.uniform(1,5,length)) | ||
idest = IntArray(length) | ||
|
||
a = imathnumpy.arrayToNumpy(ia) | ||
b = imathnumpy.arrayToNumpy(ib) | ||
dest = imathnumpy.arrayToNumpy(idest) | ||
|
||
if use_cuda: | ||
multiply_them_int(drv.Out(dest), drv.In(a), drv.In(b), block=(length,1,1)) | ||
else: | ||
dest[:] = a * b | ||
|
||
results = idest - ia*ib | ||
|
||
print "a:", particle.join(ia,' ') | ||
print "b:", particle.join(ib,' ') | ||
print "dest:", particle.join(idest,' ') | ||
print "diff:", particle.join(results,' ') | ||
idest = imathnumpy.arrayToNumpy(idest) | ||
idest[:] = ia * ib | ||
iresults = idest - ia*ib | ||
|
||
print( "a: {}".format(ia) ) | ||
print( "b: {}".format(ib) ) | ||
print( "dest: {}".format(idest) ) | ||
print( "diff: {}".format(iresults) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
ADD_TEST ( PyImathTest | ||
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pyImathTest.in | ||
) | ||
|
||
SET_TESTS_PROPERTIES ( PyImathTest PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/../PyIex:${CMAKE_CURRENT_BINARY_DIR}/../PyImath;LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/../../IlmBase/Iex:${CMAKE_CURRENT_BINARY_DIR}/../../IlmBase/IexMath:${CMAKE_CURRENT_BINARY_DIR}/../../IlmBase/Imath:${CMAKE_CURRENT_BINARY_DIR}/../PyIex:${CMAKE_CURRENT_BINARY_DIR}/../PyImath" ) |
Oops, something went wrong.