Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
tci-gateway-module
Grpc
Commits
c11e8472
Commit
c11e8472
authored
9 years ago
by
Alistair Veitch
Browse files
Options
Downloads
Patches
Plain Diff
only print #cores seen
parent
dcfb3fe4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/core/support/cpu_test.c
+11
-8
11 additions, 8 deletions
test/core/support/cpu_test.c
with
11 additions
and
8 deletions
test/core/support/cpu_test.c
+
11
−
8
View file @
c11e8472
...
...
@@ -54,14 +54,15 @@
to run on all cores).
4) Each thread checks what core it is running on, and marks that core
as "used" in the test.
5) C
heck that all cores were "used"
5) C
ount number of "used" cores.
The test will fail if:
1) gpr_cpu_num_cores() == 0
2) The result of gpr_cpu_current_cpu() >= gpr_cpu_num_cores()
3) Not all cores are used/seen in the test. If a system does not exhibit
this property (e.g. some cores reserved/unusable), then this condition
will have to be rethought.
2) Any result from gpr_cpu_current_cpu() >= gpr_cpu_num_cores()
3) Ideally, we would fail if not all cores were seen as used. Unfortunately,
this is only probabilistically true, and depends on the OS, it's
scheduler, etc. So we just print out an indication of how many were seen;
hopefully developers can use this to sanity check their system.
*/
/* Status shared across threads */
...
...
@@ -92,7 +93,6 @@ static void worker_thread(void *arg) {
gpr_mu_unlock
(
&
ct
->
mu
);
}
gpr_mu_lock
(
&
ct
->
mu
);
fprintf
(
stderr
,
"thread done on core %d
\n
"
,
cpu
);
ct
->
r
=
r
;
/* make it look like we care about r's value... */
ct
->
nthreads
--
;
if
(
ct
->
nthreads
==
0
)
{
...
...
@@ -104,11 +104,11 @@ static void worker_thread(void *arg) {
static
void
cpu_test
(
void
)
{
gpr_uint32
i
;
int
cores_seen
=
0
;
struct
cpu_test
ct
;
gpr_thd_id
thd
;
ct
.
ncores
=
gpr_cpu_num_cores
();
GPR_ASSERT
(
ct
.
ncores
>
0
);
fprintf
(
stderr
,
"#cores = %d
\n
"
,
ct
.
ncores
);
ct
.
nthreads
=
(
int
)
ct
.
ncores
*
3
;
ct
.
used
=
gpr_malloc
(
ct
.
ncores
*
sizeof
(
int
));
memset
(
ct
.
used
,
0
,
ct
.
ncores
*
sizeof
(
int
));
...
...
@@ -124,8 +124,11 @@ static void cpu_test(void) {
}
gpr_mu_unlock
(
&
ct
.
mu
);
for
(
i
=
0
;
i
<
ct
.
ncores
;
i
++
)
{
GPR_ASSERT
(
ct
.
used
[
i
]);
if
(
ct
.
used
[
i
])
{
cores_seen
++
;
}
}
fprintf
(
stderr
,
"Saw %d/%d cores
\n
"
,
cores_seen
,
ct
.
ncores
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
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