Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
AARTFAAC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
ResearchAndDevelopment
AARTFAAC
Commits
d58227b9
Commit
d58227b9
authored
4 years ago
by
Steven van der Vlugt
Browse files
Options
Downloads
Patches
Plain Diff
CorrelatorTest
parent
fda62780
No related branches found
No related tags found
1 merge request
!1
Clean up
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Common/UnitTest.h
+9
-6
9 additions, 6 deletions
Common/UnitTest.h
Correlator/Tests/CorrelatorTest.cc
+71
-177
71 additions, 177 deletions
Correlator/Tests/CorrelatorTest.cc
README.md
+9
-1
9 additions, 1 deletion
README.md
with
89 additions
and
184 deletions
Common/UnitTest.h
+
9
−
6
View file @
d58227b9
...
@@ -25,10 +25,13 @@ class UnitTest
...
@@ -25,10 +25,13 @@ class UnitTest
template
<
typename
T
>
void
check
(
T
actual
,
T
expected
)
template
<
typename
T
>
void
check
(
T
actual
,
T
expected
)
{
{
if
(
expected
!=
actual
)
{
if
(
expected
!=
actual
)
{
std
::
cerr
<<
"Test FAILED: expected "
<<
expected
<<
", computed "
<<
actual
<<
std
::
endl
;
std
::
cerr
<<
"Test FAILED: expected "
<<
expected
<<
", computed "
<<
actual
<<
std
::
endl
;
exit
(
1
);
exit
(
1
);
}
else
{
}
else
{
std
::
cout
<<
"Test OK"
<<
std
::
endl
;
std
::
cout
<<
"Test OK"
<<
std
::
endl
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Correlator/Tests/CorrelatorTest.cc
+
71
−
177
View file @
d58227b9
...
@@ -8,96 +8,16 @@
...
@@ -8,96 +8,16 @@
#include
<iostream>
#include
<iostream>
#if defined USE_PHI_CORRELATOR
#if 0
struct CorrelatorTest : public UnitTest
{
CorrelatorTest(const CorrelatorParset &ps)
:
UnitTest(ps, "Correlator/Kernels/PhiCorrelator.cl")
{
if (ps.nrStations() >= 5 && ps.nrChannelsPerSubband() >= 6 && ps.nrSamplesPerChannel() >= 100) {
MultiArraySharedBuffer<float, 5> visibilities(boost::extents[ps.nrBaselines()][ps.nrPolarizations()][ps.nrPolarizations()][COMPLEX][ps.nrChannelsPerSubband()], queue, CL_MEM_HOST_READ_ONLY | CL_MEM_WRITE_ONLY);
MultiArraySharedBuffer<float, 5> inputData(boost::extents[ps.nrStations()][ps.nrSamplesPerChannel()][ps.nrPolarizations()][COMPLEX][ps.nrChannelsPerSubband()], queue, CL_MEM_HOST_WRITE_ONLY | CL_MEM_READ_ONLY);
CorrelatorKernel correlator(ps, queue, program, visibilities, inputData);
inputData[3][99][POL_Y][REAL][5] = 3; // stat=3,pol=Y,real,time=99,chan=5
inputData[3][99][POL_Y][IMAG][5] = 4; // stat=3,pol=Y,imag,time=99,chan=5
inputData[4][99][POL_Y][REAL][5] = 5; // stat=4,pol=Y,real,time=99,chan=5
inputData[4][99][POL_Y][IMAG][5] = 6; // stat=4,pol=Y,imag,time=99,chan=5
inputData.hostToDevice(CL_FALSE);
correlator.enqueue(queue, counter);
visibilities.deviceToHost(CL_TRUE);
#if 0
check(visibilities[ 9][POL_Y][POL_Y][REAL][5], 25.f);
check(visibilities[ 9][POL_Y][POL_Y][IMAG][5], 0.f);
check(visibilities[13][POL_Y][POL_Y][REAL][5], 39.f);
check(visibilities[13][POL_Y][POL_Y][IMAG][5], 2.f);
check(visibilities[14][POL_Y][POL_Y][REAL][5], 61.f);
check(visibilities[14][POL_Y][POL_Y][IMAG][5], 0.f);
#endif
}
}
};
#else
struct
CorrelateRectangleTest
:
public
UnitTest
{
CorrelateRectangleTest
(
const
CorrelatorParset
&
ps
)
:
UnitTest
(
ps
,
"Correlator/Kernels/PhiCorrelator.cl"
)
{
if
(
ps
.
nrStations
()
>=
69
&&
ps
.
nrChannelsPerSubband
()
>=
6
&&
ps
.
nrSamplesPerChannel
()
>=
100
&&
ps
.
nrVisibilityPolarizations
()
==
1
)
{
Buffer
<
float
,
4
>
inputData
(
boost
::
extents
[
ps
.
nrChannelsPerSubband
()][
ps
.
nrSamplesPerChannel
()][
COMPLEX
][
align
(
ps
.
nrStations
()
*
ps
.
nrPolarizations
(),
16
)],
context
,
CL_MEM_HOST_WRITE_ONLY
|
CL_MEM_READ_ONLY
);
Buffer
<
float
,
3
>
visibilities
(
boost
::
extents
[
ps
.
nrChannelsPerSubband
()][
COMPLEX
][
ps
.
nrBaselines
()],
context
,
CL_MEM_HOST_READ_ONLY
|
CL_MEM_WRITE_ONLY
);
CorrelateRectangleKernel
correlator
(
ps
,
queue
,
program
,
visibilities
,
inputData
);
{
MappedBuffer
<
float
,
4
>
mappedInputData
(
queue
,
inputData
,
CL_MAP_WRITE
,
true
);
mappedInputData
[
5
][
99
][
REAL
][
0
]
=
3
;
mappedInputData
[
5
][
99
][
IMAG
][
0
]
=
4
;
mappedInputData
[
5
][
99
][
REAL
][
15
]
=
5
;
mappedInputData
[
5
][
99
][
IMAG
][
15
]
=
6
;
}
correlator
.
enqueue
(
queue
,
counter
);
{
MappedBuffer
<
float
,
3
>
mappedVisibilities
(
queue
,
visibilities
,
CL_MAP_READ
);
//unsigned outputChannel = 5;
//check(visibilities[outputChannel][2373][outputPolarization], std::complex<float>(39, 2));
#if 1
for
(
unsigned
ch
=
0
;
ch
<
ps
.
nrChannelsPerSubband
();
ch
++
)
for
(
unsigned
bl
=
0
;
bl
<
ps
.
nrBaselines
();
bl
++
)
if
(
mappedVisibilities
[
ch
][
REAL
][
bl
]
!=
0
||
mappedVisibilities
[
ch
][
IMAG
][
bl
]
!=
0
)
std
::
cout
<<
"vis["
<<
ch
<<
"]["
<<
bl
<<
"] = ("
<<
mappedVisibilities
[
ch
][
REAL
][
bl
]
<<
','
<<
mappedVisibilities
[
ch
][
IMAG
][
bl
]
<<
')'
<<
std
::
endl
;
#endif
}
}
}
};
#endif
#elif defined USE_NEW_CORRELATOR
struct
CorrelateSquareTest
:
public
CorrelatorUnitTest
struct
CorrelateSquareTest
:
public
CorrelatorUnitTest
{
{
CorrelateSquareTest
(
const
CorrelatorParset
&
ps
)
CorrelateSquareTest
(
const
CorrelatorParset
&
ps
)
:
:
CorrelatorUnitTest
(
ps
,
"Correlator/Kernels/NewCorrelator.cl"
)
CorrelatorUnitTest
(
ps
,
"Correlator/Kernels/NewCorrelator.cl"
)
{
{
if
(
ps
.
nrStations
()
>=
64
&&
ps
.
nrOutputChannelsPerSubband
()
>=
6
&&
ps
.
nrSamplesPerChannel
()
>=
100
&&
ps
.
nrVisibilityPolarizations
()
>=
2
)
{
std
::
cout
<<
">>> Running CorrelateSquareTest"
<<
std
::
endl
;
if
(
ps
.
nrStations
()
>=
64
&&
ps
.
nrOutputChannelsPerSubband
()
>=
6
&&
ps
.
nrSamplesPerChannel
()
>=
100
&&
ps
.
nrVisibilityPolarizations
()
>=
2
)
{
Buffer
<
std
::
complex
<
float
>
,
4
>
inputData
(
boost
::
extents
[
ps
.
nrChannelsPerSubband
()][
ps
.
nrSamplesPerChannel
()][
ps
.
nrStations
()][
ps
.
nrPolarizations
()],
context
,
CL_MEM_HOST_WRITE_ONLY
|
CL_MEM_READ_ONLY
);
Buffer
<
std
::
complex
<
float
>
,
4
>
inputData
(
boost
::
extents
[
ps
.
nrChannelsPerSubband
()][
ps
.
nrSamplesPerChannel
()][
ps
.
nrStations
()][
ps
.
nrPolarizations
()],
context
,
CL_MEM_HOST_WRITE_ONLY
|
CL_MEM_READ_ONLY
);
Buffer
<
std
::
complex
<
float
>
,
3
>
visibilities
(
boost
::
extents
[
ps
.
nrBaselines
()][
ps
.
nrOutputChannelsPerSubband
()][
ps
.
nrVisibilityPolarizations
()],
context
,
CL_MEM_HOST_READ_ONLY
|
CL_MEM_WRITE_ONLY
);
Buffer
<
std
::
complex
<
float
>
,
3
>
visibilities
(
boost
::
extents
[
ps
.
nrBaselines
()][
ps
.
nrOutputChannelsPerSubband
()][
ps
.
nrVisibilityPolarizations
()],
context
,
CL_MEM_HOST_READ_ONLY
|
CL_MEM_WRITE_ONLY
);
CorrelateSquareKernel
correlator
(
ps
,
queue
,
program
,
visibilities
,
inputData
);
CorrelateSquareKernel
correlator
(
ps
,
queue
,
program
,
visibilities
,
inputData
);
...
@@ -130,14 +50,16 @@ struct CorrelateSquareTest : public CorrelatorUnitTest
...
@@ -130,14 +50,16 @@ struct CorrelateSquareTest : public CorrelatorUnitTest
}
}
};
};
struct
CorrelateRectangleTest
:
public
CorrelatorUnitTest
struct
CorrelateRectangleTest
:
public
CorrelatorUnitTest
{
{
CorrelateRectangleTest
(
const
CorrelatorParset
&
ps
)
CorrelateRectangleTest
(
const
CorrelatorParset
&
ps
)
:
:
CorrelatorUnitTest
(
ps
,
"Correlator/Kernels/NewCorrelator.cl"
)
CorrelatorUnitTest
(
ps
,
"Correlator/Kernels/NewCorrelator.cl"
)
{
{
if
(
ps
.
nrStations
()
>=
69
&&
ps
.
nrOutputChannelsPerSubband
()
>=
6
&&
ps
.
nrSamplesPerChannel
()
>=
100
&&
ps
.
nrVisibilityPolarizations
()
>=
2
)
{
std
::
cout
<<
">>> Running CorrelateRectangleTest"
<<
std
::
endl
;
if
(
ps
.
nrStations
()
>=
69
&&
ps
.
nrOutputChannelsPerSubband
()
>=
6
&&
ps
.
nrSamplesPerChannel
()
>=
100
&&
ps
.
nrVisibilityPolarizations
()
>=
2
)
{
Buffer
<
std
::
complex
<
float
>
,
4
>
inputData
(
boost
::
extents
[
ps
.
nrChannelsPerSubband
()][
ps
.
nrSamplesPerChannel
()][
ps
.
nrStations
()][
ps
.
nrPolarizations
()],
context
,
CL_MEM_HOST_WRITE_ONLY
|
CL_MEM_READ_ONLY
);
Buffer
<
std
::
complex
<
float
>
,
4
>
inputData
(
boost
::
extents
[
ps
.
nrChannelsPerSubband
()][
ps
.
nrSamplesPerChannel
()][
ps
.
nrStations
()][
ps
.
nrPolarizations
()],
context
,
CL_MEM_HOST_WRITE_ONLY
|
CL_MEM_READ_ONLY
);
Buffer
<
std
::
complex
<
float
>
,
3
>
visibilities
(
boost
::
extents
[
ps
.
nrBaselines
()][
ps
.
nrOutputChannelsPerSubband
()][
ps
.
nrVisibilityPolarizations
()],
context
,
CL_MEM_HOST_READ_ONLY
|
CL_MEM_WRITE_ONLY
);
Buffer
<
std
::
complex
<
float
>
,
3
>
visibilities
(
boost
::
extents
[
ps
.
nrBaselines
()][
ps
.
nrOutputChannelsPerSubband
()][
ps
.
nrVisibilityPolarizations
()],
context
,
CL_MEM_HOST_READ_ONLY
|
CL_MEM_WRITE_ONLY
);
CorrelateRectangleKernel
correlator
(
ps
,
queue
,
program
,
visibilities
,
inputData
);
CorrelateRectangleKernel
correlator
(
ps
,
queue
,
program
,
visibilities
,
inputData
);
...
@@ -170,14 +92,16 @@ struct CorrelateRectangleTest : public CorrelatorUnitTest
...
@@ -170,14 +92,16 @@ struct CorrelateRectangleTest : public CorrelatorUnitTest
}
}
};
};
struct
CorrelateTriangleTest
:
public
CorrelatorUnitTest
struct
CorrelateTriangleTest
:
public
CorrelatorUnitTest
{
{
CorrelateTriangleTest
(
const
CorrelatorParset
&
ps
)
CorrelateTriangleTest
(
const
CorrelatorParset
&
ps
)
:
:
CorrelatorUnitTest
(
ps
,
"Correlator/Kernels/NewCorrelator.cl"
)
CorrelatorUnitTest
(
ps
,
"Correlator/Kernels/NewCorrelator.cl"
)
{
{
if
(
ps
.
nrStations
()
>=
5
&&
ps
.
nrOutputChannelsPerSubband
()
>=
6
&&
ps
.
nrSamplesPerChannel
()
>=
100
&&
ps
.
nrVisibilityPolarizations
()
>=
2
)
{
std
::
cout
<<
">>> Running CorrelateTriangleTest"
<<
std
::
endl
;
if
(
ps
.
nrStations
()
>=
5
&&
ps
.
nrOutputChannelsPerSubband
()
>=
6
&&
ps
.
nrSamplesPerChannel
()
>=
100
&&
ps
.
nrVisibilityPolarizations
()
>=
2
)
{
Buffer
<
std
::
complex
<
float
>
,
4
>
inputData
(
boost
::
extents
[
ps
.
nrChannelsPerSubband
()][
ps
.
nrSamplesPerChannel
()][
ps
.
nrStations
()][
ps
.
nrPolarizations
()],
context
,
CL_MEM_HOST_WRITE_ONLY
|
CL_MEM_READ_ONLY
);
Buffer
<
std
::
complex
<
float
>
,
4
>
inputData
(
boost
::
extents
[
ps
.
nrChannelsPerSubband
()][
ps
.
nrSamplesPerChannel
()][
ps
.
nrStations
()][
ps
.
nrPolarizations
()],
context
,
CL_MEM_HOST_WRITE_ONLY
|
CL_MEM_READ_ONLY
);
Buffer
<
std
::
complex
<
float
>
,
3
>
visibilities
(
boost
::
extents
[
ps
.
nrBaselines
()][
ps
.
nrOutputChannelsPerSubband
()][
ps
.
nrVisibilityPolarizations
()],
context
,
CL_MEM_HOST_READ_ONLY
|
CL_MEM_WRITE_ONLY
);
Buffer
<
std
::
complex
<
float
>
,
3
>
visibilities
(
boost
::
extents
[
ps
.
nrBaselines
()][
ps
.
nrOutputChannelsPerSubband
()][
ps
.
nrVisibilityPolarizations
()],
context
,
CL_MEM_HOST_READ_ONLY
|
CL_MEM_WRITE_ONLY
);
CorrelateTriangleKernel
correlator
(
ps
,
queue
,
program
,
visibilities
,
inputData
);
CorrelateTriangleKernel
correlator
(
ps
,
queue
,
program
,
visibilities
,
inputData
);
...
@@ -196,12 +120,15 @@ struct CorrelateTriangleTest : public CorrelatorUnitTest
...
@@ -196,12 +120,15 @@ struct CorrelateTriangleTest : public CorrelatorUnitTest
#if 1
#if 1
unsigned
outputChannel
=
(
5
-
1
)
/
ps
.
channelIntegrationFactor
();
unsigned
outputChannel
=
(
5
-
1
)
/
ps
.
channelIntegrationFactor
();
switch
(
ps
.
nrVisibilityPolarizations
())
{
switch
(
ps
.
nrVisibilityPolarizations
())
case
2
:
check
(
mappedVisibilities
[
2
][
outputChannel
][
1
],
std
::
complex
<
float
>
(
25
,
0
));
{
case
2
:
check
(
mappedVisibilities
[
2
][
outputChannel
][
1
],
std
::
complex
<
float
>
(
25
,
0
));
check
(
mappedVisibilities
[
9
][
outputChannel
][
0
],
std
::
complex
<
float
>
(
61
,
0
));
check
(
mappedVisibilities
[
9
][
outputChannel
][
0
],
std
::
complex
<
float
>
(
61
,
0
));
break
;
break
;
case
4
:
check
(
mappedVisibilities
[
2
][
outputChannel
][
3
],
std
::
complex
<
float
>
(
25
,
0
));
case
4
:
check
(
mappedVisibilities
[
2
][
outputChannel
][
3
],
std
::
complex
<
float
>
(
25
,
0
));
check
(
mappedVisibilities
[
7
][
outputChannel
][
2
],
std
::
complex
<
float
>
(
39
,
2
));
check
(
mappedVisibilities
[
7
][
outputChannel
][
2
],
std
::
complex
<
float
>
(
39
,
2
));
check
(
mappedVisibilities
[
9
][
outputChannel
][
0
],
std
::
complex
<
float
>
(
61
,
0
));
check
(
mappedVisibilities
[
9
][
outputChannel
][
0
],
std
::
complex
<
float
>
(
61
,
0
));
break
;
break
;
...
@@ -218,63 +145,30 @@ struct CorrelateTriangleTest : public CorrelatorUnitTest
...
@@ -218,63 +145,30 @@ struct CorrelateTriangleTest : public CorrelatorUnitTest
}
}
};
};
#else
struct
CorrelatorTest
:
public
UnitTest
{
CorrelatorTest
(
const
CorrelatorParset
&
ps
)
:
UnitTest
(
ps
,
"Correlator/Kernels/Correlator.cl"
)
{
if
(
ps
.
nrStations
()
>=
5
&&
ps
.
nrChannelsPerSubband
()
>=
6
&&
ps
.
nrSamplesPerChannel
()
>=
100
)
{
Buffer
<
std
::
complex
<
float
>
,
4
>
inputData
(
boost
::
extents
[
ps
.
nrStations
()][
ps
.
nrChannelsPerSubband
()][
ps
.
nrSamplesPerChannel
()][
ps
.
nrPolarizations
()],
context
,
CL_MEM_HOST_WRITE_ONLY
|
CL_MEM_READ_ONLY
);
Buffer
<
std
::
complex
<
float
>
,
4
>
visibilities
(
boost
::
extents
[
ps
.
nrBaselines
()][
ps
.
nrChannelsPerSubband
()][
ps
.
nrPolarizations
()][
ps
.
nrPolarizations
()],
context
,
CL_MEM_HOST_READ_ONLY
|
CL_MEM_WRITE_ONLY
);
CorrelatorKernel
correlator
(
ps
,
queue
,
program
,
visibilities
,
inputData
);
{
MappedBuffer
<
std
::
complex
<
float
>
,
4
>
mappedInputData
(
queue
,
inputData
,
CL_MAP_WRITE
,
true
);
mappedInputData
[
3
][
5
][
99
][
POL_Y
]
=
std
::
complex
<
float
>
(
3
,
4
);
mappedInputData
[
4
][
5
][
99
][
POL_Y
]
=
std
::
complex
<
float
>
(
5
,
6
);
}
correlator
.
enqueue
(
queue
,
counter
);
{
MappedBuffer
<
std
::
complex
<
float
>
,
3
>
mappedVisibilities
(
queue
,
visibilities
,
CL_MAP_READ
);
check
(
mappedVisibilities
[
9
][
5
][
POL_Y
][
POL_Y
],
std
::
complex
<
float
>
(
25
,
0
));
check
(
mappedVisibilities
[
13
][
5
][
POL_Y
][
POL_Y
],
std
::
complex
<
float
>
(
39
,
2
));
check
(
mappedVisibilities
[
14
][
5
][
POL_Y
][
POL_Y
],
std
::
complex
<
float
>
(
61
,
0
));
}
}
}
};
#endif
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
#if !defined CREATE_BACKTRACE_ON_EXCEPTION
#if !defined CREATE_BACKTRACE_ON_EXCEPTION
try
{
try
{
#endif
#endif
std
::
cout
<<
">>> Running CorrelatorTest"
<<
std
::
endl
;
CorrelatorParset
ps
(
argc
,
argv
);
CorrelatorParset
ps
(
argc
,
argv
);
#if defined USE_PHI_CORRELATOR
std
::
cout
<<
"With "
<<
ps
.
nrStations
()
<<
" number of stations"
<<
std
::
endl
;
(
CorrelateRectangleTest
)(
ps
);
#elif defined USE_NEW_CORRELATOR
(
CorrelateSquareTest
)(
ps
);
(
CorrelateSquareTest
)(
ps
);
if
(
ps
.
nrStations
()
%
32
!=
0
)
if
(
ps
.
nrStations
()
%
32
!=
0
)
{
(
CorrelateRectangleTest
)(
ps
);
(
CorrelateRectangleTest
)(
ps
);
}
(
CorrelateTriangleTest
)(
ps
);
(
CorrelateTriangleTest
)(
ps
);
#else
(
CorrelatorTest
)(
ps
);
#endif
#if !defined CREATE_BACKTRACE_ON_EXCEPTION
#if !defined CREATE_BACKTRACE_ON_EXCEPTION
}
catch
(
cl
::
Error
&
ex
)
{
}
catch
(
cl
::
Error
&
ex
)
{
#pragma omp critical (cerr)
#pragma omp critical (cerr)
std
::
cerr
<<
"caught cl::Error: "
<<
ex
.
what
()
<<
": "
<<
errorMessage
(
ex
.
err
())
<<
std
::
endl
;
std
::
cerr
<<
"caught cl::Error: "
<<
ex
.
what
()
<<
": "
<<
errorMessage
(
ex
.
err
())
<<
std
::
endl
;
exit
(
1
);
exit
(
1
);
...
...
This diff is collapsed.
Click to expand it.
README.md
+
9
−
1
View file @
d58227b9
...
@@ -15,7 +15,15 @@ make -j
...
@@ -15,7 +15,15 @@ make -j
```
```
## Usage
## Usage
A test program
`./Correlator/Correlator`
A test program for the Correlator pipeline
`./Correlator/Correlator`
Unit tests in
`/Correlator/Tests`
:
*
`CorrelatorTest`
;
Uses 288 stations by default and therefore does not run subtest
`CorrelateRectangleTest`
(only used when nr of stations is not a multiple of 32)
*
`DelayAndBandPassTest`
*
`DeviceInstanceTest`
*
`Filter_FFT_Test`
*
`FIR_FilterTest`
# AARTFAAC
# AARTFAAC
...
...
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