Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change underlying TPS struct #122

Closed
mattsignorelli opened this issue Jul 12, 2024 · 4 comments
Closed

Change underlying TPS struct #122

mattsignorelli opened this issue Jul 12, 2024 · 4 comments

Comments

@mattsignorelli
Copy link
Contributor

This will be a lot of work, but I think is worth it
#121

I think by putting the ctors in Julia and using jl_malloc INSIDE Julia, there could be a massive speedup (simple testing shows so).

This requires removing the flexible array members from the tpsa structs in C and replacing them with pointers. There is a bit of a slowdown here but I think using everything inside Julia will make up for it

@mattsignorelli
Copy link
Contributor Author

The time for operations is of course unchanged, but the allocations are now significantly faster:

julia> @btime NewTPS{Float64}($d.desc, GTPSA.MAD_TPSA_SAME)
  47.208 ns (2 allocations: 62.62 KiB)
NewTPS{Float64}(Ptr{GTPSA.Desc} @0x0000600001f14000, 0x01, 0x00, 0x0a, 0x0a, 0, (0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00), Ptr{Float64} @0x00000001330f8010)

julia> @btime TPS(use=$d)
  769.939 ns (1 allocation: 16 bytes)
TPS:
 Coefficient                Order   Exponent
  0.0000000000000000e+00      0      0   0   0   0   0   0

@mattsignorelli
Copy link
Contributor Author

#123

@mattsignorelli
Copy link
Contributor Author

Speed differences for the benchmark without @FastGTPSA appears negligible, including not using the flexible array members. However Julia memory usage now stays completely sane. Also, I tested using Vectors of these new structs and feeding that straight into the C (instead of creating temporary array of pointers as I was) and that appears to be working too.

@mattsignorelli
Copy link
Contributor Author

Fixed in #123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant