473,385 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Best performing use of boost::spirit

Hello,

I've been doing some research as to ways to optimise our parsing and
evaluation of mathematical expressions and came across the spirit template
library as part of the boost library.
It looks like for the parsing bit that library provides everything we need.
However, I'm still pondering about the best performing options for the
evaluation part. The idea is to evaluate the same expressions many times
with different values. Conventionally, you'd set up a parse tree and walk
down that tree to arrive at the endresult. I have been thinking about
alternative approaches using expression templates for the evaluation part
(lambda??)
Is there any use of the boost::spirit template library in combination with
the use of expression templates for evaluation? Are there any code samples
that demonstrate that combination?

TIA

P.
Sep 30 '05 #1
3 2884
> evaluation part. The idea is to evaluate the same expressions many times
with different values. Conventionally, you'd set up a parse tree and walk
down that tree to arrive at the endresult.


Another common way is to create some form of stack based p-code, but I
guess you know that pretty well :)

Maybe, if you need really the max performance, one could even think
about compiling into the real code (invoking C compiler and dynamically
link created .so should not be as hard nor slow....)

Mirek

P.S.: Sorry for now answering your question, I found this topic to be
interesting and could not resist adding my 0.02 :)
Sep 30 '05 #2
I have thought about generating C++ and dynamically link that to our .so
libs. That has a trade-off, however, in that you'd probably need to release
a compiler with your application and possible source dependencies which is
something I don't like.

"Mirek Fidler" <cx*@volny.cz> schreef in bericht
news:3q************@individual.net...
evaluation part. The idea is to evaluate the same expressions many times
with different values. Conventionally, you'd set up a parse tree and walk down that tree to arrive at the endresult.


Another common way is to create some form of stack based p-code, but I
guess you know that pretty well :)

Maybe, if you need really the max performance, one could even think
about compiling into the real code (invoking C compiler and dynamically
link created .so should not be as hard nor slow....)

Mirek

P.S.: Sorry for now answering your question, I found this topic to be
interesting and could not resist adding my 0.02 :)

Sep 30 '05 #3
Paul van Hagen wrote:
I have thought about generating C++ and dynamically link that to our .so
libs. That has a trade-off, however, in that you'd probably need to release
a compiler with your application and possible source dependencies which is
something I don't like.
Well, I guess than on any *x platform you could count on invoking "gcc".
At least, you can count to have some c compiler there... and possible
command-line differences will be just part of porting...

As for source dependencies, I think that generated code should use just
minimal standard headers (if any), perhaps just "math.h", so I do not
see too much danger with source dependencies... But of course, this
depends on what kind of expresions are you going to deal with.

Moreover, if you are even more ambitios, you can even think about
avoiding compiler and generate the code by your app. Even that might not
be as hard as it seems... (but of course, you will have to do it again
for any CPU you are porting to..)

That said, I really like your original idea of representing expression
using some form composed functor. I guess that it will be the second
fastest solution to compiled code....

Mirek

"Mirek Fidler" <cx*@volny.cz> schreef in bericht
news:3q************@individual.net...
evaluation part. The idea is to evaluate the same expressions many times
with different values. Conventionally, you'd set up a parse tree and
walk
down that tree to arrive at the endresult.


Another common way is to create some form of stack based p-code, but I
guess you know that pretty well :)

Maybe, if you need really the max performance, one could even think
about compiling into the real code (invoking C compiler and dynamically
link created .so should not be as hard nor slow....)

Mirek

P.S.: Sorry for now answering your question, I found this topic to be
interesting and could not resist adding my 0.02 :)


Sep 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Moonlit | last post by:
Hi, I am searching for the best lex and yacc combination (or something similar) that can be used in combination with C++ and that can contain C++ code. I have the regular flex/bison port working...
1
by: Ingo Nolden | last post by:
Hi, I am using spirit 1.31 I have been trying the following example from the spirit docs. I tried it with int and double neither works: vector<int> v; rule<> r = list_p(int_p, ch_p(',')); ...
4
by: Evan Carew | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Anyone familliar with Boost's Spirit library? I was trying to get it to work with my g++ 2.96 & it kept barfing pages & pages of errors. I guess...
1
by: Alf P. Steinbach | last post by:
Microsoft Visual C++ warning C4267 (the number is not a typo) can occur e.g. when compiling Boost Spirit, or when doing std::size_t x = 0; std::cout << x; when compiled with 64-bit...
1
by: FBergemann | last post by:
Hi, I wanted to start some samples with phonenix - but it doesn't work. (a polymorphic add function) Because of problems i cut it back and wanted to do just simple "reflection" 1st. But i have...
4
by: Marcin Kalicinski | last post by:
Hi All, Does anybody has experience compiling XML parser written with boost::spirit on gcc? The parser is based on http://spirit.sourceforge.net/repository/applications/xml.zip samples. What...
13
by: krbyxtrm | last post by:
hi, i have problem implemting a string parser that parser comman delimited string: "str1,str2,str3" INTO: 1. str1 2. str2 3. str3 *also strings are of any string (no specific string/keyword)
14
by: IndyStef | last post by:
Hi all, This is an inquiry into the usability of the boost libraries. We are a C++ shop, and have been using STL for some time now. When the question about using boost came up, some developers...
3
by: =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki | last post by:
How do it's by next of boost.spirit library it are not discrimitation a letter size that a small letters and big letters it are not discrimitation? I'm know how write s small parser by next of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.