Skip to content

Commit

Permalink
Added simple Intel support for tests
Browse files Browse the repository at this point in the history
Added -g flag to the compile options to include debug information
Some tests are not fixed yet, more changes are coming
However, this version should be usable okay-ish
  • Loading branch information
nikitavlaev committed Oct 19, 2020
1 parent 62c93e6 commit 8f1c167
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ elseif( CMAKE_COMPILER_IS_GNUCC )
message( STATUS "Detected GNU compiler collection" )

if( clSPARSE_BUILD64 )
set( CMAKE_CXX_FLAGS "-m64 ${CMAKE_CXX_FLAGS}" )
set( CMAKE_CXX_FLAGS "-g -m64 ${CMAKE_CXX_FLAGS}" )
set( CMAKE_C_FLAGS "-m64 ${CMAKE_C_FLAGS}" )
else( )
set( CMAKE_CXX_FLAGS "-m32 ${CMAKE_CXX_FLAGS}" )
set( CMAKE_CXX_FLAGS "-g -m32 ${CMAKE_CXX_FLAGS}" )
set( CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}" )
endif( )
else( )
Expand Down
12 changes: 10 additions & 2 deletions src/tests/resources/opencl_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ cl::Device getDevice( cl_platform_type pID, cl_uint dID )

std::map<std::string, int> pNames;

