Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libclfft
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maximillian Bensch
libclfft
Commits
6abc5466
Commit
6abc5466
authored
14 years ago
by
Oliver Bock
Browse files
Options
Downloads
Patches
Plain Diff
Added crude feature to pass device ID as second command line argument (replaying
3987009c
)
parent
47d231be
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
example/main.cpp
+49
-27
49 additions, 27 deletions
example/main.cpp
with
49 additions
and
27 deletions
example/main.cpp
+
49
−
27
View file @
6abc5466
...
@@ -740,51 +740,73 @@ int main (int argc, char * const argv[]) {
...
@@ -740,51 +740,73 @@ int main (int argc, char * const argv[]) {
}
}
device_id
=
NULL
;
device_id
=
NULL
;
unsigned
int
i
=
0
;
unsigned
int
i
;
if
(
argc
==
3
)
{
for
(
i
=
0
;
i
<
num_devices
;
i
++
)
{
cl_bool
available
;
cl_bool
available
;
err
=
clGetDeviceInfo
(
device_ids
[
i
],
CL_DEVICE_AVAILABLE
,
sizeof
(
cl_bool
),
&
available
,
NULL
);
err
=
clGetDeviceInfo
(
device_ids
[
atoi
(
argv
[
2
])
],
CL_DEVICE_AVAILABLE
,
sizeof
(
cl_bool
),
&
available
,
NULL
);
if
(
err
)
if
(
err
)
{
{
printf
(
"ERROR: Cannot check device availability of device # %d
\n
"
,
atoi
(
argv
[
2
]));
log_error
(
"Cannot check device availability of device # %d
\n
"
,
i
)
;
return
-
1
;
}
}
if
(
available
)
if
(
available
)
{
{
device_id
=
device_ids
[
atoi
(
argv
[
2
])];
device_id
=
device_ids
[
i
];
}
else
{
char
name
[
200
];
char
name
[
200
];
err
=
clGetDeviceInfo
(
device_ids
[
i
],
CL_DEVICE_NAME
,
sizeof
(
name
),
name
,
NULL
);
err
=
clGetDeviceInfo
(
device_ids
[
i
],
CL_DEVICE_NAME
,
sizeof
(
name
),
name
,
NULL
);
if
(
err
==
CL_SUCCESS
)
{
if
(
err
==
CL_SUCCESS
)
{
printf
(
"
INFO: Using device %s...
\n
"
,
name
);
printf
(
"
ERROR: Device %s not available for compute
\n
"
,
name
);
}
}
else
{
else
{
printf
(
"
INFO: Using device # %d...
\n
"
,
i
);
printf
(
"
ERROR: Device # %d not available for compute
\n
"
,
atoi
(
argv
[
2
])
);
}
}
b
re
ak
;
re
turn
-
1
;
}
}
else
}
else
{
for
(
i
=
0
;
i
<
num_devices
;
i
++
)
{
{
cl_bool
available
;
err
=
clGetDeviceInfo
(
device_ids
[
i
],
CL_DEVICE_AVAILABLE
,
sizeof
(
cl_bool
),
&
available
,
NULL
);
if
(
err
)
{
log_error
(
"Cannot check device availability of device # %d. Continuing with next available device...
\n
"
,
i
);
continue
;
}
if
(
available
)
{
device_id
=
device_ids
[
i
];
break
;
}
else
{
char
name
[
200
];
char
name
[
200
];
err
=
clGetDeviceInfo
(
device_ids
[
i
],
CL_DEVICE_NAME
,
sizeof
(
name
),
name
,
NULL
);
err
=
clGetDeviceInfo
(
device_ids
[
i
],
CL_DEVICE_NAME
,
sizeof
(
name
),
name
,
NULL
);
if
(
err
==
CL_SUCCESS
)
if
(
err
==
CL_SUCCESS
)
{
{
log_info
(
"Device %s not available for compute
\n
"
,
name
);
log_info
(
"Device %s not available for compute
\n
"
,
name
);
}
}
else
else
{
{
log_info
(
"Device # %d not available for compute
\n
"
,
i
);
log_info
(
"Device # %d not available for compute
\n
"
,
i
);
}
}
}
}
}
}
}
if
(
!
device_id
)
if
(
!
device_id
)
{
{
log_error
(
"None of the devices available for compute ... aborting test
\n
"
);
log_error
(
"None of the devices available for compute ... aborting test
\n
"
);
test_finish
();
test_finish
();
return
-
1
;
return
-
1
;
}
}
else
{
char
name
[
200
];
err
=
clGetDeviceInfo
(
device_id
,
CL_DEVICE_NAME
,
sizeof
(
name
),
name
,
NULL
);
if
(
err
==
CL_SUCCESS
)
{
printf
(
"INFO: Using device %s...
\n
"
,
name
);
}
else
{
printf
(
"INFO: Using device # %d...
\n
"
,
i
);
}
}
context
=
clCreateContext
(
0
,
1
,
&
device_id
,
NULL
,
NULL
,
&
err
);
context
=
clCreateContext
(
0
,
1
,
&
device_id
,
NULL
,
NULL
,
&
err
);
if
(
!
context
||
err
)
if
(
!
context
||
err
)
...
@@ -826,7 +848,7 @@ int main (int argc, char * const argv[]) {
...
@@ -826,7 +848,7 @@ int main (int argc, char * const argv[]) {
return
-
1
;
return
-
1
;
}
}
if
(
argc
=
=
2
)
{
// arguments are supplied in a file with arguments for a single run are all on the same line
if
(
argc
>
=
2
)
{
// arguments are supplied in a file with arguments for a single run are all on the same line
paramFile
=
fopen
(
argv
[
1
],
"r"
);
paramFile
=
fopen
(
argv
[
1
],
"r"
);
if
(
!
paramFile
)
{
if
(
!
paramFile
)
{
log_error
(
"Cannot open the parameter file
\n
"
);
log_error
(
"Cannot open the parameter file
\n
"
);
...
...
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