Skip to content

Instantly share code, notes, and snippets.

@kevsmith
Created March 10, 2011 14:25
Show Gist options
  • Select an option

  • Save kevsmith/864154 to your computer and use it in GitHub Desktop.

Select an option

Save kevsmith/864154 to your computer and use it in GitHub Desktop.
Snapshot of current
1> l(pteracuda_nifs).
{module,pteracuda_nifs}
2> {ok, Ctx} = pteracuda_nifs:new_context().
{ok,<<>>}
3> {ok, Buf} = pteracuda_nifs:new_buffer().
{ok,<<>>}
4> F = fun(_, _) -> random:uniform(100) > 49 end.
#Fun<erl_eval.12.113037538>
%% Randomize a list
5> N = lists:sort(F, lists:seq(1, 1000000)).
[683074,417721,398080,386936,278674,250020,250975,703592,
398715,533496,420733,276179,570418,396154,288017,562821,
673245,288732,420213,418741,250136,705195,533009,275911,
428770,249973,427131,526510,711228|...]
%% Write it to a pteracuda buffer
6> timer:tc(pteracuda_nifs, write_buffer, [Buf, N]).
{40594,ok}
%% Sort 1 million ints on the GPU
7> timer:tc(pteracuda_nifs, sort_buffer, [Ctx, Buf]).
{38180,ok}
8> pteracuda_nifs:destroy_buffer(Buf)
ok
9> pteracuda_nifs:destroy_context(Ctx)
ok
10>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment