-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
107 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.hip |
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// In applying this license CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
/// \file testGPUSMatrixImp.cu | ||
/// \author Matteo Concas | ||
|
||
#define BOOST_TEST_MODULE Test GPUSMatrixImpl | ||
#ifdef __HIPCC__ | ||
#define GPUPLATFORM "HIP" | ||
#include "hip/hip_runtime.h" | ||
#else | ||
#define GPUPLATFORM "CUDA" | ||
#endif | ||
|
||
#include <boost/test/unit_test.hpp> | ||
#include <iostream> | ||
|
||
cudaError_t gpuCheckError(cudaError_t gpuErrorCode) | ||
{ | ||
if (gpuErrorCode != cudaSuccess) { | ||
std::cerr << "ErrorCode " << gpuErrorCode << " " << cudaGetErrorName(gpuErrorCode) << ": " << cudaGetErrorString(gpuErrorCode) << std::endl; | ||
exit(-1); | ||
} | ||
return gpuErrorCode; | ||
} | ||
|
||
__global__ void kernel() | ||
{ | ||
printf("Hello world from device\n"); | ||
} | ||
|
||
struct GPUSMatrixImplFixture { | ||
GPUSMatrixImplFixture() | ||
{ | ||
std::cout << "GPUSMatrixImplFixture" << std::endl; | ||
// Get the number of GPU devices | ||
int deviceCount; | ||
cudaGetDeviceCount(&deviceCount); | ||
|
||
if (deviceCount == 0) { | ||
std::cerr << "No " << GPUPLATFORM << " devices found" << std::endl; | ||
} | ||
|
||
for (int iDevice = 0; iDevice < deviceCount; ++iDevice) { | ||
cudaDeviceProp deviceProp; | ||
cudaGetDeviceProperties(&deviceProp, iDevice); | ||
|
||
std::cout << GPUPLATFORM << " Device " << iDevice << ": " << deviceProp.name << std::endl; | ||
} | ||
|
||
kernel<<<1, 1>>>(); | ||
gpuCheckError(cudaDeviceSynchronize()); | ||
i = 3; | ||
} | ||
|
||
~GPUSMatrixImplFixture() | ||
{ | ||
std::cout << "~GPUSMatrixImplFixture" << std::endl; | ||
} | ||
|
||
int i; | ||
}; | ||
|
||
BOOST_FIXTURE_TEST_CASE(DummyFixtureUsage, GPUSMatrixImplFixture) | ||
{ | ||
BOOST_TEST(i == 3); | ||
} |
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