fix & updated interface C++ -> Cython -> Python

This commit is contained in:
Jerome Kieffer 2012-06-21 13:36:15 +02:00
parent fc71ff362f
commit 802d8a254a
5 changed files with 573 additions and 232 deletions

3
benchmark/benchmark.py Normal file → Executable file
View File

@ -104,6 +104,9 @@ out=ai.xrpd2(data,500,360)""" % (param, fn)
print("Failed to find an OpenCL GPU (useFp64:%s) %s" % (useFp64, error))
continue
print(" device: %s.%s" % ai._ocl.get_contexed_Ids())
# print(ai._ocl.get_platform_info())
# print(ai._ocl.get_device_info())
self.print_init(t1 - t0)
ref = ai.xrpd(data, N)
R = utilstest.Rwp(res, ref)

File diff suppressed because it is too large Load Diff

View File

@ -345,6 +345,30 @@ cdef class Integrator1d:
self.cpp_integrator.get_contexed_Ids(platform, device)
return (platform, device)
def get_platform_info(self):
"""
@return: dict with platform info
"""
out={}
out["name"] = self.cpp_integrator.platform_info.name
out["vendor"] = self.cpp_integrator.platform_info.vendor
out["extensions"] = self.cpp_integrator.platform_info.extensions
out["version"] = self.cpp_integrator.platform_info.version
return out
def get_device_info(self):
"""
@return: dict with device info
"""
out={}
out["name"] = self.cpp_integrator.device_info.name
out["type"] = self.cpp_integrator.device_info.type
out["version"] = self.cpp_integrator.device_info.version
out["driver_version"] = self.cpp_integrator.device_info.driver_version
out["extensions"] = self.cpp_integrator.device_info.extensions
out["global_mem"]=self.cpp_integrator.device_info.global_mem
return out
_INTEGRATORS_1D = {} #key=(Nimage,NBins), value=instance of Integrator1d
lock = threading.Semaphore()

View File

@ -206,7 +206,7 @@ void ocl::show_device_details(int ignoreStream){
fprintf(tmp,"%s Device version: %s\n", heading.c_str(), device_info.version);
fprintf(tmp,"%s Device driver version: %s\n", heading.c_str(), device_info.driver_version);
fprintf(tmp,"%s Device extensions: %s\n", heading.c_str(), device_info.extensions);
fprintf(tmp,"%s Device Max Memory: %s\n", heading.c_str(), device_info.global_mem);
fprintf(tmp,"%s Device Max Memory: %ul\n", heading.c_str(), device_info.global_mem);
}
return;
}

View File

@ -1,5 +1,33 @@
from libcpp cimport bool
cdef extern from "ocl_tools.h":
# OpenCL tools platform information struct
#
# It can be passed to ocl_platform_info to
# retrieve and save platform information
# for the current context
struct ocl_plat_t:
char * name
char * vendor
char * version
char * extensions
#OpenCL tools platform information struct
# It can be passed to ocl_device_info to
# retrieve and save device information
# for the current context
struct ocl_dev_t:
char * name
char type[4]
char * version
char * driver_version
char * extensions
unsigned long global_mem
cdef extern from "ocl_xrpd1d.hpp":
cdef cppclass ocl_xrpd1D_fullsplit:
# Default constructor - Prints messages on stdout
ocl_xrpd1D_fullsplit()
@ -119,3 +147,9 @@ cdef extern from "ocl_xrpd1d.hpp":
#bit 7: use dummy value
int get_status() nogil
#A couple of members of the class containing the platform_info and device_info
ocl_plat_t platform_info
ocl_dev_t device_info