Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
a6dcafde
Commit
a6dcafde
authored
6 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
COB-61
: fixed test
parent
bda0bdd2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
Import cobalt2 into lofar4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
RTCP/Cobalt/GPUProc/test/t_gpu_utils.cc
+93
-93
93 additions, 93 deletions
RTCP/Cobalt/GPUProc/test/t_gpu_utils.cc
with
93 additions
and
93 deletions
RTCP/Cobalt/GPUProc/test/t_gpu_utils.cc
+
93
−
93
View file @
a6dcafde
...
...
@@ -61,99 +61,99 @@ TEST_FIXTURE(CreateFixture, CreatePtx)
{
createPTX
(
srcFile
);
}
//
//
TEST_FIXTURE(CreateFixture, CreatePtxExtraDef)
//
{
//
CompileDefinitions defs;
//
defs["FOO"] = "42";
//
createPTX(srcFile, defs);
//
}
//
//
TEST_FIXTURE(CreateFixture, CreatePtxWrongExtraDef)
//
{
//
CompileDefinitions defs;
//
defs["FOO"] = "24";
//
CHECK_THROW(createPTX(srcFile, defs), GPUProcException);
//
}
//
//
TEST_FIXTURE(CreateFixture, CreatePtxExtraFlag)
//
{
//
CompileFlags flags;
//
flags.insert("--source-in-ptx");
//
createPTX(srcFile, defaultCompileDefinitions(), flags);
//
}
//
//
TEST_FIXTURE(CreateFixture, CreatePtxWrongExtraFlag)
//
{
//
CompileFlags flags;
//
flags.insert("--yaddayadda");
//
CHECK_THROW(createPTX(srcFile, defaultCompileDefinitions(), flags),
//
GPUProcException);
//
}
//
//
TEST_FIXTURE(CreateFixture, CreateModule)
//
{
//
gpu::Device device(gpu::Platform().devices()[0]);
//
createModule(gpu::Context(device), srcFile, createPTX(srcFile));
//
}
//
//
TEST_FIXTURE(CreateFixture, CreateModuleHighestArch)
//
{
//
// Highest known architecture is 3.5.
//
// Only perform this test if we do NOT have a device with that capability.
//
gpu::Device device(gpu::Platform().devices()[0]);
//
//
if (device.getComputeCapabilityMajor() > 3) return;
//
if (device.getComputeCapabilityMajor() == 3 &&
//
device.getComputeCapabilityMinor() >= 5) return;
//
//
CHECK_THROW(createModule(gpu::Context(device),
//
srcFile,
//
createPTX(srcFile,
//
defaultCompileDefinitions(),
//
defaultCompileFlags(),
//
vector<gpu::Device>())),
//
gpu::GPUException);
//
}
//
//
TEST(DumpBuffer)
//
{
//
typedef unsigned element_type;
//
const char* dumpFile("tDevMem.dat");
//
const size_t num_elements(1024);
//
const size_t num_bytes(num_elements * sizeof(element_type));
//
vector<element_type> input(num_elements), output(num_elements);
//
//
// Initialize input vector
//
for(size_t i = 0; i < num_elements; i++)
//
input[i] = element_type(i);
//
//
// Initialize GPU device, context, and stream.
//
gpu::Device device(gpu::Platform().devices()[0]);
//
gpu::Context ctx(device);
//
gpu::Stream stream(ctx);
//
//
// Allocate memory on host and device
//
gpu::HostMemory hostMem(ctx, num_bytes);
//
gpu::DeviceMemory devMem(ctx, num_bytes);
//
//
// Copy input vector to host memory
//
copy(input.begin(), input.end(), hostMem.get<element_type>());
//
//
// Transfer to device memory
//
stream.writeBuffer(devMem, hostMem);
//
//
// Dump device memory to file
//
dumpBuffer(devMem, dumpFile);
//
//
// Read raw data back from file into output vector and remove file
//
ifstream ifs(dumpFile, ios::binary);
//
ifs.read(reinterpret_cast<char*>(&output[0]), num_bytes);
//
remove(dumpFile);
//
//
// Compare input and output vector.
//
CHECK_ARRAY_EQUAL(input, output, num_elements);
//
}
TEST_FIXTURE
(
CreateFixture
,
CreatePtxExtraDef
)
{
CompileDefinitions
defs
;
defs
[
"FOO"
]
=
"42"
;
createPTX
(
srcFile
,
defs
);
}
TEST_FIXTURE
(
CreateFixture
,
CreatePtxWrongExtraDef
)
{
CompileDefinitions
defs
;
defs
[
"FOO"
]
=
"24"
;
CHECK_THROW
(
createPTX
(
srcFile
,
defs
),
GPUProcException
);
}
TEST_FIXTURE
(
CreateFixture
,
CreatePtxExtraFlag
)
{
CompileFlags
flags
;
flags
.
insert
(
"--source-in-ptx"
);
createPTX
(
srcFile
,
defaultCompileDefinitions
(),
flags
);
}
TEST_FIXTURE
(
CreateFixture
,
CreatePtxWrongExtraFlag
)
{
CompileFlags
flags
;
flags
.
insert
(
"--yaddayadda"
);
CHECK_THROW
(
createPTX
(
srcFile
,
defaultCompileDefinitions
(),
flags
),
GPUProcException
);
}
TEST_FIXTURE
(
CreateFixture
,
CreateModule
)
{
gpu
::
Device
device
(
gpu
::
Platform
().
devices
()[
0
]);
createModule
(
gpu
::
Context
(
device
),
srcFile
,
createPTX
(
srcFile
));
}
TEST_FIXTURE
(
CreateFixture
,
CreateModuleHighestArch
)
{
// Highest known architecture is 3.5.
// Only perform this test if we do NOT have a device with that capability.
gpu
::
Device
device
(
gpu
::
Platform
().
devices
()[
0
]);
if
(
device
.
getComputeCapabilityMajor
()
>
3
)
return
;
if
(
device
.
getComputeCapabilityMajor
()
==
3
&&
device
.
getComputeCapabilityMinor
()
>=
5
)
return
;
CHECK_THROW
(
createModule
(
gpu
::
Context
(
device
),
srcFile
,
createPTX
(
srcFile
,
defaultCompileDefinitions
(),
defaultCompileFlags
(),
vector
<
gpu
::
Device
>
())),
gpu
::
GPUException
);
}
TEST
(
DumpBuffer
)
{
typedef
unsigned
element_type
;
const
char
*
dumpFile
(
"tDevMem.dat"
);
const
size_t
num_elements
(
1024
);
const
size_t
num_bytes
(
num_elements
*
sizeof
(
element_type
));
vector
<
element_type
>
input
(
num_elements
),
output
(
num_elements
);
// Initialize input vector
for
(
size_t
i
=
0
;
i
<
num_elements
;
i
++
)
input
[
i
]
=
element_type
(
i
);
// Initialize GPU device, context, and stream.
gpu
::
Device
device
(
gpu
::
Platform
().
devices
()[
0
]);
gpu
::
Context
ctx
(
device
);
gpu
::
Stream
stream
(
ctx
);
// Allocate memory on host and device
gpu
::
HostMemory
hostMem
(
ctx
,
num_bytes
);
gpu
::
DeviceMemory
devMem
(
ctx
,
num_bytes
);
// Copy input vector to host memory
copy
(
input
.
begin
(),
input
.
end
(),
hostMem
.
get
<
element_type
>
());
// Transfer to device memory
stream
.
writeBuffer
(
devMem
,
hostMem
);
// Dump device memory to file
dumpBuffer
(
devMem
,
dumpFile
);
// Read raw data back from file into output vector and remove file
ifstream
ifs
(
dumpFile
,
ios
::
binary
);
ifs
.
read
(
reinterpret_cast
<
char
*>
(
&
output
[
0
]),
num_bytes
);
remove
(
dumpFile
);
// Compare input and output vector.
CHECK_ARRAY_EQUAL
(
input
,
output
,
num_elements
);
}
int
main
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment