Apply .clangformat to all repo source files

Change-Id: I7e79c6058f0303f9a98911e3b7dd2e8596079344
This commit is contained in:
Maneesh Gupta
2018-03-12 11:29:03 +05:30
parent eee7fa6072
commit 9e47fccc89
293 ha cambiato i file con 43980 aggiunte e 45830 eliminazioni
@@ -30,20 +30,20 @@ THE SOFTWARE.
#include "hip/hip_runtime.h"
#include "test_common.h"
int main( void ) {
hipDeviceProp_t prop;
int main(void) {
hipDeviceProp_t prop;
int dev;
hipGetDevice( &dev ) ;
printf( "ID of current HIP device: %d\n", dev );
hipGetDevice(&dev);
printf("ID of current HIP device: %d\n", dev);
memset( &prop, 0, sizeof( hipDeviceProp_t ) );
memset(&prop, 0, sizeof(hipDeviceProp_t));
prop.major = 1;
prop.minor = 3;
hipChooseDevice( &dev, &prop );
printf( "ID of hip device closest to revision 1.3: %d\n", dev );
hipChooseDevice(&dev, &prop);
printf("ID of hip device closest to revision 1.3: %d\n", dev);
hipSetDevice( dev );
hipSetDevice(dev);
passed();
}
@@ -30,14 +30,13 @@ THE SOFTWARE.
#include "test_common.h"
int main()
{
int main() {
int numDevices = 0;
int major,minor;
int major, minor;
hipDevice_t device;
HIPCHECK(hipGetDeviceCount(&numDevices));
for(int i=0;i<numDevices;i++){
HIPCHECK(hipDeviceGet(&device,i));
for (int i = 0; i < numDevices; i++) {
HIPCHECK(hipDeviceGet(&device, i));
HIPCHECK(hipDeviceComputeCapability(&major, &minor, device));
HIPASSERT(major >= 0);
HIPASSERT(minor >= 0);
@@ -30,25 +30,25 @@ THE SOFTWARE.
#include "hip/hip_runtime.h"
#include "test_common.h"
int main( void ) {
int main(void) {
char pciBusId[13];
int deviceCount = 0;
HIPCHECK(hipGetDeviceCount(&deviceCount));
HIPASSERT(deviceCount != 0);
for(int i=0; i< deviceCount;i++) {
for (int i = 0; i < deviceCount; i++) {
int pciBusID = -1;
int pciDeviceID = -1;
int pciDomainID = -1;
int tempPciBusId = -1;
int tempDeviceId = -1;
HIPCHECK(hipDeviceGetPCIBusId ( &pciBusId[0], 13, i ));
sscanf (pciBusId,"%04x:%02x:%02x",&pciDomainID,&pciBusID,&pciDeviceID);
HIPCHECK(hipDeviceGetAttribute(&tempPciBusId,hipDeviceAttributePciBusId , i));
if(pciBusID != tempPciBusId) {
HIPCHECK(hipDeviceGetPCIBusId(&pciBusId[0], 13, i));
sscanf(pciBusId, "%04x:%02x:%02x", &pciDomainID, &pciBusID, &pciDeviceID);
HIPCHECK(hipDeviceGetAttribute(&tempPciBusId, hipDeviceAttributePciBusId, i));
if (pciBusID != tempPciBusId) {
exit(EXIT_FAILURE);
}
HIPCHECK(hipDeviceGetByPCIBusId ( &tempDeviceId, pciBusId ));
if(tempDeviceId != i) {
HIPCHECK(hipDeviceGetByPCIBusId(&tempDeviceId, pciBusId));
if (tempDeviceId != i) {
exit(EXIT_FAILURE);
}
}
@@ -32,15 +32,14 @@ THE SOFTWARE.
#define len 256
int main()
{
int main() {
int numDevices = 0;
char name[len];
hipDevice_t device;
HIPCHECK(hipGetDeviceCount(&numDevices));
for(int i=0;i<numDevices;i++){
HIPCHECK(hipDeviceGet(&device,i));
HIPCHECK(hipDeviceGetName(name,len,device));
for (int i = 0; i < numDevices; i++) {
HIPCHECK(hipDeviceGet(&device, i));
HIPCHECK(hipDeviceGetName(name, len, device));
HIPASSERT(name != "");
}
passed();
@@ -30,20 +30,20 @@ THE SOFTWARE.
#include "hip/hip_runtime.h"
#include "test_common.h"
int main( void ) {
int main(void) {
char pciBusId[13];
int deviceCount = 0;
HIPCHECK(hipGetDeviceCount(&deviceCount));
HIPASSERT(deviceCount != 0);
for(int i=0; i< deviceCount;i++) {
for (int i = 0; i < deviceCount; i++) {
int pciBusID = -1;
int pciDeviceID = -1;
int pciDomainID = -1;
int tempPciBusId = -1;
HIPCHECK(hipDeviceGetPCIBusId ( &pciBusId[0], 13, i ));
sscanf (pciBusId,"%04x:%02x:%02x",&pciDomainID,&pciBusID,&pciDeviceID);
HIPCHECK(hipDeviceGetAttribute(&tempPciBusId,hipDeviceAttributePciBusId , i));
if(pciBusID != tempPciBusId) {
HIPCHECK(hipDeviceGetPCIBusId(&pciBusId[0], 13, i));
sscanf(pciBusId, "%04x:%02x:%02x", &pciDomainID, &pciBusID, &pciDeviceID);
HIPCHECK(hipDeviceGetAttribute(&tempPciBusId, hipDeviceAttributePciBusId, i));
if (pciBusID != tempPciBusId) {
exit(EXIT_FAILURE);
}
}
@@ -20,7 +20,7 @@ THE SOFTWARE.
/*
* Test for checking the functionality of
* hipError_t hipDeviceSynchronize();
*/
*/
/* HIT_START
* BUILD: %t %s ../../test_common.cpp
@@ -28,47 +28,49 @@ THE SOFTWARE.
* HIT_END
*/
#include"test_common.h"
#include "test_common.h"
#define _SIZE sizeof(int)*1024*1024
#define _SIZE sizeof(int) * 1024 * 1024
#define NUM_STREAMS 2
__global__ void Iter(hipLaunchParm lp, int *Ad, int num){
__global__ void Iter(hipLaunchParm lp, int* Ad, int num) {
int tx = threadIdx.x + blockIdx.x * blockDim.x;
// Kernel loop designed to execute very slowly... ... ... so we can test timing-related behavior below
if(tx == 0){
for(int i = 0; i<num;i++){
// Kernel loop designed to execute very slowly... ... ... so we can test timing-related
// behavior below
if (tx == 0) {
for (int i = 0; i < num; i++) {
Ad[tx] += 1;
}
}
}
int main(){
int *A[NUM_STREAMS];
int *Ad[NUM_STREAMS];
int main() {
int* A[NUM_STREAMS];
int* Ad[NUM_STREAMS];
hipStream_t stream[NUM_STREAMS];
for(int i=0;i<NUM_STREAMS;i++){
for (int i = 0; i < NUM_STREAMS; i++) {
HIPCHECK(hipHostMalloc((void**)&A[i], _SIZE, hipHostMallocDefault));
A[i][0] = 1;
HIPCHECK(hipMalloc((void**)&Ad[i], _SIZE));
HIPCHECK(hipStreamCreate(&stream[i]));
}
for(int i=0;i<NUM_STREAMS;i++){
for (int i = 0; i < NUM_STREAMS; i++) {
HIPCHECK(hipMemcpyAsync(Ad[i], A[i], _SIZE, hipMemcpyHostToDevice, stream[i]));
}
for(int i=0;i<NUM_STREAMS;i++){
hipLaunchKernel(HIP_KERNEL_NAME(Iter), dim3(1), dim3(1), 0, stream[i], Ad[i], 1<<30);
for (int i = 0; i < NUM_STREAMS; i++) {
hipLaunchKernel(HIP_KERNEL_NAME(Iter), dim3(1), dim3(1), 0, stream[i], Ad[i], 1 << 30);
}
for(int i=0;i<NUM_STREAMS;i++){
for (int i = 0; i < NUM_STREAMS; i++) {
HIPCHECK(hipMemcpyAsync(A[i], Ad[i], _SIZE, hipMemcpyDeviceToHost, stream[i]));
}
// This first check but relies on the kernel running for so long that the D2H async memcopy has not started yet.
// This will be true in an optimal asynchronous implementation.
// Conservative implementations which synchronize the hipMemcpyAsync will fail, ie if HIP_LAUNCH_BLOCKING=true
HIPASSERT(1<<30 != A[NUM_STREAMS-1][0]-1);
// This first check but relies on the kernel running for so long that the D2H async memcopy has
// not started yet. This will be true in an optimal asynchronous implementation. Conservative
// implementations which synchronize the hipMemcpyAsync will fail, ie if
// HIP_LAUNCH_BLOCKING=true
HIPASSERT(1 << 30 != A[NUM_STREAMS - 1][0] - 1);
HIPCHECK(hipDeviceSynchronize());
HIPASSERT(1<<30 == A[NUM_STREAMS-1][0]-1);
HIPASSERT(1 << 30 == A[NUM_STREAMS - 1][0] - 1);
passed();
}
@@ -30,15 +30,14 @@ THE SOFTWARE.
#include "test_common.h"
int main()
{
int main() {
int numDevices = 0;
size_t totMem;
hipDevice_t device;
HIPCHECK(hipGetDeviceCount(&numDevices));
for(int i=0;i<numDevices;i++){
HIPCHECK(hipDeviceGet(&device,i));
HIPCHECK(hipDeviceTotalMem(&totMem,device));
for (int i = 0; i < numDevices; i++) {
HIPCHECK(hipDeviceGet(&device, i));
HIPCHECK(hipDeviceTotalMem(&totMem, device));
HIPASSERT(totMem != 0);
}
passed();
@@ -30,12 +30,11 @@ THE SOFTWARE.
#include "test_common.h"
int main()
{
int main() {
int numDevices = 0;
int device;
HIPCHECK(hipGetDeviceCount(&numDevices));
for(int i=0;i<numDevices;i++){
for (int i = 0; i < numDevices; i++) {
HIPCHECK(hipSetDevice(i));
HIPCHECK(hipGetDevice(&device));
HIPASSERT(device == i);
@@ -33,17 +33,20 @@ THE SOFTWARE.
#include "test_common.h"
#define CHECK(error) \
if (error != hipSuccess) { \
fprintf(stderr, "error: '%s'(%d) at %s:%d\n", hipGetErrorString(error), error,__FILE__, __LINE__); \
exit(EXIT_FAILURE);\
#define CHECK(error) \
if (error != hipSuccess) { \
fprintf(stderr, "error: '%s'(%d) at %s:%d\n", hipGetErrorString(error), error, __FILE__, \
__LINE__); \
exit(EXIT_FAILURE); \
}
hipError_t test_hipDeviceGetAttribute(int deviceId, hipDeviceAttribute_t attr, int expectedValue = -1)
{
hipError_t test_hipDeviceGetAttribute(int deviceId, hipDeviceAttribute_t attr,
int expectedValue = -1) {
int value = 0;
std::cout << "Test hipDeviceGetAttribute attribute " << attr;
if (expectedValue != -1) { std::cout << " expected value " << expectedValue; }
if (expectedValue != -1) {
std::cout << " expected value " << expectedValue;
}
hipError_t e = hipDeviceGetAttribute(&value, attr, deviceId);
std::cout << " actual value " << value << std::endl;
if ((expectedValue != -1) && value != expectedValue) {
@@ -53,39 +56,57 @@ hipError_t test_hipDeviceGetAttribute(int deviceId, hipDeviceAttribute_t attr, i
return hipSuccess;
}
int main(int argc, char *argv[])
{
int main(int argc, char* argv[]) {
int deviceId;
CHECK (hipGetDevice(&deviceId));
CHECK(hipGetDevice(&deviceId));
hipDeviceProp_t props;
CHECK(hipGetDeviceProperties(&props, deviceId));
printf ("info: running on device #%d %s\n", deviceId, props.name);
printf("info: running on device #%d %s\n", deviceId, props.name);
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxThreadsPerBlock, props.maxThreadsPerBlock));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxBlockDimX, props.maxThreadsDim[0]));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxBlockDimY, props.maxThreadsDim[1]));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxBlockDimZ, props.maxThreadsDim[2]));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxGridDimX, props.maxGridSize[0]));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxGridDimY, props.maxGridSize[1]));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxGridDimZ, props.maxGridSize[2]));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxSharedMemoryPerBlock, props.sharedMemPerBlock));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeTotalConstantMemory, props.totalConstMem));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxThreadsPerBlock,
props.maxThreadsPerBlock));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxBlockDimX,
props.maxThreadsDim[0]));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxBlockDimY,
props.maxThreadsDim[1]));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxBlockDimZ,
props.maxThreadsDim[2]));
CHECK(
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxGridDimX, props.maxGridSize[0]));
CHECK(
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxGridDimY, props.maxGridSize[1]));
CHECK(
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxGridDimZ, props.maxGridSize[2]));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxSharedMemoryPerBlock,
props.sharedMemPerBlock));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeTotalConstantMemory,
props.totalConstMem));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeWarpSize, props.warpSize));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxRegistersPerBlock, props.regsPerBlock));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxRegistersPerBlock,
props.regsPerBlock));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeClockRate, props.clockRate));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMemoryClockRate, props.memoryClockRate));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMemoryBusWidth, props.memoryBusWidth));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMultiprocessorCount, props.multiProcessorCount));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeIsMultiGpuBoard, props.isMultiGpuBoard));//
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMemoryClockRate,
props.memoryClockRate));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMemoryBusWidth,
props.memoryBusWidth));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMultiprocessorCount,
props.multiProcessorCount));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeIsMultiGpuBoard,
props.isMultiGpuBoard)); //
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeMode, props.computeMode));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeL2CacheSize, props.l2CacheSize));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxThreadsPerMultiProcessor, props.maxThreadsPerMultiProcessor));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeCapabilityMajor, props.major));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeCapabilityMinor, props.minor));//
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeConcurrentKernels, props.concurrentKernels));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxThreadsPerMultiProcessor,
props.maxThreadsPerMultiProcessor));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeCapabilityMajor,
props.major));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeCapabilityMinor,
props.minor)); //
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeConcurrentKernels,
props.concurrentKernels));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributePciBusId, props.pciBusID));
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributePciDeviceId, props.pciDeviceID));//
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxSharedMemoryPerMultiprocessor, props.maxSharedMemoryPerMultiProcessor));
CHECK(
test_hipDeviceGetAttribute(deviceId, hipDeviceAttributePciDeviceId, props.pciDeviceID)); //
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxSharedMemoryPerMultiprocessor,
props.maxSharedMemoryPerMultiProcessor));
passed();
};
@@ -20,7 +20,8 @@ THE SOFTWARE.
/*
* Conformance test for checking functionality of
* hipError_t hipRuntimeGetVersion(int* runtimeVersion);
* On HIP/HCC path this function returns HIP runtime patch version(a 5 digit code) however on HIP/NVCC path this function return CUDA runtime version.
* On HIP/HCC path this function returns HIP runtime patch version(a 5 digit code) however on
* HIP/NVCC path this function return CUDA runtime version.
*/
/* HIT_START
@@ -31,8 +32,7 @@ THE SOFTWARE.
#include "test_common.h"
int main()
{
int main() {
int runtimeVersion;
HIPCHECK(hipRuntimeGetVersion(&runtimeVersion));
passed();
@@ -23,14 +23,13 @@ THE SOFTWARE.
* HIT_END
*/
#include<hip/hip_runtime_api.h>
#include<iostream>
#include"test_common.h"
#include <hip/hip_runtime_api.h>
#include <iostream>
#include "test_common.h"
int main(){
hipFuncCache_t cacheConfig;
void *func;
hipFuncSetCacheConfig(func, cacheConfig);
passed();
int main() {
hipFuncCache_t cacheConfig;
void* func;
hipFuncSetCacheConfig(func, cacheConfig);
passed();
}
@@ -25,10 +25,10 @@ THE SOFTWARE.
#include "test_common.h"
int main(){
int main() {
int numDevices = 0;
HIPCHECK(hipGetDeviceCount(&numDevices));
for(int i=0;i<numDevices;i++){
for (int i = 0; i < numDevices; i++) {
HIPCHECK(hipSetDevice(i));
}
HIPASSERT(hipErrorInvalidDevice == hipSetDevice(numDevices));
@@ -25,27 +25,24 @@ THE SOFTWARE.
#include "test_common.h"
int main()
{
int main() {
unsigned flag = 0;
HIPCHECK(hipDeviceReset());
int deviceCount = 0;
HIPCHECK(hipGetDeviceCount(&deviceCount));
for(int j=0;j<deviceCount;j++){
for (int j = 0; j < deviceCount; j++) {
HIPCHECK(hipSetDevice(j));
for(int i=0;i<4;i++){
for (int i = 0; i < 4; i++) {
flag = 1 << i;
printf ("Flag=%x\n", flag);
printf("Flag=%x\n", flag);
HIPCHECK(hipSetDeviceFlags(flag));
//HIPCHECK_API(hipSetDeviceFlags(flag), hipErrorInvalidValue);
// HIPCHECK_API(hipSetDeviceFlags(flag), hipErrorInvalidValue);
}
flag = 0;
}
passed();