Permalink
Browse files

Relax clu:setup/1

Be compatible with Intels empty list of devices
and ignore non-successful initializations if we have more platforms
to try
  • Loading branch information...
1 parent c546684 commit 1daed87cd4a858e1755e12b5c5ee33a0cd1f7463 @dgud dgud committed with dgud Nov 10, 2011
Showing with 16 additions and 6 deletions.
  1. +1 −1 src/cl.erl
  2. +15 −5 src/clu.erl
View
@@ -177,7 +177,7 @@ init() ->
4 -> filename:join([Lib,"32","cl_nif"]);
8 -> filename:join([Lib,"64","cl_nif"])
end,
- io:format("Loading: ~s\n", [Nif]),
+ %% io:format("Loading: ~s\n", [Nif]),
erlang:load_nif(Nif, 0).
%%
View
@@ -34,19 +34,29 @@ setup(DevType) ->
setup(DevType, [Platform|Ps]) ->
case cl:get_device_ids(Platform,DevType) of
+ {ok, []} ->
+ setup(DevType, Ps);
{ok,DeviceList} ->
- {ok,Context} = cl:create_context(DeviceList),
- #cl { platform = Platform,
- devices = DeviceList,
- context = Context };
+ case cl:create_context(DeviceList) of
+ {ok,Context} ->
+ #cl { platform = Platform,
+ devices = DeviceList,
+ context = Context };
+ {error, _} when Ps /= [] ->
+ setup(DevType, Ps);
+ Other ->
+ Other
+ end;
{error, device_not_found} ->
setup(DevType, Ps);
+ {error, _} when Ps /= [] ->
+ setup(DevType, Ps);
Other ->
Other
end;
setup(DevType, []) ->
{error, {device_not_found, DevType}}.
-
+
%%
%% @doc setup a clu context with all devices.

0 comments on commit 1daed87

Please sign in to comment.