Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
16aca119
Commit
16aca119
authored
19 years ago
by
Moe Jette
Browse files
Options
Downloads
Patches
Plain Diff
Modify tests to work with sched_setaffinity functions having 2 or 3 args.
parent
f8bbaa0f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
testsuite/expect/test1.89
+1
-0
1 addition, 0 deletions
testsuite/expect/test1.89
testsuite/expect/test1.89.prog.c
+47
-8
47 additions, 8 deletions
testsuite/expect/test1.89.prog.c
with
48 additions
and
8 deletions
testsuite/expect/test1.89
+
1
−
0
View file @
16aca119
...
...
@@ -77,6 +77,7 @@ set job_id $expect_out(1,string)
# Run a job step to get allocated processor count and affinity
#
expect -re $prompt
set mask 0
set task_cnt 0
send "$srun -c1 $file_prog\n"
expect {
...
...
This diff is collapsed.
Click to expand it.
testsuite/expect/test1.89.prog.c
+
47
−
8
View file @
16aca119
#define _GNU_SOURCE
#include
<errno.h>
#include
<sched.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<gnu/libc-version.h>
main
(
int
argc
,
char
**
argv
)
static
void
_load_mask
(
cpu_set_t
*
mask
)
{
char
*
task_str
;
unsigned
long
mask
;
int
task_id
;
int
rc
,
affinity_args
=
3
;
int
(
*
fptr_sched_getaffinity
)()
=
sched_getaffinity
;
if
(
sched_getaffinity
((
pid_t
)
0
,
(
unsigned
int
)
sizeof
(
mask
),
&
mask
)
!=
0
)
{
fprintf
(
stderr
,
"ERROR: sched_getaffinity: %s
\n
"
,
#if defined __GLIBC__
const
char
*
glibc_vers
=
gnu_get_libc_version
();
if
(
glibc_vers
!=
NULL
)
{
int
scnt
=
0
,
major
=
0
,
minor
=
0
,
point
=
0
;
scnt
=
sscanf
(
glibc_vers
,
"%d.%d.%d"
,
&
major
,
&
minor
,
&
point
);
if
(
scnt
==
3
)
{
if
((
major
<=
2
)
&&
(
minor
<=
3
)
&&
(
point
<=
2
))
{
affinity_args
=
2
;
}
}
}
#endif
if
(
affinity_args
==
3
)
{
rc
=
(
*
fptr_sched_getaffinity
)((
pid_t
)
0
,
(
unsigned
int
)
sizeof
(
cpu_set_t
),
mask
);
}
else
{
rc
=
(
*
fptr_sched_getaffinity
)((
pid_t
)
0
,
mask
);
}
if
(
rc
!=
0
)
{
fprintf
(
stderr
,
"ERROR: sched_getaffinity: %s
\n
"
,
strerror
(
errno
));
exit
(
1
);
}
}
static
int
_mask_to_int
(
cpu_set_t
*
mask
)
{
int
i
,
rc
=
0
;
for
(
i
=
0
;
i
<
CPU_SETSIZE
;
i
++
)
{
if
(
CPU_ISSET
(
i
,
mask
))
rc
+=
(
1
<<
i
);
}
return
rc
;
}
main
(
int
argc
,
char
**
argv
)
{
char
*
task_str
;
cpu_set_t
mask
;
int
task_id
;
_load_mask
(
&
mask
);
if
((
task_str
=
getenv
(
"SLURM_PROCID"
))
==
NULL
)
{
fprintf
(
stderr
,
"ERROR: getenv(SLURM_TASKID) failed
\n
"
);
exit
(
1
);
}
task_id
=
atoi
(
task_str
);
printf
(
"TASK_ID:%d,MASK:%
l
u
\n
"
,
task_id
,
mask
);
printf
(
"TASK_ID:%d,MASK:%u
\n
"
,
task_id
,
_
mask
_to_int
(
&
mask
)
);
exit
(
0
);
}
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