//search for AMD or NVIDIA
//search for AMD, NVIDIA or INTEL
cl_int pIndex = -1;
for( const auto& p : platforms )
{
Expand All @@ -96,13 +96,21 @@ cl::Device getDevice( cl_platform_type pID, cl_uint dID )

//get index of desired platform;
std::string desired_platform_name;
int device_type;
if( pID == AMD )
{
desired_platform_name = amd_platform_str;
device_type = CL_DEVICE_TYPE_GPU;
}
else if( pID == NVIDIA )
{
desired_platform_name = nvidia_platform_str;
device_type = CL_DEVICE_TYPE_GPU;
}
else if( pID == INTEL )
{
desired_platform_name = intel_platform_str;
device_type = CL_DEVICE_TYPE_CPU;
}
else
{
Expand All @@ -122,7 +130,7 @@ cl::Device getDevice( cl_platform_type pID, cl_uint dID )
}

std::vector<cl::Device> devices;
platforms[ pIndex ].getDevices( CL_DEVICE_TYPE_GPU, &devices );
platforms[ pIndex ].getDevices( device_type, &devices );

assert( dID < devices.size( ) );

Expand Down
4 changes: 3 additions & 1 deletion src/tests/resources/opencl_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@

typedef enum _platform {
AMD = 0,
NVIDIA
NVIDIA = 1,
INTEL = 2,
} cl_platform_type;

const static std::string amd_platform_str = "AMD";
const static std::string nvidia_platform_str = "NVIDIA";
const static std::string intel_platform_str = "Intel(R)";

cl_int getPlatforms( cl_platform_id **platforms, cl_uint* num_platforms );

Expand Down
6 changes: 5 additions & 1 deletion src/tests/test-blas1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ int main (int argc, char* argv[])
desc.add_options()
("help,h", "Produce this message.")
("platform,l", po::value(&platform)->default_value("AMD"),
"OpenCL platform: AMD or NVIDIA.")
"OpenCL platform: AMD, NVIDIA or INTEL.")
("device,d", po::value(&dID)->default_value(0),
"Device id within platform.")
("size,s",po::value(&size)->default_value(1024),
Expand Down Expand Up @@ -669,6 +669,10 @@ int main (int argc, char* argv[])
{
pID = NVIDIA;
}
else if ("INTEL" == platform)
{
pID = INTEL;
}
else
{

Expand Down
6 changes: 5 additions & 1 deletion src/tests/test-blas2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ int main (int argc, char* argv[])
("help,h", "Produce this message.")
("path,p", po::value(&path)->required(), "Path to matrix in mtx format.")
("platform,l", po::value(&platform)->default_value("AMD"),
"OpenCL platform: AMD or NVIDIA.")
"OpenCL platform: AMD, NVIDIA or INTEL.")
("device,d", po::value(&dID)->default_value(0),
"Device id within platform.")
("alpha,a", po::value(&alpha)->default_value(1.0),
Expand Down Expand Up @@ -439,6 +439,10 @@ int main (int argc, char* argv[])
{
pID = NVIDIA;
}
else if ("INTEL" == platform)
{
pID = INTEL;
}
else
{

Expand Down
6 changes: 5 additions & 1 deletion src/tests/test-blas3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ int main (int argc, char* argv[])
("path,p", po::value(&path)->required(), "Path to matrix in mtx format.")
("function,f", po::value<std::string>(&function)->default_value("SpMdM"), "Sparse functions to test. Options: SpMdM, SpMSpM, All")
("platform,l", po::value(&platform)->default_value("AMD"),
"OpenCL platform: AMD or NVIDIA.")
"OpenCL platform: AMD, NVIDIA or INTEL.")
("device,d", po::value(&dID)->default_value(0),
"Device id within platform.")
("alpha,a", po::value(&alpha)->default_value(1.0),
Expand Down Expand Up @@ -707,6 +707,10 @@ int main (int argc, char* argv[])
{
pID = NVIDIA;
}
else if ("INTEL" == platform)
{
pID = INTEL;
}
else
{
std::cout << "The platform option is missing or is ill defined!\n";
Expand Down
20 changes: 19 additions & 1 deletion src/tests/test-clsparse-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ TEST( clsparseInit, control )

}

TEST( clsparseInit, cpp_interface )
TEST( pID, clsparseInit, cpp_interface )
{
// Init OpenCL environment;
cl_int cl_status;
Expand Down Expand Up @@ -128,6 +128,24 @@ TEST( clsparseInit, cpp_interface )

// Get device from platform
std::vector<cl::Device> devices;

int device_type;
if( pID == AMD )
{
device_type = CL_DEVICE_TYPE_GPU;
}
else if( pID == NVIDIA )
{
device_type = CL_DEVICE_TYPE_GPU;
}
else if( pID == INTEL )
{
device_type = CL_DEVICE_TYPE_CPU;
}
else
{
throw std::string( "No such platform pID: " + std::to_string( pID ) );
}
cl_status = platform.getDevices( CL_DEVICE_TYPE_GPU, &devices );

if( cl_status != CL_SUCCESS )
Expand Down
6 changes: 5 additions & 1 deletion src/tests/test-conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ int main (int argc, char* argv[])
("help,h", "Produce this message.")
("path,p", po::value(&path)->required(), "Path to matrix in mtx format.")
("platform,l", po::value(&platform)->default_value("AMD"),
"OpenCL platform: AMD or NVIDIA.")
"OpenCL platform: AMD, NVIDIA or INTEL.")
("device,d", po::value(&dID)->default_value(0),
"Device id within platform.")
("no_zeroes,z", po::bool_switch()->default_value(false),
Expand Down Expand Up @@ -781,6 +781,10 @@ int main (int argc, char* argv[])
{
pID = NVIDIA;
}
else if ("INTEL" == platform)
{
pID = INTEL;
}
else
{

Expand Down
6 changes: 5 additions & 1 deletion src/tests/test-solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ int main (int argc, char* argv[])
("help,h", "Produce this message.")
("path,p", po::value(&path)->required(), "Path to matrix in mtx format.")
("platform,l", po::value(&platform)->default_value("AMD"),
"OpenCL platform: AMD or NVIDIA.")
"OpenCL platform: AMD, NVIDIA or INTEL.")
("device,d", po::value(&dID)->default_value(0),
"Device id within platform.")
("relative,r", po::value(&relativeTolerance)->default_value(1e-2),
Expand Down Expand Up @@ -317,6 +317,10 @@ int main (int argc, char* argv[])
{
pID = NVIDIA;
}
else if ("INTEL" == platform)
{
pID = INTEL;
}
else
{

Expand Down

0 comments on commit 8f1c167

Please sign in to comment.