NativeBoost opportunties?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

NativeBoost opportunties?

Schwab,Wilhelm K
Sig,

Today, I ran into a bug of mine that I would not have had to track down if the various typed byte arrays (double in particular) existed.  The more you can offer in that area, with indexing, bulk fill, bulk copy, etc., the better.

I also ran into what appears to be a maximum number of arguments to an external call.  Can you get around that?  I can too, in this case.  It's shameless, but I will "dumb down" the call so that FFI can handle it.  There are arguments that I can default or provide from a shared library, and just call into a facade function exported from there.  Shouldn't have to do that, clearly, but it will work.

Bill




_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: NativeBoost opportunties?

Igor Stasenko
On 26 September 2010 06:43, Schwab,Wilhelm K <[hidden email]> wrote:
> Sig,
>
> Today, I ran into a bug of mine that I would not have had to track down if the various typed byte arrays (double in particular) existed.  The more you can offer in that area, with indexing, bulk fill, bulk copy, etc., the better.
>
> I also ran into what appears to be a maximum number of arguments to an external call.  Can you get around that?  I can too, in this case.  It's shameless, but I will "dumb down" the call so that FFI can handle it.  There are arguments that I can default or provide from a shared library, and just call into a facade function exported from there.  Shouldn't have to do that, clearly, but it will work.
>

NB supports facade calls.
And i'm using them a lot, since many functions having default values,
which never change.
There's one limitation, that constant arguments should be 32-bit int/uint.

In function spec you can put integer constants or class/pool variables.
Suppose you have a C function
 foo( int x , int y)

so, FFI allows you to use only in this style:

fooX: x y: y
  <primitive ... >
  ^ NBFFICallout cdecl: #(    foo (int x, int y) ) module: 'bar'

i.e. , method arguments 1:1 matching function argument.

With NB, however you can pass them in arbitraty order, or push same
argument twice, like:

fooX: x
  <primitive ... >
  ^ NBFFICallout cdecl: #(    foo (int x, byte x) ) module: 'bar'


or use constants:

fooX: x
  <primitive ... >
  ^ NBFFICallout cdecl: #(    foo (int x, 0 ) )  module: 'bar'

so, y argument will be zero.

or use class/pool vars for constants:

fooX: x
  <primitive ... >
  ^ NBFFICallout cdecl: #(    foo (int x, SomeClassVar ) ) module: 'bar'

so, it will use a SomeClassVar value at the moment of code generation.

or use inst vars as arguments:

Point>>foo
  <primitive ... >
  ^ NBFFICallout cdecl: #(    foo (int x, int y) )  module: 'bar'

it will use receiver's x and y instance variables to coerce&push them
as arguments.

You also can use self (receiver) as an argument name, but then,
obviously you have to tell NB how to
coerce instance of your class to some C type.



> Bill
>
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project