Closed afif-ishamsyah closed 2 years ago
Where did you test it. Only Windows or also Linux. I get an compiler error, if I try it on Linux.
I only tested it in windows. I will try it on linux
Please do this.
I already fixed it. It should work on both linux and windows
Please add also some test. Don't need to be to much.
I extended the CMakeLists.txt
to make CUDA optional. Building the project with CUDA will be enabled with cmake .. -DENABLE_CUDA=ON
. All .cu
files needs to be renamed to .cpp
files. In the CMake files, it is required that the following code is added to each target, which compiles code:
if(TARGET cpyref::cuda)
target_link_libraries(${_targetName} PUBLIC cpyref::cuda)
set_cuda_language(${_targetName})
endif()
If the CUDA build is enabled, the the variable ENABLED_CUDA
will be defined and can be used in the c++ preprocessor:
#ifdef ENABLED_CUDA
int cuda_only_variable = 3;
#endif
Please implement also a python_binding, to ask which CPU and GPU types are available. For example, it can return an enum value.
is the python binding will be used to know whether the algorithm we are using is on CPU or GPU? or the type of CPU/GPU? (like intel. amd, nvidia, etc)
and what is best way to implement #ifdef ENABLED_CUDA on python side? is it possible?
is the python binding will be used to know whether the algorithm we are using is on CPU or GPU? or the type of CPU/GPU? (like intel. amd, nvidia, etc)
and what is best way to implement #ifdef ENABLED_CUDA on python side? is it possible?
On the python side, you should be able to ask, what is available, e.g.
if len(binding.get_all_acc) == 0:
raise Error("no acc avaiable")
print("avaiable acc: ")
for acc in binding.get_all_acc:
print(acc)
if binding.is_cuda_algo:
algo = binding.CudaAlgo()
elif binding.is_cpu_algo:
algo = binding.CPUAlgo()
It think, you need to do this via preprocessor defines in the binding.cpp
Mem_ref for CPU numpy is done