Re: inlining or not inlining...

2011-02-15 Thread Stewart Gordon
On 11/02/2011 06:35, Walter Bright wrote: snip I hate not being able to force functions to be inline. A consequence is that you can't fully interface certain APIs without an extra .lib over what would be needed in C(++). You cannot force inlining in C(++) either. The inline keyword is only

Re: inlining or not inlining...

2011-02-14 Thread piotrek
On Sun, 13 Feb 2011 09:57:52 +0200, so wrote: Ok i stop, looks like i fail to make my point to anyone :) I see your point and I agree with you. Cheers Piotrek

Re: inlining or not inlining...

2011-02-14 Thread spir
On 02/14/2011 04:42 AM, Walter Bright wrote: In that vein, it is exceedingly miserable that assemblers do not accept struct declarations in C format. I always have to painstakingly translate them, and double check that all the offsets and alignment are correct. What a pain. Does D's inline asm

Re: inlining or not inlining...

2011-02-14 Thread bearophile
spir: Does D's inline asm allow that? I don't think so (but I don't know what you are able to do with static structs defined outside the asm block). In the same vein, what about a low-level language with (un)named tuples? I have suggested some kind of annotation to allow D

Re: inlining or not inlining...

2011-02-14 Thread Andrej Mitrovic
On 2/14/11, bearophile bearophileh...@lycos.com wrote: spir: Does D's inline asm allow that? I don't think so (but I don't know what you are able to do with static structs defined outside the asm block). I think the asm in DMD is the same one used in DMC, so this page should be helpfull:

Re: inlining or not inlining...

2011-02-14 Thread Walter Bright
spir wrote: On 02/14/2011 04:42 AM, Walter Bright wrote: In that vein, it is exceedingly miserable that assemblers do not accept struct declarations in C format. I always have to painstakingly translate them, and double check that all the offsets and alignment are correct. What a pain. Does

Re: inlining or not inlining...

2011-02-13 Thread so
Ok i stop, looks like i fail to make my point to anyone :)

Re: inlining or not inlining...

2011-02-13 Thread Walter Bright
so wrote: If you are against this reasoning, i don't have any idea why D has inline assembly, which again targets a very small audience. The inline assembler is s much easier to deal with than the miserable, fugly assemblers found on the various systems. The Linux as assembler is

Re: inlining or not inlining...

2011-02-13 Thread bearophile
Walter: The inline assembler can't do everything a standalone assembler can, but what it does it does well enough, and is a pleasure (to me) to use. The D inline assembler has another purpose you have not underlined: it's a didactic tool to learn some assembly without nothing but the

Re: inlining or not inlining...

2011-02-13 Thread Adam D. Ruppe
bearophile wrote: There is not much intrinsic in the asm language that forces people to not define and use a good type system on asm instructions to catch programming bugs, to indent asm code well, to use a modern IDE on asm code, and so on. All of this has been done, and caught on to a huge

Re: inlining or not inlining...

2011-02-13 Thread bearophile
Adam D. Ruppe: All of this has been done, and caught on to a huge degree. They called that asm+types language C This is part of what I was referring to: http://www.cs.cornell.edu/talc/ Bye, bearophile

Re: inlining or not inlining...

2011-02-13 Thread so
On Mon, 14 Feb 2011 00:58:48 +0200, Walter Bright newshou...@digitalmars.com wrote: so wrote: If you are against this reasoning, i don't have any idea why D has inline assembly, which again targets a very small audience. The inline assembler is s much easier to deal with than the

Re: inlining or not inlining...

2011-02-13 Thread Walter Bright
bearophile wrote: Walter: The inline assembler can't do everything a standalone assembler can, but what it does it does well enough, and is a pleasure (to me) to use. The D inline assembler has another purpose you have not underlined: it's a didactic tool to learn some assembly without

Re: inlining or not inlining...

2011-02-12 Thread Christopher Nicholson-Sauls
All of this is hardly related to the simple feature I initially asked for: string escString (string s) @tellmeifnotinlined { s2 = s.replace(\n,\\n); s2 = s.replace(\t,\\t); return s2; } void show (X x) { // ... use escString ...

Re: inlining or not inlining...

2011-02-12 Thread spir
On 02/12/2011 10:46 AM, Christopher Nicholson-Sauls wrote: All of this is hardly related to the simple feature I initially asked for: string escString (string s) @tellmeifnotinlined { s2 = s.replace(\n,\\n); s2 = s.replace(\t,\\t); return s2; }

Re: inlining or not inlining...

2011-02-12 Thread Jim
spir Wrote: On 02/11/2011 09:49 PM, bearophile wrote: Jim: If forced inlining is to be supported spir was asking for a list of functions that the compiled has inlined, not for a forced inlining functionality. You are (nearly) right, Bearophile. More precisely, I rather wish

Re: inlining or not inlining...

2011-02-12 Thread spir
On 02/12/2011 12:15 PM, Jim wrote: Sorry about that, but I think that is a closely related discussion. @inline is certainly a verb -- even imperative mood, so not just asking for information. Why do you need information if you can't affect the outcome? I want to know it. First, because it's

Re: inlining or not inlining...

2011-02-12 Thread Jim
spir Wrote: On 02/12/2011 12:15 PM, Jim wrote: Sorry about that, but I think that is a closely related discussion. @inline is certainly a verb -- even imperative mood, so not just asking for information. Why do you need information if you can't affect the outcome? I want to know it.

Re: inlining or not inlining...

2011-02-12 Thread spir
On 02/12/2011 12:42 PM, Jim wrote: spir Wrote: On 02/12/2011 12:15 PM, Jim wrote: Sorry about that, but I think that is a closely related discussion. @inline is certainly a verb -- even imperative mood, so not just asking for information. Why do you need information if you can't affect the

Re: inlining or not inlining...

2011-02-12 Thread ivan
Jim Wrote: spir Wrote: On 02/12/2011 12:15 PM, Jim wrote: Sorry about that, but I think that is a closely related discussion. @inline is certainly a verb -- even imperative mood, so not just asking for information. Why do you need information if you can't affect the outcome?

Re: inlining or not inlining...

2011-02-12 Thread ivan
ivan Wrote: Jim Wrote: spir Wrote: On 02/12/2011 12:15 PM, Jim wrote: Sorry about that, but I think that is a closely related discussion. @inline is certainly a verb -- even imperative mood, so not just asking for information. Why do you need information if you can't

Re: inlining or not inlining...

2011-02-12 Thread Jim
to request inlining at the place of calling a function, not only at the definition of the function.

Re: inlining or not inlining...

2011-02-12 Thread JimBob
other of the myriad of compiler optimizations? Inlining is an important optimization, so give this information to the programmer is a good start. Register allocation is far more important than inlining. Why not give information about why a variable was not enregistered? Whether either

Re: inlining or not inlining...

2011-02-12 Thread so
This is to all of you. Inlining is not a toy, knowing if a function is inlined or not has no practical purposes in the sense you are asking, or any other for that matter. This is a low level optimization, again it is not a toy to play with, and D being a system language (where function call

Re: inlining or not inlining...

2011-02-12 Thread so
There are all kinds of extensions popular in C++, but they are not part of Standard C++. That is because if they don't support an extension (where standard failed to provide), people would switch to different compiler that would. If you mean there are many things a language can't possibly

Re: inlining or not inlining...

2011-02-12 Thread spir
for compilers! ;-) Denis This is to all of you. Inlining is not a toy, knowing if a function is inlined or not has no practical purposes in the sense you are asking, or any other for that matter. This is a low level optimization, again it is not a toy to play with, and D being a system language

Re: inlining or not inlining...

2011-02-12 Thread so
How many times do I need to repeat I do not want to force inlining? Or what else are you talking about? And this is why it doesn't make sense. What are we doing here? Are we trying to find practical solutions to real world problems or just showing how useless things D can do? Instead, I

Re: inlining or not inlining...

2011-02-11 Thread Walter Bright
so wrote: You cannot force inlining in C(++) either. The inline keyword is only a suggestion. I'm not understanding your last comment that a .lib would be required. That's not correct, as since you're supplying the full source anyway (needed for inlining), just compile in that source from

Re: inlining or not inlining...

2011-02-11 Thread Jim
--depending on a variety of factors, inlining may in fact be counter-productive. snip I hate not being able to force functions to be inline. A consequence is that you can't fully interface certain APIs without an extra .lib over what would be needed in C(++). You cannot

Re: inlining or not inlining...

2011-02-11 Thread Walter Bright
Jonathan M Davis wrote: Regardless, I would _hope_ that the compiler would be smart enough to make intelligent choices about inlining. That's probably one of those areas that can always be improved however. I agree completely. All compilers could use better register allocation algorithms

Re: inlining or not inlining...

2011-02-11 Thread Walter Bright
so wrote: While in isolation that's a good idea, how far should it be taken? Should the compiler emit information on which variables wound up in which registers, and why? What about other of the myriad of compiler optimizations? Isn't Inlining by far the most important (most practical

Re: inlining or not inlining...

2011-02-11 Thread Brad Roberts
On 2/11/2011 12:37 AM, Walter Bright wrote: so wrote: While in isolation that's a good idea, how far should it be taken? Should the compiler emit information on which variables wound up in which registers, and why? What about other of the myriad of compiler optimizations? Isn't Inlining

Re: inlining or not inlining...

2011-02-11 Thread so
think we are talking about two different things, i don't mean locating the cause of the bottleneck, it is of course the most logical thing to do. Assume we know the problem, a function that has been reduced to simplest case, still compiler for some reason didn't do the inlining and we need

Re: inlining or not inlining...

2011-02-11 Thread so
Wrappers and frequent matrix, vector operations are -a- very serious examples that inlining is must. Now, it doesn't matter how easy or hard, -have- +how+ could we get around this? This is a great +excuse+ for an annotation. duh... how hard to synchronize brain, hands and eyes...

Re: inlining or not inlining...

2011-02-11 Thread spir
On 02/11/2011 09:33 AM, Jim wrote: Regardless, I would _hope_ that the compiler would be smart enough to make intelligent choices about inlining. That's probably one of those areas that can always be improved however. I also think that this decision should be left to the compiler

Re: inlining or not inlining...

2011-02-11 Thread bearophile
Walter: While in isolation that's a good idea, how far should it be taken? Should the compiler emit information on which variables wound up in which registers, and why? What about other of the myriad of compiler optimizations? Inlining is an important optimization, so give this information

Re: inlining or not inlining...

2011-02-11 Thread so
But I'm sure this sort of thing is also highly variable based on type of applications, code style, language, etc. Indeed it is, for example you won't hear much complaints from game developers because they rely on GPU for most of the computations these days, but there are other areas where

Re: inlining or not inlining...

2011-02-11 Thread spir
imagine an inline annotation beeing, not a request for inlining, but a request for compiler warning emission when inlining would not be applied to a given annotated func. Then, programmers would at least know, beeing thus able to choose on an informed basis. Complement to that may be a little

Re: inlining or not inlining...

2011-02-11 Thread spir
On 02/11/2011 07:53 AM, so wrote: While in isolation that's a good idea, how far should it be taken? Should the compiler emit information on which variables wound up in which registers, and why? What about other of the myriad of compiler optimizations? Isn't Inlining by far the most important

Re: inlining or not inlining...

2011-02-11 Thread bearophile
spir: People possibly interested in the question of inlining (or more generally factors of (in)efficiency) must start somehow, granted. But making it even more difficult than necessary, while we all know it is inherently a very complex topic, does not bring much, don't you think

Re: inlining or not inlining...

2011-02-11 Thread Jim
spir Wrote: On 02/11/2011 09:33 AM, Jim wrote: Regardless, I would _hope_ that the compiler would be smart enough to make intelligent choices about inlining. That's probably one of those areas that can always be improved however. I also think that this decision should be left

Re: inlining or not inlining...

2011-02-11 Thread bearophile
Jim: I rarely need to go that low-level. Two times I have had D1 code that was too much slow compared to equivalent C code. After profiling and some changes I have understood that the cause was an important missing inline. With a list of the inlined functions (as done by CommonLisp some

Re: inlining or not inlining...

2011-02-11 Thread spir
On 02/11/2011 07:08 PM, bearophile wrote: Jim: I rarely need to go that low-level. Two times I have had D1 code that was too much slow compared to equivalent C code. After profiling and some changes I have understood that the cause was an important missing inline. With a list of the

Re: inlining or not inlining...

2011-02-11 Thread Walter Bright
bearophile wrote: While in isolation that's a good idea, how far should it be taken? Should the compiler emit information on which variables wound up in which registers, and why? What about other of the myriad of compiler optimizations? Inlining is an important optimization, so give

Re: inlining or not inlining...

2011-02-11 Thread Jim
bearophile Wrote: The LLVM back-end of LDC is able to inline much more, but even here a list of inlined/not inlined functions helps. D is almost a system language, so sometimes you need to go lower level (or you just need a program that's not too much slow). If forced inlining

Re: inlining or not inlining...

2011-02-11 Thread spir
On 02/11/2011 08:11 PM, Walter Bright wrote: bearophile wrote: While in isolation that's a good idea, how far should it be taken? Should the compiler emit information on which variables wound up in which registers, and why? What about other of the myriad of compiler optimizations? Inlining

Re: inlining or not inlining...

2011-02-11 Thread Jim
inlining is to be supported I think it would be good idea to also let the _caller_ decide whether to inline a function. The compiler could simply find the function definition, perhaps parameterize it, and then insert it. Should it not be able to inline almost any function if asked to? Just

Re: inlining or not inlining...

2011-02-11 Thread bearophile
Jim: If forced inlining is to be supported spir was asking for a list of functions that the compiled has inlined, not for a forced inlining functionality. Bye, bearophile

Re: inlining or not inlining...

2011-02-11 Thread bearophile
Walter: bearophile wrote: While in isolation that's a good idea, how far should it be taken? Should the compiler emit information on which variables wound up in which registers, and why? What about other of the myriad of compiler optimizations? Inlining is an important

Re: inlining or not inlining...

2011-02-11 Thread bearophile
spir: About inline, note that no-one asks for information on every potentially inlinable func, blindly. But having a way to know that about /this/ func one is wondering about would be great: just append @inline to it, recompile, et voilà! you know :-) (provided you can interpret the

Re: inlining or not inlining...

2011-02-11 Thread Christopher Nicholson-Sauls
much slow). If forced inlining is to be supported I think it would be good idea to also let the _caller_ decide whether to inline a function. The compiler could simply find the function definition, perhaps parameterize it, and then insert it. Should it not be able to inline almost any

Re: inlining or not inlining...

2011-02-11 Thread spir
On 02/11/2011 09:49 PM, bearophile wrote: Jim: If forced inlining is to be supported spir was asking for a list of functions that the compiled has inlined, not for a forced inlining functionality. You are (nearly) right, Bearophile. More precisely, I rather wish @inline on a given func

Re: inlining or not inlining...

2011-02-11 Thread spir
to go lower level (or you just need a program that's not too much slow). If forced inlining is to be supported I think it would be good idea to also let the _caller_ decide whether to inline a function. The compiler could simply find the function definition, perhaps parameterize

Re: inlining or not inlining...

2011-02-11 Thread spir
On 02/11/2011 10:08 PM, bearophile wrote: spir: About inline, note that no-one asks for information on every potentially inlinable func, blindly. But having a way to know that about /this/ func one is wondering about would be great: just append @inline to it, recompile, et voilà! you know :-)

Re: inlining or not inlining...

2011-02-11 Thread Walter Bright
? Inlining is an important optimization, so give this information to the programmer is a good start. Register allocation is far more important than inlining. Why not give information about why a variable was not enregistered? Because we do not ask for it ;-) Actually, that is a good reason

Re: inlining or not inlining...

2011-02-11 Thread Walter Bright
bearophile wrote: There are two groups of register allocation algorithms. The very fast ones, and the more precise ones. You even have perfect ones. Experience has shown that the difference in runtime performance between the precise algorithm and the perfect ones is often about 5% (this measured

Re: inlining or not inlining...

2011-02-11 Thread so
Register allocation is far more important than inlining. Why not give information about why a variable was not enregistered? I am sorry Walter but your stance on this more politic than a practical fact, it is not you, sounds like you secured a professorship!. :)

Re: inlining or not inlining...

2011-02-11 Thread so
All of this is hardly related to the simple feature I initially asked for: string escString (string s) @tellmeifnotinlined { s2 = s.replace(\n,\\n); s2 = s.replace(\t,\\t); return s2; } void show (X x) { // ... use

Re: inlining or not inlining...

2011-02-11 Thread so
Register allocation is far more important than inlining. Why not give information about why a variable was not enregistered? I am sorry Walter but your stance on this more politic than a practical fact, it is not you, sounds like you secured a professorship!. :) Now i started to see

Re: inlining or not inlining...

2011-02-10 Thread Stewart Gordon
On 09/02/2011 12:14, spir wrote: Hello, Walter states that inline annotations are useless, since programmers cannot generally know which function /should/ be inlined --depending on a variety of factors, inlining may in fact be counter-productive. snip I hate not being able to force

Re: inlining or not inlining...

2011-02-10 Thread Walter Bright
, not a request for inlining, but a request for compiler warning emission when inlining would not be applied to a given annotated func. Then, programmers would at least know, beeing thus able to choose on an informed basis. Complement to that may be a little (and hopefully clear) how-to guide on best

Re: inlining or not inlining...

2011-02-10 Thread Walter Bright
Stewart Gordon wrote: On 09/02/2011 12:14, spir wrote: Hello, Walter states that inline annotations are useless, since programmers cannot generally know which function /should/ be inlined --depending on a variety of factors, inlining may in fact be counter-productive. snip I hate

Re: inlining or not inlining...

2011-02-10 Thread so
You cannot force inlining in C(++) either. The inline keyword is only a suggestion. I'm not understanding your last comment that a .lib would be required. That's not correct, as since you're supplying the full source anyway (needed for inlining), just compile in that source from

Re: inlining or not inlining...

2011-02-10 Thread Jonathan M Davis
, inlining may in fact be counter-productive. snip I hate not being able to force functions to be inline. A consequence is that you can't fully interface certain APIs without an extra .lib over what would be needed in C(++). You cannot force inlining in C(++) either. The inline

Re: inlining or not inlining...

2011-02-10 Thread so
While in isolation that's a good idea, how far should it be taken? Should the compiler emit information on which variables wound up in which registers, and why? What about other of the myriad of compiler optimizations? Isn't Inlining by far the most important (most practical) optimization

Re: inlining or not inlining...

2011-02-10 Thread Brad Roberts
On 2/10/2011 10:53 PM, so wrote: While in isolation that's a good idea, how far should it be taken? Should the compiler emit information on which variables wound up in which registers, and why? What about other of the myriad of compiler optimizations? Isn't Inlining by far the most

Re: inlining or not inlining...

2011-02-10 Thread so
of the myriad of compiler optimizations? Isn't Inlining by far the most important (most practical) optimization among those that actually we can control? A few times i have seen comparisons here to similar languages and in most of them the inlining was the reason (only) for the inferior

Re: inlining or not inlining...

2011-02-10 Thread Brad Roberts
registers, and why? What about other of the myriad of compiler optimizations? Isn't Inlining by far the most important (most practical) optimization among those that actually we can control? A few times i have seen comparisons here to similar languages and in most of them the inlining

inlining or not inlining...

2011-02-09 Thread spir
Hello, Walter states that inline annotations are useless, since programmers cannot generally know which function /should/ be inlined --depending on a variety of factors, inlining may in fact be counter-productive. I totally agree, even more after having (superficially) explored the topic

Re: inlining or not inlining...

2011-02-09 Thread Nick Sabalausky
spir denis.s...@gmail.com wrote in message news:mailman.1420.1297253687.4748.digitalmar...@puremagic.com... By the way, I would love a [rather big] tutorial on efficiency -- what do you think? That would be great. Funny timing on your mentioning that, though: I just noticed today that one

Re: inlining or not inlining...

2011-02-09 Thread Trass3r
This howto would start by describing most common and/or most critical criteria for the compiler to /not/ inline a given func. Well if I read the code correctly: - inline assembler - variadic functions (string s, ...) - synchronized - imported functions - functions with closure vars - virtual

Re: inlining or not inlining...

2011-02-09 Thread Trass3r
At least back in 2010: http://www.digitalmars.com/d/archives/digitalmars/D/learn/Is_there_a_way_to_get_a_list_of_functions_that_get_inlined_by_dmd_18798.html#N18810

Re: inlining or not inlining...

2011-02-09 Thread spir
On 02/09/2011 03:53 PM, Trass3r wrote: This howto would start by describing most common and/or most critical criteria for the compiler to /not/ inline a given func. Well if I read the code correctly: - inline assembler - variadic functions (string s, ...) - synchronized - imported functions -