Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions CMakeModules/FindMKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,14 @@ endif()

if(WIN32)
set(ENV_LIBRARY_PATHS "$ENV{LIB}")
message(VERBOSE "MKL environment variable(LIB): ${ENV_LIBRARY_PATHS}")
if (${CMAKE_VERSION} VERSION_GREATER 3.14)
message(VERBOSE "MKL environment variable(LIB): ${ENV_LIBRARY_PATHS}")
endif()
else()
string(REGEX REPLACE ":" ";" ENV_LIBRARY_PATHS "$ENV{LIBRARY_PATH}")
message(VERBOSE "MKL environment variable(LIBRARY_PATH): ${ENV_LIBRARY_PATHS}")
if (${CMAKE_VERSION} VERSION_GREATER 3.14)
message(VERBOSE "MKL environment variable(LIBRARY_PATH): ${ENV_LIBRARY_PATHS}")
endif()
endif()

# Finds and creates libraries for MKL with the MKL:: prefix
Expand Down Expand Up @@ -225,7 +229,9 @@ function(find_mkl_library)
intel64
intel64/gcc4.7)
if(MKL_${mkl_args_NAME}_LINK_LIBRARY)
message(VERBOSE "MKL_${mkl_args_NAME}_LINK_LIBRARY: ${MKL_${mkl_args_NAME}_LINK_LIBRARY}")
if (CMAKE_VERSION VERSION_GREATER 3.14)
message(VERBOSE "MKL_${mkl_args_NAME}_LINK_LIBRARY: ${MKL_${mkl_args_NAME}_LINK_LIBRARY}")
endif()
mark_as_advanced(MKL_${mkl_args_NAME}_LINK_LIBRARY)
endif()
endif()
Expand All @@ -252,7 +258,9 @@ function(find_mkl_library)
IntelSWTools/compilers_and_libraries/windows/tbb/lib/intel64/${msvc_dir}
)
if(MKL_${mkl_args_NAME}_STATIC_LINK_LIBRARY)
message(VERBOSE "MKL_${mkl_args_NAME}_STATIC_LINK_LIBRARY: ${MKL_${mkl_args_NAME}_STATIC_LINK_LIBRARY}")
if (CMAKE_VERSION VERSION_GREATER 3.14)
message(VERBOSE "MKL_${mkl_args_NAME}_STATIC_LINK_LIBRARY: ${MKL_${mkl_args_NAME}_STATIC_LINK_LIBRARY}")
endif()
mark_as_advanced(MKL_${mkl_args_NAME}_STATIC_LINK_LIBRARY)
endif()
endif()
Expand Down
28 changes: 28 additions & 0 deletions src/backend/opencl/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,34 @@ Node_ptr bufferNodePtr() {
shortname<T>(true));
}

namespace {
template<typename T>
void verifyTypeSupport() {
return;
}

template<>
void verifyTypeSupport<double>() {
if (!isDoubleSupported(getActiveDeviceId())) {
AF_ERROR("Double precision not supported", AF_ERR_NO_DBL);
}
}

template<>
void verifyTypeSupport<cdouble>() {
if (!isDoubleSupported(getActiveDeviceId())) {
AF_ERROR("Double precision not supported", AF_ERR_NO_DBL);
}
}

template<>
void verifyTypeSupport<common::half>() {
if (!isHalfSupported(getActiveDeviceId())) {
AF_ERROR("Half precision not supported", AF_ERR_NO_HALF);
}
}
} // namespace

template<typename T>
Array<T>::Array(dim4 dims)
: info(getActiveDeviceId(), dims, 0, calcStrides(dims),
Expand Down
13 changes: 0 additions & 13 deletions src/backend/opencl/err_opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,3 @@
throw SupportError(__PRETTY_FUNCTION__, __AF_FILENAME__, __LINE__, \
message, boost::stacktrace::stacktrace()); \
} while (0)

namespace opencl {
template<typename T>
void verifyTypeSupport() {
if ((std::is_same<T, double>::value || std::is_same<T, cdouble>::value) &&
!isDoubleSupported(getActiveDeviceId())) {
AF_ERROR("Double precision not supported", AF_ERR_NO_DBL);
} else if (std::is_same<T, common::half>::value &&
!isHalfSupported(getActiveDeviceId())) {
AF_ERROR("Half precision not supported", AF_ERR_NO_HALF);
}
}
} // namespace opencl
17 changes: 15 additions & 2 deletions src/backend/opencl/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ bool isDoubleSupported(int device) {
dev = *devMngr.mDevices[device];
}

return (dev.getInfo<CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE>() > 0);
return (dev.getInfo<CL_DEVICE_DOUBLE_FP_CONFIG>() > 0);
}

bool isHalfSupported(int device) {
Expand All @@ -343,7 +343,20 @@ bool isHalfSupported(int device) {
common::lock_guard_t lock(devMngr.deviceMutex);
dev = *devMngr.mDevices[device];
}
return (dev.getInfo<CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF>() > 0);
cl_device_fp_config config = 0;
size_t ret_size = 0;
// NVIDIA OpenCL seems to return error codes for CL_DEVICE_HALF_FP_CONFIG.
// It seems to be a bug in their implementation. Assuming if this function
// fails that the implemenation does not support f16 type. Using the C API
// to avoid exceptions
cl_int err =
clGetDeviceInfo(dev(), CL_DEVICE_HALF_FP_CONFIG,
sizeof(cl_device_fp_config), &config, &ret_size);

if (err)
return false;
else
return config > 0;
}

void devprop(char* d_name, char* d_platform, char* d_toolkit, char* d_compute) {
Expand Down