dmd download issues
Just a heads up, chrome is throwing a virus detected error in the dmd-2.071.1.exe file.
Re: GC pathological case behaviour
On Tuesday, 28 June 2016 at 19:03:14 UTC, John Colvin wrote: On my machine (OS X), this program eats up memory with no end in sight import std.concurrency; import core.stdc.stdio; void start() { while(true) { receive( (int msg) { char[2] s = '\0'; s[0] = cast(char)msg; puts(s.ptr);// remove this => no memory leak } ); } } void main() { auto hw_tid = spawn(); while(true) { send(hw_tid, 64); auto b = new ubyte[](1_000); // 10_000 => no memory leak } } This is very odd, no? I'm not sure if it's a bug, but it sure is surprising. Why should "puts" cause a GC leak (writeln is the same)? What's so special about small allocations that allows all my memory to get filled up? Is puts high enough latency that, that main thread can fill the message queue faster then start can exhaust it? If you put a call to sleep for 1ms in the main loop does it have the same result?
Re: C++17 is feature complete
On Monday, 27 June 2016 at 19:34:18 UTC, Ola Fosheim Grøstad wrote: On Monday, 27 June 2016 at 19:32:39 UTC, luminousone wrote: Its the nature of being compatible with C, it might not be explicitly stated in the spec, but the only place to put the vtable pointer and stay compatible with C structs is at the end. No... You are making way too many assumptions. By all means believe whatever delusion fits your corner of the universe.
Re: C++17 is feature complete
On Monday, 27 June 2016 at 18:58:25 UTC, Ola Fosheim Grøstad wrote: On Monday, 27 June 2016 at 18:23:11 UTC, default0 wrote: Regarding C++ I found this to be a fun read: http://yosefk.com/c++fqa/ :-) A lot of it makes sense... C++ is what happens when you evolve, evolve, evolve and evolve a language from a starting-point that was not a high level language, desperately trying to hone it into high level shoes... Those shoes will never fit perfectly, obviously. It gets even more expansive when you add inn compiler extensions. For instance gcc/clang simd extensions is basically taking in parts of OpenCL into C++. In order to figure out how they work you have to read the OpenCL spec... I only found out today that I can do "simd.even" and "simd.odd" to get even and odd elements from a simd register in Clang... after implementing it manually first. ;-/ OpenCL is for micro threading, not simd. OpenCL allows you to run thousands of instances of the same function in parallel, in either the cpu and/or the gpu. SIMD or single instruction multiple data, is for instruction level parallelism,aka vector add op that adds 4 floats to 4 other floats in a single cpu instruction.
Re: C++17 is feature complete
On Monday, 27 June 2016 at 16:48:16 UTC, Ola Fosheim Grøstad wrote: On Monday, 27 June 2016 at 16:38:07 UTC, luminousone wrote: easy to implement. In C++ the exact position of the vtable depends on what is in the base most class, it might be 8bytes in, maybe 20, maybe 200, you just don't know, And certainly the runtime can't know. I know what the usual implementation is, but I don't believe it is required by the spec. So it is implementation defined and the runtime most certainly can know if that is part of the requirement. As I said, you don't even need to use a vtable AFAIK. Can show me the section in the spec where it is required? I can't find it. Its the nature of being compatible with C, it might not be explicitly stated in the spec, but the only place to put the vtable pointer and stay compatible with C structs is at the end. You will notice in D you can't inherit from a struct, this isn't merely design choice.
Re: C++17 is feature complete
On Monday, 27 June 2016 at 16:10:13 UTC, Ola Fosheim Grøstad wrote: On Monday, 27 June 2016 at 16:03:44 UTC, luminousone wrote: C++ post pended vtable pointers, Are not implementation dependent. I don't know what «post pended vtable pointers» means. Which section of the C++ spec are you referring to? http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf Member name lookup, Virtual functions, some where in their. When you declare an object, class a{ int b; int c; //** the compiler puts a hidden variable here called the vtable pointer **// void **vtble; virtual void somefunc(); } All of your virtual functions are referenced from this table; So that inherited classes will call the correct function based on the type of said object and the overrides in said object. C#, D, put the vtable as the very first item in the base most class, C++ puts this as the last item in the base most class, C# and D use the first item in the vtable for type information generated by the compiler at compile time. Because the vtable is in the same place in ALL objects type reflection is very easy to implement. In C++ the exact position of the vtable depends on what is in the base most class, it might be 8bytes in, maybe 20, maybe 200, you just don't know, And certainly the runtime can't know. Granted their are really bloated, slow, and memory chugging ways around this, such as storing a list of every allocated object in memory somewhere, and having reflection calls search this using an objects memory address.
Re: C++17 is feature complete
On Monday, 27 June 2016 at 15:59:30 UTC, Ola Fosheim Grøstad wrote: On Monday, 27 June 2016 at 15:54:16 UTC, luminousone wrote: C++ has post pended vtable pointers on class objects, its unlikely good reflection can ever be added to the language, as the vtable may be in a different place in every object their is no way to access it universally for object type information. Some Compile time type reflection might be possible, But I bet it ends up being flimsy. Huh? IIRC it is implementation defined in C++. There are C++ compilers/tools that provide more extensive reflection, but it is not part of the standard beyond simple typeid reflection. C++ post pended vtable pointers, Are not implementation dependent.
Re: C++17 is feature complete
On Monday, 27 June 2016 at 06:16:57 UTC, Ola Fosheim Grøstad wrote: On Monday, 27 June 2016 at 05:33:24 UTC, luminousone wrote: On Sunday, 26 June 2016 at 22:32:55 UTC, Walter Bright wrote: On 6/26/2016 10:18 AM, Enamex wrote: - template arguments that accept constant values of any type whatsoever 'template'; Still adding D features, I see! Now if only they could bring over some of D's superior template syntax, all of the <>'s are so damned ugly, Or type reflection features(is this even possible in c++?). Ugh, D's template syntax is far from superior :-(. What kind of type reflection are you thinking of? C++ has static type traits and some very limited dynamic reflection for classes with virtual functions, but C++ is nowhere near Python's capabilities. C++ does have a special interest group working on reflection: https://root.cern.ch/blog/status-reflection-c D's template syntax is vastly superior to C++... C++ has post pended vtable pointers on class objects, its unlikely good reflection can ever be added to the language, as the vtable may be in a different place in every object their is no way to access it universally for object type information. Some Compile time type reflection might be possible, But I bet it ends up being flimsy.
Re: C++17 is feature complete
On Monday, 27 June 2016 at 15:16:19 UTC, Ola Fosheim Grøstad wrote: On Monday, 27 June 2016 at 14:57:10 UTC, Patrick Schluter wrote: I forgot. No it's not more readable, to the contrary. The issue is that normally { } introduces an indentation, which is always associated with some kind of branching. Adding an indentation just for the declaration of a variable is an inconsistency annoying to read. I had the case several times in the code I was transforming and it had me each time puzzled at where the loop or condition was. I see your point, but I like to keep conditional clean. Usually the expression is long when I have to check an error code in C++. I don't think the following is easy on my eyes and it is not at all clear where the destructor is called: if ( auto file = ::tool::filesystem::open("/path/to/somewhere/xx"); file != nullptr) { ... } else if(…) { ... } else { ... } I think this is easier to read, and the location for the destruction is obvious: { auto file = ::tool::filesystem::open("/path/to/somewhere/xx"); if ( file != nullptr ) { ... } else if(…) { ... } else { ... } } In modern C++ one has to think about introducing scopes to gain control over where RAII is created and destructed. Modern C++ is a train-wreck, I don't think we should consider D features around the flaws of another language. Luckily we don't have to code with the worry of labyrinth like namespaces so deep and bloated that the language needs a special keyword to let the compiler know that the following blobby mass is a typename.
Re: C++17 is feature complete
On Sunday, 26 June 2016 at 22:32:55 UTC, Walter Bright wrote: On 6/26/2016 10:18 AM, Enamex wrote: - template arguments that accept constant values of any type whatsoever 'template'; Still adding D features, I see! Now if only they could bring over some of D's superior template syntax, all of the <>'s are so damned ugly, Or type reflection features(is this even possible in c++?).
Re: Is Anything Holding you back?
On Friday, 2 October 2015 at 08:23:56 UTC, Sönke Ludwig wrote: Am 02.10.2015 um 10:15 schrieb Kagamin: On Friday, 2 October 2015 at 08:03:03 UTC, Dmitry Olshansky wrote: On 02-Oct-2015 10:49, Kagamin wrote: On Friday, 2 October 2015 at 05:15:26 UTC, luminousone wrote: vibe.d compatible sqlite, postgresql, and oracle sql drivers. An ODBC driver would be fine too, anything that can connect to a database. http://dlang.org/phobos/etc_c_odbc_sql.html http://wiki.dlang.org/Libraries_and_Frameworks#Databases http://code.dlang.org/?sort=name=library.database Looks like an async postgresql driver is in their, but i don't see sqlite supported in this fashion yet. I would love to use vibe.d(we currently use java/tomcat with spring framework) in some of the projects at work, but most of this would require connecting to an oracle server, I will re-examine the pgsql situation. We have several projects coming up where we will get a dataset from the Utah department of environmental quality and we will build a small website around it for the public to query and look at the data in a user friendly fashion. Assuming pgsql support is up to snuff, I can get away with using vibe.d. And I believe anyway that I could finish the project faster with vibe.d then java/tomcat/spring.
Re: Is Anything Holding you back?
On Friday, 2 October 2015 at 02:25:21 UTC, Yaser wrote: Are there any critical frameworks or libraries that are holding you back in fully investing in D? Obviously I think D is an awesome language, but some frameworks/libraries hold me back, wish I could do everything in D. vibe.d compatible sqlite, postgresql, and oracle sql drivers. dub support in visualD/mono-d, better container libraries in the standard library(granted this is coming now that the allocator library is just about here). derelictGL has issues with AMD cards(issues that are AMD's fault granted) that has caused me to have to maintain a fork with a few things commented out. I would kill for golang channel like types supported in the standard library. other then some database support missing from vibe.d nothing really holds me back, just annoyances really.
Re: GC and MMM
On Thursday, 20 August 2015 at 17:13:33 UTC, Ilya Yaroshenko wrote: Hi All! Does GC scan manually allocated memory? I want to use huge manually allocated hash tables and I don't want to GC scan them because performance reasons. Best regards, Ilya Yes, just don't store any GC managed pointers in said manually allocated memory. Or at the very least consider any GC managed pointers to be weak pointers. core.memory add/remove range have to be used put c malloc memory into the GC, simply don't call these functions.
Re: Right after allocators: containers or database connectivity?
On Tuesday, 9 June 2015 at 17:05:19 UTC, Andrei Alexandrescu wrote: My work on allocators takes the last turn before the straight line. I've arranged with Dicebot to overlap the review period with finalizing details so I can act on feedback quickly. After that I'm ready for some major library work, and I had two things in mind. One would be a good pass of std.container, in particular (a) a design review with the DbI glasses on; (b) better documentation - sadly it seems to me so inadequate as to make containers themselves unusable; (c) investigate use of UFCS - std.container's design predates UFCS yet is a perfect fit for it, and most likely other cool language improvements we've added since. The other would be database connectivity. Erik Smith has shown some cool ideas at DConf, and I encourage him to continue working on them, but it seems to me this is an area where more angles mean more connectivity options. For database connectivity I'm thinking of using ODBC. What I see is that on all major platforms, vendors offer mature, good quality ODBC drivers, and most programs that have anything to do with databases offer ODBC connectivity. So connecting with ODBC means the individual database drivers are already there; no need to waste effort on creating drivers for each (or asking vendors to, which we can't afford). So I gave myself ten minutes the other night just before I went to sleep to see if I can get an ODBC rig on my OSX machine starting from absolutely nothing. I got http://www.odbcmanager.net but then got confused about where to find some dumb driver (text, csv) and gave up. Last night I gave myself another ten minutes, and lo and behold I got up and running. Got a demo CSV driver from http://www.actualtech.com/product_access.php (which also supports Access and others). Then I headed to http://www.easysoft.com/developer/languages/c/odbc_tutorial.html and was able to run a simple ODBC application that lists the available drivers. Nice! It's trivial work to convert the C headers to D declarations. Then it's straight library design to offer convenient libraries on top of the comprehensive but pedestrian ODBC C API. Then, voilà - we'll have database connectivity for all databases out there! Please help me choose what to work on next. Andrei I would think a good database lib would depend on a good container lib, So IMO, the order is self evident. 1000+ to containers.
Re: Use SIMD to accelerate comment lexing
On Monday, 1 June 2015 at 19:38:59 UTC, Walter Bright wrote: https://issues.dlang.org/show_bug.cgi?id=14641 Manu, our resident god of vector instructions, do you want to take this on? Looking at that code, I would think that some well placed prefetch and Non Temporal move intrinsic's, would do more good then anything else. CPU speculative read ahead is not so smart as one would think it otta be.
Re: D and GPGPU
On Friday, 20 February 2015 at 10:05:34 UTC, francesco.cattoglio wrote: On Wednesday, 18 February 2015 at 18:14:19 UTC, luminousone wrote: HSA does work with discrete gpu's and not just the embedded stuff, And I believe that HSA can be used to accelerate OpenCL 2.0, via copyless cache coherent memory access. Unless I'm mistaken, it will more like the opposite: HSA will use OpenCL 2.0 as a backend to do that kind of copyless GPGPU acceleration. HSAIL does not depend on opencl, and it supports more then copyless gpgpu acceleration, as it said, it has been access to virtual memory, including the program stack. HSA defines changes to the MMU, IOMMU, cpu cache coherency protocol, a new bytecode(HSAIL), a software stack built around llvm and its own backend in the gpu device driver. OpenCL 2.0, generally obtains its copyless accel from remapping the gpu memory into system memory, not from direct access to virtual memory, Intel supports a form of copyless accel via this remapping system. The major difference between the two systems, is that HSA can access any arbitrary location in memory, where as OpenCL must still rely on the pointers being mapped for use. HSA has for example have complete access to runtime type reflection, vtable pointers, you could have a linked list or a tree that is allocated arbitrarily in memory.
Re: D and GPGPU
On Wednesday, 18 February 2015 at 15:15:21 UTC, Russel Winder wrote: It strikes me that D really ought to be able to work with GPGPU – is there already something and I just failed to notice. This is data parallelism but of a slightly different sort to that in std.parallelism. std.concurrent, std.parallelism, std.gpgpu ought to be harmonious though. The issue is to create a GPGPU kernel (usually C code with bizarre data structures and calling conventions) set it running and then pipe data in and collect data out – currently very slow but the next generation of Intel chips will fix this (*). And then there is the OpenCL/CUDA debate. Personally I think OpenCL, for all it's deficiencies, as it is vendor neutral. CUDA binds you to NVIDIA. Anyway there is an NVIDIA back end for OpenCL. With a system like PyOpenCL, the infrastructure data and process handling is abstracted, but you still have to write the kernels in C. They really ought to do a Python DSL for that, but… So with D can we write D kernels and have them compiled and loaded using a combination of CTFE, D → C translation, C ompiler call, and other magic? Is this a GSoC 2015 type thing? (*) It will be interesting to see how NVIDIA responds to the tack Intel are taking on GPGPU and main memory access. https://github.com/HSAFoundation This is really the way to go, yea opencl and cuda exist, along with opengl/directx compute shaders, but pretty much every thing out their suffers from giant limitations. With HSA, HSAIL bytecode is embedded directly into the elf/exe file, HASIL bytecode can can fully support all the features of c++, virtual function lookups in code, access to the stack, cache coherent memory access, the same virtual memory view as the application it runs in, etc. HSA is implemented in the llvm backend compiler, and when it is used in a elf/exe file, their is a llvm based finalizer that generates gpu bytecode. More importantly, it should be very easy to implement in any llvm supported language once all of the patches are moved up stream to their respective libraries/toolsets. I believe that linux kernel 3.19 and above have the iommu 2.5 patches, and I think amd's radeon KFD driver made it into 3.20. HSA will also be supported by ARM. HSA is generic enough, that assuming Intel implements similar capabilities into their chips it otta be supportable their with or without intels direct blessing. HSA does work with discrete gpu's and not just the embedded stuff, And I believe that HSA can be used to accelerate OpenCL 2.0, via copyless cache coherent memory access.
Re: dmedia library
On Friday, 7 November 2014 at 07:32:53 UTC, Rikki Cattermole wrote: On 7/11/2014 8:22 p.m., luminousone wrote: On Friday, 7 November 2014 at 07:08:02 UTC, Rikki Cattermole wrote: On 7/11/2014 7:58 p.m., luminousone wrote: On Friday, 7 November 2014 at 06:42:24 UTC, Rikki Cattermole wrote: On 7/11/2014 7:38 p.m., luminousone wrote: On Friday, 7 November 2014 at 06:29:14 UTC, Rikki Cattermole wrote: On 7/11/2014 6:56 p.m., luminousone wrote: I have been working on a media library, it still has a long way to go, but I figured its about time I shared what I am doing. https://github.com/luminousone/dmedia If I could possibly convince a few people out their to give'er a once over. I use XCB/XLIB/GLX directly, so I am not just simply wrapping SDL or SFML. And I am using XCB for event handling and opening windows. Threading should work much more reliably, due to the use of XCB. I am releasing the library under the BSD license, Its a good start. But instead of creating the window itself manually would you consider using DWC [0]? DWC is more or less done. But I need help with my plans for a game dev framework in D. If you're interested in helping with that please give me an email fi...@lastname.co.nz [0] https://github.com/rikkimax/DWC XLIB is an absolute train wreck when it comes to threading, call XPollEvent outside your draw thread will most likely segfault. As well I need control of the opengl contexts, as I want to separate drawing and loading into separate threads. I need both good threading support, and control over my opengl contexts to fulfill the goals I have set for myself. That said, it is a nice looking library. But it would not fulfill my needs. Fair enough. Threading is a major issue with those low level api's. I eventually want to build a entity system, and make use of parallel_foreach, or fibers/routines, and have a loading thread that can get assets in an async fashion. Large voxel/cube-voxel systems and mega texturing interest me, I feel like a small team could develop a big game with tools built around a voxel system. XCB mostly solves the threading issues that XLIB suffers from, However XCB has poor support for the input extensions, as of yet nothing that replaces xlookupstring, I hope to find a good work around at some point, but it seems good enough for my needs. Also I am not sure of how well XXf86vm extension is supported for full screen access, As I have yet to implement full screen windows. Its a learning experience, however so I can't complain to much! Interesting, just out of interest have you thought about separating it out and work independently of GUI's for e.g. game servers? Or would that abstract it to the point of non-usefulness? Yes, tho I have yet to put much thought into how that will all be put together. Working towards something that I could use in vibe.d, without any dependence on the windowing system would be important for a good gameserver. Depending on the needs of the game server, I would keep it apart from the web server aspect from vibe.d all together. By in large interacting with e.g. a task, shouldn't be hard but that's not quite why. The idea behind my actor framework Dakka [0] (although would need a bit of work for this sort of thing). Share the data (including data models) between the web server and game server over sockets with method calling support. But keep its functions separate. Although the original context was all about having front end nodes for web development and backend nodes for interacting with e.g. VM's. But that's just me rambling with not much reason. [0] https://github.com/rikkimax/dakka dwc has been an interesting read, using the dub configurations option, and separate directories for the different platforms seems much cleaner then my approach with version statements. Your win32 code will be helpful when I get to that as well. Luckily win32 doesn't suffer the threading problems of xlib, nor does mac. I will drop an email later tonight after work, I am sure their are a few area's where we can save time by sharing code, in so far as a larger framework is concerned.
dmedia library
I have been working on a media library, it still has a long way to go, but I figured its about time I shared what I am doing. https://github.com/luminousone/dmedia If I could possibly convince a few people out their to give'er a once over. I use XCB/XLIB/GLX directly, so I am not just simply wrapping SDL or SFML. And I am using XCB for event handling and opening windows. Threading should work much more reliably, due to the use of XCB. I am releasing the library under the BSD license,
Re: dmedia library
On Friday, 7 November 2014 at 06:29:14 UTC, Rikki Cattermole wrote: On 7/11/2014 6:56 p.m., luminousone wrote: I have been working on a media library, it still has a long way to go, but I figured its about time I shared what I am doing. https://github.com/luminousone/dmedia If I could possibly convince a few people out their to give'er a once over. I use XCB/XLIB/GLX directly, so I am not just simply wrapping SDL or SFML. And I am using XCB for event handling and opening windows. Threading should work much more reliably, due to the use of XCB. I am releasing the library under the BSD license, Its a good start. But instead of creating the window itself manually would you consider using DWC [0]? DWC is more or less done. But I need help with my plans for a game dev framework in D. If you're interested in helping with that please give me an email fi...@lastname.co.nz [0] https://github.com/rikkimax/DWC XLIB is an absolute train wreck when it comes to threading, call XPollEvent outside your draw thread will most likely segfault. As well I need control of the opengl contexts, as I want to separate drawing and loading into separate threads. I need both good threading support, and control over my opengl contexts to fulfill the goals I have set for myself. That said, it is a nice looking library. But it would not fulfill my needs.
Re: dmedia library
On Friday, 7 November 2014 at 06:42:24 UTC, Rikki Cattermole wrote: On 7/11/2014 7:38 p.m., luminousone wrote: On Friday, 7 November 2014 at 06:29:14 UTC, Rikki Cattermole wrote: On 7/11/2014 6:56 p.m., luminousone wrote: I have been working on a media library, it still has a long way to go, but I figured its about time I shared what I am doing. https://github.com/luminousone/dmedia If I could possibly convince a few people out their to give'er a once over. I use XCB/XLIB/GLX directly, so I am not just simply wrapping SDL or SFML. And I am using XCB for event handling and opening windows. Threading should work much more reliably, due to the use of XCB. I am releasing the library under the BSD license, Its a good start. But instead of creating the window itself manually would you consider using DWC [0]? DWC is more or less done. But I need help with my plans for a game dev framework in D. If you're interested in helping with that please give me an email fi...@lastname.co.nz [0] https://github.com/rikkimax/DWC XLIB is an absolute train wreck when it comes to threading, call XPollEvent outside your draw thread will most likely segfault. As well I need control of the opengl contexts, as I want to separate drawing and loading into separate threads. I need both good threading support, and control over my opengl contexts to fulfill the goals I have set for myself. That said, it is a nice looking library. But it would not fulfill my needs. Fair enough. Threading is a major issue with those low level api's. I eventually want to build a entity system, and make use of parallel_foreach, or fibers/routines, and have a loading thread that can get assets in an async fashion. Large voxel/cube-voxel systems and mega texturing interest me, I feel like a small team could develop a big game with tools built around a voxel system. XCB mostly solves the threading issues that XLIB suffers from, However XCB has poor support for the input extensions, as of yet nothing that replaces xlookupstring, I hope to find a good work around at some point, but it seems good enough for my needs. Also I am not sure of how well XXf86vm extension is supported for full screen access, As I have yet to implement full screen windows. Its a learning experience, however so I can't complain to much!
Re: dmedia library
On Friday, 7 November 2014 at 07:08:02 UTC, Rikki Cattermole wrote: On 7/11/2014 7:58 p.m., luminousone wrote: On Friday, 7 November 2014 at 06:42:24 UTC, Rikki Cattermole wrote: On 7/11/2014 7:38 p.m., luminousone wrote: On Friday, 7 November 2014 at 06:29:14 UTC, Rikki Cattermole wrote: On 7/11/2014 6:56 p.m., luminousone wrote: I have been working on a media library, it still has a long way to go, but I figured its about time I shared what I am doing. https://github.com/luminousone/dmedia If I could possibly convince a few people out their to give'er a once over. I use XCB/XLIB/GLX directly, so I am not just simply wrapping SDL or SFML. And I am using XCB for event handling and opening windows. Threading should work much more reliably, due to the use of XCB. I am releasing the library under the BSD license, Its a good start. But instead of creating the window itself manually would you consider using DWC [0]? DWC is more or less done. But I need help with my plans for a game dev framework in D. If you're interested in helping with that please give me an email fi...@lastname.co.nz [0] https://github.com/rikkimax/DWC XLIB is an absolute train wreck when it comes to threading, call XPollEvent outside your draw thread will most likely segfault. As well I need control of the opengl contexts, as I want to separate drawing and loading into separate threads. I need both good threading support, and control over my opengl contexts to fulfill the goals I have set for myself. That said, it is a nice looking library. But it would not fulfill my needs. Fair enough. Threading is a major issue with those low level api's. I eventually want to build a entity system, and make use of parallel_foreach, or fibers/routines, and have a loading thread that can get assets in an async fashion. Large voxel/cube-voxel systems and mega texturing interest me, I feel like a small team could develop a big game with tools built around a voxel system. XCB mostly solves the threading issues that XLIB suffers from, However XCB has poor support for the input extensions, as of yet nothing that replaces xlookupstring, I hope to find a good work around at some point, but it seems good enough for my needs. Also I am not sure of how well XXf86vm extension is supported for full screen access, As I have yet to implement full screen windows. Its a learning experience, however so I can't complain to much! Interesting, just out of interest have you thought about separating it out and work independently of GUI's for e.g. game servers? Or would that abstract it to the point of non-usefulness? Yes, tho I have yet to put much thought into how that will all be put together. Working towards something that I could use in vibe.d, without any dependence on the windowing system would be important for a good gameserver.
Re: How to turn this C++ into D?
On Wednesday, 5 November 2014 at 18:18:18 UTC, Ali Çehreli wrote: On 11/05/2014 10:12 AM, Adam D. Ruppe wrote: On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli wrote: If so, then that push_back would be adding an incomplete object to the list. scope(success)? I really like that! :) But still not for this case because in addition to the problem with the destruction order, I would like to feel free to remove unused objects like the following without worrying about side-effects: // C++ code void bar() { Foo seemingly_unused_here(); // ... } Ali unless delete is explicitly called, I don't believe the destructor would ever be called, it would still have a reference in the static foo_list object that would stop it from being collected by the gc. I could see the constructor situation being a problem in threaded code as well, tho it may be bad practice, I don't believe the insert(this) would actually break anything. The scope(success) is a good idea either way however.
Re: How to turn this C++ into D?
On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicitly called, I don't believe the destructor would ever be called, it would still have a reference in the static foo_list object that would stop it from being collected by the gc. This is exactly why I asked about it, and even if delete is explicitly called-- which i believe is deprecated, wouldn't the runtime fill the space with the default construtor until the GC decides to remove it? meaning it would be immediatly added back into the list? I don't believe that the default constructor is called. I am pretty sure delete immediately deallocates the object, deregistering its memory from the gc. In fact I am 99% sure no constructor is called after delete, it would cause problems for objects with no default constructor, or for system related stuff done in constructors, and I haven't seen anything like that in my X11 work in d.
Re: How to turn this C++ into D?
On Wednesday, 5 November 2014 at 20:31:54 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 19:44:57 UTC, luminousone wrote: On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicitly called, I don't believe the destructor would ever be called, it would still have a reference in the static foo_list object that would stop it from being collected by the gc. This is exactly why I asked about it, and even if delete is explicitly called-- which i believe is deprecated, wouldn't the runtime fill the space with the default construtor until the GC decides to remove it? meaning it would be immediatly added back into the list? I don't believe that the default constructor is called. I am pretty sure delete immediately deallocates the object, deregistering its memory from the gc. In fact I am 99% sure no constructor is called after delete, it would cause problems for objects with no default constructor, or for system related stuff done in constructors, and I haven't seen anything like that in my X11 work in d. I guess I got confused by something... I don't know. But what I'd really like is for it to be garbage colleceted when no references outside of that static array exist, as i mentioned at the bottom of my first post. I illustrated my example with that specific class because when i looked up weak pointers on the site I found discussions getting caught up with how to avoid dangling pointers when weak pointers are used; and I wanted to illustrate that that's a non-issue in this case, because I wasn't sure how much that contributed to the solutions given. I suppose it doesn't matter because this is based on something I do with multiple inheritance in C++, I felt like I may be able to get it to work in D because the only public members of those classes were always pure virtual functions. As an aside, how does scope(success) work in the context of a constructor? given: abstract class foo { this() { scope(success) onAdd(); } ~this() { onRemove(); } onAdd(); onRemove(); } class bar : foo { int _a; this(int a) { _a = a; } void onAdd(){ writeln(_a); } void onRemove() { writeln(_a); } } is _a defined as anything in either of writes? or would it be called at the wrong time relative to setting _a? As of yet their are no built in weak references/pointers, you can jerry rig them however. constructors will implicitly call super at the top of the function if no super call is made within the function body, so this( int a ) { // super(); is called here if not defined below _a = a; } I'd really like is for it to be garbage colleceted when no references outside of that static array exist, as i mentioned at the bottom of my first post. Can't easily do this yet, would require you writing your own list class, as std.container, does not have any way of passing an allocator to it. They are coming, slowly but surely we will eventually have them. Allocators would allow container classes to create objects(nodes and such) that are in memory that is not scanned by the garbage collector. You can in fact allocate memory manually right now, via std.c.memory or std.c.stdlib (don't member which one has c malloc and free). Just be sure to familiarize your self with the manual gc registration and deregistration functions in core.memory.
Re: What are the worst parts of D?
On Sunday, 21 September 2014 at 22:17:59 UTC, H. S. Teoh via Digitalmars-d wrote: On Sun, Sep 21, 2014 at 08:49:38AM +, via Digitalmars-d wrote: On Sunday, 21 September 2014 at 00:07:36 UTC, Vladimir Panteleev wrote: On Saturday, 20 September 2014 at 12:39:23 UTC, Tofu Ninja wrote: What do you think are the worst parts of D? The regressions! https://issues.dlang.org/buglist.cgi?bug_severity=regressionlist_id=106988resolution=--- I filed over half of those... I guess you found them using your own code base? Maybe it would make sense to add one or more larger projects to the autotester, in addition to the unit tests. They don't necessarily need to be blocking, just a notice hey, your PR broke this and that project would surely be helpful to detect the breakages early on. This has been suggested before. The problem is resources. If you're willing to donate equipment for running these tests, it would be greatly appreciated, I believe. For my part, I regularly try compiling my own projects with git HEAD, and filing any regressions I find. T What is needed?
Re: critique of vibe.d
On Thursday, 10 July 2014 at 01:04:35 UTC, Sönke Ludwig wrote: Am 10.07.2014 02:58, schrieb Sönke Ludwig: Am 10.07.2014 02:30, schrieb luminousone: he links are clicked they simply don't do anything, the load function is not called. And it doesn't seem to throw any errors in chromes devel I'll test with Chrome. But the spec is the same in that regard for HTML 4: http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2 It even explicitly mentions escaping of quot; and #39; All of these work for the latest Chrome (as well as for Opera, Firefox and IE11): htmlbody a href=# onClick=alert(#39;Hello, World!#39;)Using amp;#39;/abr a href=# onClick=alert(quot;Hello, World!quot;)Using amp;quot;/abr a href=# onClick=alert('Hello, World!')Using '/abr a href=# onClick='alert(Hello, World!)'Using /abr /body/html Relooked over my code, and found issue else where, When I saw the html special characters seemed so out of place and figured that was it.
Re: critique of vibe.d
On Wednesday, 9 July 2014 at 15:21:40 UTC, Sönke Ludwig wrote: Am 09.07.2014 03:54, schrieb luminousone: There is lots of missing little bits here and their, password hashing functions that use crypt_(C) formated hashes. I was hoping for dauth [1] to fill that gap. It doesn't use the same format, but one with the same goal. I didn't actually try it out yet, though. There are diet/jade template bugs still, specific major problem being that use of single quotes inside of double quotes when i need to pass strings to js functions inside of js events such as onclick inside a html tag, seems to be broken. Do you have a concrete example where this goes wrong? I've tested both, nesting ' inside and vice versa. Both seemed to work fine for body onLoad= There is not common database interface for sql databases(forgivable actually), but many of the specific database libraries are messy(ddb for example) and they are not any where near api stable. Support for mongo is... cute?!, don't get me wrong it has a place, for most apps it would be fine, it is however unusable for the apps i am involved in. Yeah, I kind of like it for its flexibility, but it's definitely not the right choice for million user web services. I'm currently looking at NouDB as another potential SQL based target. [1]: http://code.dlang.org/packages/dauth I specifically work with data projects involving the EPA, Utah department of environmental quality, and county emissions programs in the State of Utah. We have a few legacy projects that sit in Oracle, And everything else sits in mysql and postgresql. We would like to get everything onto just postgresql, minus the projects we can't move out of Oracle. Our projects are spread across php/apache, and java/tomcat. I have been working to cut down the number of different technologies we use, or atleast to dump the really big train wreck ones aka, php and mysql. Now oddly enough because we are a center at a university, I can get away with what some might consider experimental, and use D and vibe.d, or at the very least whenever we have a one off demo of something I could use it for that. I have been using mongodb for a few personal projects as I wanted to learn it, I am using it from vibe.d. Our largest dataset is 1.5 million records per year going back to 1994~. Not terribly large but our clients run scientific queries on it. The queries they use pretty much preempts the use of non sql databases, so mongodb is out of the question, Tho I don't want to sound like I am being over discountive of what it can do. I will look into NouSQL, assuming its not a memory database like voltdb, or some of the other NewSQL databases, it might be suitable.
Re: critique of vibe.d
On Wednesday, 9 July 2014 at 15:21:40 UTC, Sönke Ludwig wrote: Am 09.07.2014 03:54, schrieb luminousone: There is lots of missing little bits here and their, password hashing functions that use crypt_(C) formated hashes. I was hoping for dauth [1] to fill that gap. It doesn't use the same format, but one with the same goal. I didn't actually try it out yet, though. There are diet/jade template bugs still, specific major problem being that use of single quotes inside of double quotes when i need to pass strings to js functions inside of js events such as onclick inside a html tag, seems to be broken. Do you have a concrete example where this goes wrong? I've tested both, nesting ' inside and vice versa. Both seemed to work fine for body onLoad= There is not common database interface for sql databases(forgivable actually), but many of the specific database libraries are messy(ddb for example) and they are not any where near api stable. Support for mongo is... cute?!, don't get me wrong it has a place, for most apps it would be fine, it is however unusable for the apps i am involved in. Yeah, I kind of like it for its flexibility, but it's definitely not the right choice for million user web services. I'm currently looking at NouDB as another potential SQL based target. [1]: http://code.dlang.org/packages/dauth hopefully, these posts are simply read as text, if not I can figure out something else. a.menu_item(href='#', onclick='load(invoice);') New Invoice a.menu_item(href='#', onclick=load('invoice');) New Invoice will always generate the following output, a href=# onclick=load(quot;aquot;); class=menu_itemNew Invoice/a a href=# onclick=load(#39;invoice#39;); class=menu_itemNew Invoice/a
Re: critique of vibe.d
On Wednesday, 9 July 2014 at 19:51:38 UTC, Sönke Ludwig wrote: Am 09.07.2014 21:21, schrieb luminousone: On Wednesday, 9 July 2014 at 15:21:40 UTC, Sönke Ludwig wrote: Am 09.07.2014 03:54, schrieb luminousone: There is lots of missing little bits here and their, password hashing functions that use crypt_(C) formated hashes. I was hoping for dauth [1] to fill that gap. It doesn't use the same format, but one with the same goal. I didn't actually try it out yet, though. There are diet/jade template bugs still, specific major problem being that use of single quotes inside of double quotes when i need to pass strings to js functions inside of js events such as onclick inside a html tag, seems to be broken. Do you have a concrete example where this goes wrong? I've tested both, nesting ' inside and vice versa. Both seemed to work fine for body onLoad= There is not common database interface for sql databases(forgivable actually), but many of the specific database libraries are messy(ddb for example) and they are not any where near api stable. Support for mongo is... cute?!, don't get me wrong it has a place, for most apps it would be fine, it is however unusable for the apps i am involved in. Yeah, I kind of like it for its flexibility, but it's definitely not the right choice for million user web services. I'm currently looking at NouDB as another potential SQL based target. [1]: http://code.dlang.org/packages/dauth hopefully, these posts are simply read as text, if not I can figure out something else. a.menu_item(href='#', onclick='load(invoice);') New Invoice a.menu_item(href='#', onclick=load('invoice');) New Invoice will always generate the following output, a href=# onclick=load(quot;aquot;); class=menu_itemNew Invoice/a a href=# onclick=load(#39;invoice#39;); class=menu_itemNew Invoice/a That's right, but as far as I understand, it *should* work like that, because HTML character entity replacement should happen before parsing the JavaScript code, even if it's a little more verbose than it should be. It breaks the js. And the character entity replacement only effects text between tags, with the exception of the script tag which also does not get characters replaced, the existing script. tag in diet templates works correctly. Text inside of attributes is not ran through the character entity replacement.
Re: critique of vibe.d
On Thursday, 10 July 2014 at 00:02:23 UTC, Sönke Ludwig wrote: Am 10.07.2014 01:27, schrieb luminousone: On Wednesday, 9 July 2014 at 19:51:38 UTC, Sönke Ludwig wrote: Am 09.07.2014 21:21, schrieb luminousone: On Wednesday, 9 July 2014 at 15:21:40 UTC, Sönke Ludwig wrote: Am 09.07.2014 03:54, schrieb luminousone: There is lots of missing little bits here and their, password hashing functions that use crypt_(C) formated hashes. I was hoping for dauth [1] to fill that gap. It doesn't use the same format, but one with the same goal. I didn't actually try it out yet, though. There are diet/jade template bugs still, specific major problem being that use of single quotes inside of double quotes when i need to pass strings to js functions inside of js events such as onclick inside a html tag, seems to be broken. Do you have a concrete example where this goes wrong? I've tested both, nesting ' inside and vice versa. Both seemed to work fine for body onLoad= There is not common database interface for sql databases(forgivable actually), but many of the specific database libraries are messy(ddb for example) and they are not any where near api stable. Support for mongo is... cute?!, don't get me wrong it has a place, for most apps it would be fine, it is however unusable for the apps i am involved in. Yeah, I kind of like it for its flexibility, but it's definitely not the right choice for million user web services. I'm currently looking at NouDB as another potential SQL based target. [1]: http://code.dlang.org/packages/dauth hopefully, these posts are simply read as text, if not I can figure out something else. a.menu_item(href='#', onclick='load(invoice);') New Invoice a.menu_item(href='#', onclick=load('invoice');) New Invoice will always generate the following output, a href=# onclick=load(quot;aquot;); class=menu_itemNew Invoice/a a href=# onclick=load(#39;invoice#39;); class=menu_itemNew Invoice/a That's right, but as far as I understand, it *should* work like that, because HTML character entity replacement should happen before parsing the JavaScript code, even if it's a little more verbose than it should be. It breaks the js. And the character entity replacement only effects text between tags, with the exception of the script tag which also does not get characters replaced, the existing script. tag in diet templates works correctly. Text inside of attributes is not ran through the character entity replacement. This is not true. See http://www.w3.org/html/wg/drafts/html/master/syntax.html#attributes-0 On which browser does it break the JS for you? It works for me, at least in Opera and Firefox. Chrome, When the links are clicked they simply don't do anything, the load function is not called. And it doesn't seem to throw any errors in chromes developer tools, which does seem odd. Your link is for the html 5.1 draft spec, might this be different dependent on the version of html being used?
Re: critique of vibe.d
On Tuesday, 8 July 2014 at 20:39:23 UTC, Andrei Alexandrescu wrote: There's been some discussion about vibe.d recently on reddit (e.g. http://www.reddit.com/r/programming/comments/2a20h5/wired_magazine_discovers_d/cir9443) and I was wondering to what extent that's meaningful: has anyone ever tied a real webservice to vibe.d? I actually tried. its nowhere near complete in any sense. you simply cannot compare it with go's standard http lib, sorry, I tried. If there's sheer work needed for completing vibe.d, I think it would be great if the domain-savvy part of the community would rally around it. Serving dlang.org and dconf.org off of vibe.d would be awesome dogfooding. Andrei There is lots of missing little bits here and their, password hashing functions that use crypt_(C) formated hashes. There are diet/jade template bugs still, specific major problem being that use of single quotes inside of double quotes when i need to pass strings to js functions inside of js events such as onclick inside a html tag, seems to be broken. There is not common database interface for sql databases(forgivable actually), but many of the specific database libraries are messy(ddb for example) and they are not any where near api stable. Support for mongo is... cute?!, don't get me wrong it has a place, for most apps it would be fine, it is however unusable for the apps i am involved in. Anything supported within vibe.d itself, is great, well thought out, well written, clean and easy to work with. And vibe.d makes wonderful use of D features in a productive way. vibe.d's documentation could be better. Having to go outside of vibe.d for anything is often gritty, and that is what keeps me from using it. The oddities of being required to use vibe.d's sockets means libraries have to be ported to the extend of changing that(not hard, but maintaining a changeset from the original authors code is cumbersome if they are not updating the lib, or if you would like to link it from another languages compiled code). That said if the database libraries could be brought up to snuff, one way or another everything else could be worked around for the most part.
Re: radical ideas about GC and ARC : need to be time driven?
On Sunday, 11 May 2014 at 17:36:44 UTC, Manu via Digitalmars-d wrote: On 12 May 2014 02:38, Marco Leise via Digitalmars-d digitalmars-d@puremagic.com wrote: Am Sun, 11 May 2014 14:52:50 +1000 schrieb Manu via Digitalmars-d digitalmars-d@puremagic.com: On 11 May 2014 05:39, H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: On Sat, May 10, 2014 at 09:16:54PM +0200, Xavier Bigand via Digitalmars-d wrote: - Same question if D migrate to ARC? I highly doubt D will migrate to ARC. ARC will probably become *possible*, but some language features fundamentally rely on the GC, and I can't see how that will ever be changed. Which ones are incompatible with ARC? Pass-by-value slices as 2 machine words 64bit pointers are only 40-48 bits, so there's 32bits waste for an offset... and if the base pointer is 32byte aligned (all allocated memory is aligned), then you can reclaim another 5 bits there... I think saving an arg register would probably be worth a shift. 32bit pointers... not so luck :/ video games consoles though have bugger all memory, so heaps of spare bits in the pointers! :P I thought x86_64 pointers are sign extended? or does that just apply to real memory pointers and not virtual memory pointers?
Re: super(...) in mixin template
On Tuesday, 4 March 2014 at 12:04:12 UTC, John Colvin wrote: On Tuesday, 4 March 2014 at 12:01:46 UTC, John Colvin wrote: On Tuesday, 4 March 2014 at 10:37:02 UTC, Steve Teale wrote: On Tuesday, 4 March 2014 at 07:23:29 UTC, Jacob Carlborg wrote: Perhaps you already figured this out but template mixins can only mixin declarations, not expression or statements. -- /Jacob Carlborg Damn! Yup, first sentence of the documentation. Wishful reading. Thanks. Steve You can of course mixin a function (either nested inside the constructor or as a member or even a free funtion) containing whatever you want and then call that. That won't help you with calling super() though, you can only call super from another constructor. You'd have to use a string mixin as that truly can inject arbitrary code. This opens a question: Should functions nested in constructors be given all the same powers that a constructor has (calling super, initializing const/immutable data etc)? http://d.puremagic.com/issues/show_bug.cgi?id=3332 I would bet you can't call super from a mixin.
Re: Top-3 for 2.066
http://d.puremagic.com/issues/show_bug.cgi?id=3332 This would be my request for 2.066
Re: Should LLVM become the default D-lang platform?
On Friday, 10 January 2014 at 20:51:19 UTC, Dwhatever wrote: This might have been brought up before but I couldn't find any thread about this. As things has progressed I wonder if Digital Mars DMD should move over to use LLVM instead of its own code generation and compiler framework. As I see it with the small amount of contributors D-language has, DMD will never support anything beyond x86 as there are no resources for this. Also, why spend time on recreating the the code generation which has already been done with LLVM? This enables this community to focus on the language which is the most important part as well as supporting more and future processor targets. LLVM is also the finalizer for HSAIL, AMD is using it for their linux port of C++AMP. But I would assume that ldc probably wouldn't have any issues generating HSA compatible code with minor modifications as is(as the LLVM backend will support it). I have no idea if GCC will support HSA or not however Microsoft is fully supporting it, as is ARM. So I wouldn't think that GCC would be to far behind on that one.
Re: Traits
On Saturday, 12 October 2013 at 05:38:16 UTC, Jonathan M Davis wrote: On Friday, October 11, 2013 22:31:25 Jonathan M Davis wrote: On Saturday, October 12, 2013 00:54:48 luminousone wrote: The inability to handle null is pretty big, specially considering that at not point is the class instance itself cared about!, No. It's expected. When you are casting to a particular object to test whether the object is of that type, you are testing the type that the object is, and if the object is null, then it is _not_ of the type that you're casting to. Again this should be done via reflection, this method above is hackish at best. Testing via compile-time reflection is testing for something fundamentally different than what casting is testing for. With casting, you're testing whether the object is the type that you're casting to or a type derived from the type that you're casting to. With compile-time reflection, you're testing whether a particular type is derived from another type. One is testing an instance. The other is testing a type. The two are completely different. I'd also point out that if you have class A { } class B : A { } B is _not_ an instance of A. It's a subclass of A. An instance is an object in memory, not the type of the object. auto a = new A; //instance of A auto b = new B; //instance of B A c = new B; //instance of B A d; //There is no instance here. The reference is null. B e; //There's no instance here either for the same reason. So, you're using the term instance of incorrectly. - Jonathan M Davis I was using the terminology used in prior posts, my point was to the original intent of the poster. And again, the casting solution is a bloody hack, it is loaded with corner cases that will break things if you are not aware of them. It also requires an allocated instance of that object, What the poster wishes to test for doesn't require that, so why have a function that needs it unnecessarily. It is bad practice. And I suppose in good faith of correcting bad practices, bool inheritsFrom(A, B)( ) if( is( A == class ) is( B == class ) ) { if( __traits( isSame, A, B ) ) return true; foreach( k, v ; BaseClassesTuple!A ) { if( __traits(isSame, B, v ) ) return true; } return false; }
Re: Traits
On Saturday, 12 October 2013 at 07:47:18 UTC, Jonathan M Davis wrote: On Saturday, October 12, 2013 09:32:09 luminousone wrote: And again, the casting solution is a bloody hack, it is loaded with corner cases that will break things if you are not aware of them. It also requires an allocated instance of that object Of course, it requires an instance of the object. The point is to test whether an instance is of a type derived from a particular type, not whether a particular type is derived from a particular type. If the OP wants to test whether a particular type is derived from another type, then casting is not the right solution. The way to do that is to use an is expression, e.g. is(Derived : Base). If you really care that the type is a derived type and want to avoid any other type of implicit conversions, then you need to use some compile time reflection to do that, but that's often overkill and completely kills the ability to create class which inherits via alias this, which is the main purpose for alias this existing in the first place. It is bad practice. It's standard practice. Both the online docs and TDPL will tell you to use a cast to determine whether a particular object's type is derived from a particular type. And I completely disagree that it's bad practice, but clearly we're not going to agree on that. - Jonathan M Davis 1. opCast, and alias can break the cast approach. You pointed this out yourself. 2. The requested function is testing types not instance state. bool instanceOf(A,B)( B value ) { assert( value !is null ); return inheritsFrom(A,typeof(value)); } 3. Cast breaks on null, so this must be checked on every call, and leads to a 3 state outcome, true, false, and null, null then returns false, which is potentially incorrect and could cause odd bugs hard to trace. Again it is bad practice regardless of what any document says.
Re: Traits
On Saturday, 12 October 2013 at 23:48:56 UTC, Artur Skawina wrote: On 10/12/13 21:42, luminousone wrote: On Saturday, 12 October 2013 at 11:50:05 UTC, Artur Skawina wrote: template isBaseOf(BASE, C) { enum isBaseOf = { static if (is(C S == super)) foreach (A; S) static if (is(A==BASE)) return true; return is(C==BASE); }(); } I like that! Avoids importing std.traits, And will correctly handle interfaces as well. It's also buggy. A more useful version would be: template isBaseOf(BASE, C) { enum isBaseOf = { static if (is(C S == super)) foreach (A; S) static if (isBaseOf!(BASE, A)) return true; return is(C==BASE); }(); } Sorry, didn't test this properly; going to blame the dlang is-expression docs. It's not like D has multiple inheritance, so using base classes (plural) is very misleading... artur yea is can be a lil confusing, especially that is( C S == super) expression. I take it that is( C S == super) is only the bases directly listed for inheritance by the class and not the bases bases as well? which is the reason for the change you made their? That expression is weird lol.
Re: Traits
On Friday, 11 October 2013 at 09:37:33 UTC, Jacob Carlborg wrote: On 2013-10-11 07:49, luminousone wrote: import std.traits; bool ChildInheritsFromParent( parent, child )( ) { foreach ( k, t; BaseClassesTuple!child ) { if( typeid(t) == typeid(parent) ) return true; } return false; } That will perform a runtime check and not a compile time check. Is is just the typeid call that makes it unable to be ran at compile time or is their something else wrong in their?, Would a string compare with type.classInfo.name fix that, or is their not a tool yet in place for that?
Re: Traits
On Friday, 11 October 2013 at 14:09:09 UTC, Gary Willoughby wrote: On Friday, 11 October 2013 at 05:49:38 UTC, luminousone wrote: On Friday, 11 October 2013 at 04:13:55 UTC, Agustin wrote: I have a function that needs to check if the template provided inherit a class. For example: public void function(T, A...)(auto ref A values) { // static assert(IsBaseOf(L, T)); } Check if T inherit class L. Same result that std::is_base_ofL, T::value using C++. Any clean way to do it, without a dirty hack. import std.traits; bool ChildInheritsFromParent( parent, child )( ) { foreach ( k, t; BaseClassesTuple!child ) { if( typeid(t) == typeid(parent) ) return true; } return false; } A simpler way: import std.stdio; bool instanceOf(A, B)(B value) { return !!cast(A)value; } void main() { assert(1.instanceOf!(int)); } Using casts that way won't always be correct, it would be better to use reflection in some way if possible.
Re: Traits
On Friday, 11 October 2013 at 19:54:39 UTC, Jonathan M Davis wrote: On Friday, October 11, 2013 21:19:29 luminousone wrote: Using casts that way won't always be correct, it would be better to use reflection in some way if possible. The only reason that the casts wouldn't be correct would be if the class overrode opCast for the type that you're casting to or had an alias this declaration for it. Using casting for instanceOf is considered the standard and correct way to do it. But if you're being paranoid about the possibility of a conversion being defined with opCast or alias this, then yes, you need to use typeid. - Jonathan M Davis import std.stdio; bool instanceOf(A, B)(B value) { return !!cast(A)value; } class e { } class f : e { } class g { } void main() { int a; float b; char c; e E; f F; g G; assert( 1.instanceOf!int, 1); assert( a.instanceOf!int, a); // fails here ?!? assert( b.instanceOf!int, b); assert( c.instanceOf!int, c); assert( E.instanceOf!e , e); // fails here !?? assert( F.instanceOf!e , f); assert( G.instanceOf!e , g); // fails as expected } Seems to be problems, at least with quick testing using rdmd. Using casts seems terribly hackish, I would think that some sort of reflection should be much safer/correct way todo this.
Re: Traits
On Friday, 11 October 2013 at 21:49:50 UTC, Jonathan M Davis wrote: On Friday, October 11, 2013 23:06:53 luminousone wrote: On Friday, 11 October 2013 at 19:54:39 UTC, Jonathan M Davis wrote: On Friday, October 11, 2013 21:19:29 luminousone wrote: Using casts that way won't always be correct, it would be better to use reflection in some way if possible. The only reason that the casts wouldn't be correct would be if the class overrode opCast for the type that you're casting to or had an alias this declaration for it. Using casting for instanceOf is considered the standard and correct way to do it. But if you're being paranoid about the possibility of a conversion being defined with opCast or alias this, then yes, you need to use typeid. - Jonathan M Davis import std.stdio; bool instanceOf(A, B)(B value) { return !!cast(A)value; } class e { } class f : e { } class g { } void main() { int a; float b; char c; e E; f F; g G; assert( 1.instanceOf!int, 1); assert( a.instanceOf!int, a); // fails here ?!? assert( b.instanceOf!int, b); assert( c.instanceOf!int, c); assert( E.instanceOf!e , e); // fails here !?? assert( F.instanceOf!e , f); assert( G.instanceOf!e , g); // fails as expected } Seems to be problems, at least with quick testing using rdmd. Using casts seems terribly hackish, I would think that some sort of reflection should be much safer/correct way todo this. Two things: 1. Casting to determine the type of a variable only makes sense with classes. The idea is that casting a reference to a particular class will result in null if the cast fails. That doesn't work at all with types that aren't classes. 2. All of your objects are null. Of course the cast is going to fail. You need to be operating on actual instances. The whole point of casting is to check the actual type of an object at runtime. It's a completely different use case from using compile-time reflection on two types to see whether one is a base class of the other. And usually all that's done for that is to see whether one implicitly converts to the other, which is(DerivedClass : BaseClass) will do for you. The only reason to use compile-time reflection is if you're want to make sure that DerivedClass doesn't implicitly convert to BaseClass via alias this instead of by actually being a class derived from BaseClass. I'd also change the implementation of instanceOf to something like bool instanceOf(A, B)(B value) if(is(A == class) is(B == class)) { return cast(A)value !is null; } since it doesn't rely on the conversion to bool that ! does and is more explicit that way, but the other version will work. - Jonathan M Davis The inability to handle null is pretty big, specially considering that at not point is the class instance itself cared about!, Again this should be done via reflection, this method above is hackish at best. perhaps, bool instanceOf(A, B)( ) if( is( A == class ) is( B == class ) ) { if( __traits( isSame, A, B ) ) return true; foreach( k, v ; BaseClassesTuple!A ) { if( __traits(isSame, B, v ) ) return true; } return false; }
Re: Traits
On Friday, 11 October 2013 at 04:13:55 UTC, Agustin wrote: I have a function that needs to check if the template provided inherit a class. For example: public void function(T, A...)(auto ref A values) { // static assert(IsBaseOf(L, T)); } Check if T inherit class L. Same result that std::is_base_ofL, T::value using C++. Any clean way to do it, without a dirty hack. import std.traits; bool ChildInheritsFromParent( parent, child )( ) { foreach ( k, t; BaseClassesTuple!child ) { if( typeid(t) == typeid(parent) ) return true; } return false; }
Re: Huge pages and druntime parameters
On Friday, 27 September 2013 at 00:31:23 UTC, Martin Nowak wrote: Running dmd with huge page backed malloc resulted in about 10% faster compilations. This looks very promising though other tests with some D GC microbenchmarks did not benefit from huge pages. You can read more about this here. http://www.ibm.com/developerworks/systems/library/es-lop-leveragepages/ I'm interested in adding a runtime parameter that would advise the GC to preferably use huge pages as backing memory. There are a number of other interesting runtime parameters, like max heap size, GC grow policies, turning on statistics, so I wonders how to make them available. Java seems to use -XX:+UseLargePages and -Xmx for the maximum heap size. GHC uses a nice scheme where runtime parameters passed via command line are embraced by +RTS arg1 arg2 -RTS. They also require to link-in support for this. http://www.haskell.org/ghc/docs/7.0.1/html/users_guide/runtime-control.html Any good ideas for druntime? I have played around with huge pages a bit, my understanding from reading about them, and use(ROAM diamond tree nodes in huge page memory), is that they need to be used carefully, many processors only have a small number of entries for huge pages in their lookup tables. The best use of huge pages seems to be from code built around them, not sure if it entirely makes sense to put them in gc,
Re: dub: should we make it the de jure package manager for D?
On Tuesday, 10 September 2013 at 20:48:58 UTC, Andrei Alexandrescu wrote: We've been experimenting with http://code.dlang.org for a while and things are going well. In particular Sönke has been very active about maintaining and improving it, which brings further confidence in the future of the project. We're considering making dub the official package manager for D. What do you all think? Andrei Not big on package repository systems for languages, The amount of crap that eventually accumulates from abandoned projects wears down on its usefulness. Examples being php-pear, php-pecl, python pypi, etc I am sure their are more examples. Mostly however it comes down to strong policy about what stays in the main package management system. Projects that haven't had an update for an excessive amount of time should likely be hidden but still available except in cases where it is known to be unchanged without need for updates(such as most wrappers). And license acknowledgement, this is much more important with source libraries then it is with say apt on Ubuntu. Accidentally polluting a bsd project or a closed source project with LGPL/GPL code would be very bad, And often these package management systems obscure what the sources license actually is by simply not showing it or informing the user. Basically I suggest that after one year without an update a package gets moved into a old packages list, or flagged as hidden, Except where the author sets a flag that says the package is a wrapper. And when packages are fetched give a summary of the licenses used, the license name should be enough, google can fill in the rest if need be.
Re: dub: should we make it the de jure package manager for D?
On Wednesday, 11 September 2013 at 00:18:27 UTC, Martin Nowak wrote: On 09/10/2013 10:48 PM, Andrei Alexandrescu wrote: We've been experimenting with http://code.dlang.org for a while and things are going well. In particular Sönke has been very active about maintaining and improving it, which brings further confidence in the future of the project. We're considering making dub the official package manager for D. What do you all think? Andrei I think the package format is really good. The registry is essential but needs to support categories, searching and some sort of quality ranking (voting?) for future grow. Dub itself works but is still somewhat raw. So I am for making dub's package format and the registry the official place for packages and supporting dub as the primary package manager. Old, python proverb, I found 10 packages in the repo but all 11 of them are broken, or conflict with another package I am using!
Re: dub: should we make it the de jure package manager for D?
On Wednesday, 11 September 2013 at 04:06:18 UTC, Jason den Dulk wrote: On Tuesday, 10 September 2013 at 20:48:58 UTC, Andrei Alexandrescu wrote: We're considering making dub the official package manager for D. What do you all think? I think it is a good idea. Having a broad library available for developers to use is a big boost to productivity. However, I agree with luminousone that there need to be some rules about inclusion in the registry. Here are my ideas. 1) Must be legal. 2) Must be release usable. 3) Always has an active caretaker. 4) Must compile and run with a reasonably recent version of the official compiler. 5) Have a clear precise descrption of what it does. 6) Have proper licensing. On number 4, I will point out that Derelicts opengl wrapper defines several win32 api structs and functions that are also in core.sys.windows.windows. Leaving me in the position of having to maintain a change set to the wrapper in order or use it. Don't get me wrong I love derelict, Aldacron has done one hell of a job with it. And this complaint may have more todo with the somewhat ambiguous status that the windowsapi wrapper and core.sys.windows.windows and very simply what import has what function or struct declaration, and the conflicts arising from multiple definitions etc. And I get it that the wrapper is more designed to work with derelicts sdl or sfml wrappers, But this is a point that should be brought up, their does exist libraries that will break when used with the standard library. I believe this would apply to point 2 and 4. Maybe we need to define some package names that are reserved for particular purposes, such as std, or core, or etc/etc.c/ etc... Atleast within the context of the package manager so that multiple packages don't use the same module name(unless of course this is done intentionally for some useful purpose).
Re: improve concurrent queue
On Tuesday, 27 August 2013 at 17:35:13 UTC, qznc wrote: On Monday, 26 August 2013 at 19:35:28 UTC, luminousone wrote: I have been working on a project and needed a good concurrent queue What does good mean? Concurrent queues have so many design parameters (single reader? single writer? blocking? bounded? etc) and there is no queue, which performs optimal for every case. Generally, multiple writers and a single reader, but multiple writers and multiple readers may also occur. I can recommand this paper (paywalled though): http://dl.acm.org/citation.cfm?id=248106 Nevertheless, I believe you rather wanted some comments on your specific code. I wonder why you implemented spinlocks yourself? If you write a blocking algorithm, you should probably use the phobos locks. I was under the impression that the atomic spinlock has a lower latency for any waiters, then a mutex when its unlocked? I am using this for a temporary or depending on performance, a perminate replacement for std.concurrency send/receive until such time as bugs in std.variant are fixed. I have a thread with an opengl context, and I am using the queue to send messages to this thread containing interface Drawable objects, that have any needed preprocessing on them done such that only opengl calls have to be made to the video card to render it.
improve concurrent queue
I have been working on a project and needed a good concurrent queue, so I wrote one, is their anyone more familiar with the atomic arts that could tell me if their is anyway i can further improve it. module container.concurrentqueue; import std.typetuple; import core.atomic; class ConcurrentQueue( items... ) { align(64) class nodeType { align(1): this( ) { atomicStore( this.next, cast(shared nodeType) null ); } this( TypeTuple!items value ) { foreach( k, v ; value ) { this.value[k] = v; } this(); } TypeTuple!items value; shared nodeType next; } class ConsumerResult { TypeTuple!items value; alias value this; } public this() { shared nodeType temp = cast(shared)new nodeType( ); atomicStore( first, temp ); atomicStore( last , temp ); atomicStore( producerLock, false ); atomicStore( consumerLock, false ); } public void Produce( items item ) { TypeTuple!items t = item; shared nodeType temp = cast(shared)new nodeType ( t ); while( !cas(producerLock, false, true ) ) { } atomicStore( last.next , temp ); atomicStore( last, temp ); atomicStore( producerLock, false ); } public ConsumerResult Consume( ) { while( !cas(consumerLock, false, true ) ) { } shared nodeType temp = cast(shared)atomicLoad( first ); shared nodeType next = cast(shared)atomicLoad( temp.next ); ConsumerResult result = new ConsumerResult(); if( next !is null ) { foreach( k, v ; items ) { result[k] = cast(v)next.value[k]; } first = next; atomicStore( consumerLock, false ); return result; } atomicStore( consumerLock, false ); return null; } private shared nodeType first; private byte padd1[64]; private shared nodeType last; private byte padd2[64]; private shared bool consumerLock; private byte padd3[64]; private shared bool producerLock; }
Re: Allocators
On Saturday, 24 August 2013 at 22:41:54 UTC, Kapps wrote: On Saturday, 24 August 2013 at 21:53:47 UTC, Andrej Mitrovic wrote: On 8/24/13, Namespace rswhi...@googlemail.com wrote: What about the probable change of virtual by default - final by default? Btw, can someone find the link to the forum thread where the last discussion of this took place? I remember Walter agreeing to something, but can't recall anymore. It seemed like eventually Walter supported virtual by default, but nothing came of it. For some reason I can't find the thread anymore with Google. Pretty sure Walter supported final by default, he even laid out a transition plan as I recall. Seems like Manu was involved, so asking him might bear fruit on that question.
Re: GPGPUs
On Sunday, 18 August 2013 at 05:05:48 UTC, Atash wrote: On Sunday, 18 August 2013 at 03:55:58 UTC, luminousone wrote: You do have limited Atomics, but you don't really have any sort of complex messages, or anything like that. I said 'point 11', not 'point 10'. You also dodged points 1 and 3... Intel doesn't have a dog in this race, so their is no way to know what they plan on doing if anything at all. http://software.intel.com/en-us/vcsource/tools/opencl-sdk http://www.intel.com/content/www/us/en/processors/xeon/xeon-phi-detail.html Just based on those, I'm pretty certain they 'have a dog in this race'. The dog happens to be running with MPI and OpenCL across a bridge made of PCIe. The Xeon Phi is interesting in so far as taking generic programming to a more parallel environment. However it has some serious limitations that will heavily damage its potential performance. AVX2 is completely the wrong path to go about improving performance in parallel computing, The SIMD nature of this instruction set means that scalar operations, or even just not being able to fill the giant 256/512bit register wastes huge chunks of this things peak theoretical performance, and if any rules apply to instruction pairing on this multi issue pipeline you have yet more potential for wasted cycles. I haven't seen anything about intels, micro thread scheduler, or how these chips handle mass context switching natural of micro threaded environments, These two items make a huge difference in performance, comparing radeon VLIW5/4 to radeon GCN is a good example, most of the performance benefit of GCN is from easy of scheduling scalar pipelines over more complex pipes with instruction pairing rules etc. Frankly Intel, has some cool stuff, but they have been caught with their pants down, they have depended on their large fab advantage to carry them over and got lazy. We likely are watching AMD64 all over again. The reason to point out HSA, is because it is really easy add support for, it is not a giant task like opencl would be. A few changes to the front end compiler is all that is needed, LLVM's backend does the rest. H'okay. I can accept that. OpenCL isn't just a library, it is a language extension, that is ran through a preprocessor that compiles the embedded __KERNEL and __DEVICE functions, into usable code, and then outputs .c/.cpp files for the c compiler to deal with. But all those extra bits are part of the computing *environment*. Is there something wrong with requiring the proper environment for an executable? A more objective question: which devices are you trying to target here? A first, simply a different way of approaching std.parallel like functionality, with an eye gpgpu in the future when easy integration solutions popup(such as HSA). Those are all platform specific, they change based on the whim and fancy of NVIDIA and AMD with each and every new chip released, The size and configuration of CUDA clusters, or compute clusters, or EU's, or whatever the hell x chip maker feels like using at the moment. Long term this will all be managed by the underlying support software in the video drivers, and operating system kernel. Putting any effort into this is a waste of time. Yes. And the only way to optimize around them is to *know them*, otherwise you're pinning the developer down the same way OpenMP does. Actually, even worse than the way OpenMP does - at least OpenMP lets you set some hints about how many threads you want. It would be best to wait for a more generic software platform, to find out how this is handled by the next generation of micro threading tools. The way openCL/CUDA work reminds me to much of someone setting up tomcat to have java code generate php that runs on their apache server, just because they can. I would rather tighter integration with the core language, then having a language in language. void example( aggregate in float a[] ; key , in float b[], out float c[]) { c[key] = a[key] + b[key]; } example(a,b,c); in the function declaration you can think of the aggregate basically having the reserve order of the items in a foreach statement. int a[100] = [ ... ]; int b[100]; foreach( v, k ; a ) { b = a[k]; } int a[100] = [ ... ]; int b[100]; void example2( aggregate in float A[] ; k, out float B[] ) { B[k] = A[k]; } example2(a,b); Contextually solid. Read my response to the next bit. I am pretty sure they are simply multiplying the index value by the unit size they desire to work on int a[100] = [ ... ]; int b[100]; void example3( aggregate in range r ; k, in float a[], float b[]){ b[k] = a[k]; b[k+1] = a[k+1]; } example3( 0 .. 50 , a,b); Then likely they are simply executing multiple __KERNEL functions in sequence, would be my guess. I've implemented this algorithm before in OpenCL already, and what you're saying so far doesn't rhyme with what's needed. There are at least
Re: GPGPUs
On Sunday, 18 August 2013 at 07:28:02 UTC, Atash wrote: On Sunday, 18 August 2013 at 06:22:30 UTC, luminousone wrote: The Xeon Phi is interesting in so far as taking generic programming to a more parallel environment. However it has some serious limitations that will heavily damage its potential performance. AVX2 is completely the wrong path to go about improving performance in parallel computing, The SIMD nature of this instruction set means that scalar operations, or even just not being able to fill the giant 256/512bit register wastes huge chunks of this things peak theoretical performance, and if any rules apply to instruction pairing on this multi issue pipeline you have yet more potential for wasted cycles. I haven't seen anything about intels, micro thread scheduler, or how these chips handle mass context switching natural of micro threaded environments, These two items make a huge difference in performance, comparing radeon VLIW5/4 to radeon GCN is a good example, most of the performance benefit of GCN is from easy of scheduling scalar pipelines over more complex pipes with instruction pairing rules etc. Frankly Intel, has some cool stuff, but they have been caught with their pants down, they have depended on their large fab advantage to carry them over and got lazy. We likely are watching AMD64 all over again. Well, I can't argue that one. A first, simply a different way of approaching std.parallel like functionality, with an eye gpgpu in the future when easy integration solutions popup(such as HSA). I can't argue with that either. It would be best to wait for a more generic software platform, to find out how this is handled by the next generation of micro threading tools. The way openCL/CUDA work reminds me to much of someone setting up tomcat to have java code generate php that runs on their apache server, just because they can. I would rather tighter integration with the core language, then having a language in language. Fair point. I have my own share of idyllic wants, so I can't argue with those. Low level optimization is a wonderful thing, But I almost wonder if this will always be something where in order todo the low level optimization you will be using the vendors provided platform for doing it, as no generic tool will be able to match the custom one. But OpenCL is by no means a 'custom tool'. CUDA, maybe, but OpenCL just doesn't fit the bill in my opinion. I can see it being possible in the future that it'd be considered 'low-level', but it's a fairly generic solution. A little hackneyed under your earlier metaphors, but still a generic, standard solution. I can agree with that. Most of my interaction with the gpu is via shader programs for Opengl, I have only lightly used CUDA for some image processing software, So I am certainly not the one to give in depth detail to optimization strategies. There was a *lot* of stuff that opened up when vendors dumped GPGPU out of Pandora's box. If you want to get a feel for some optimization strategies and what they require, check this site out: http://www.bealto.com/gpu-sorting_intro.html (and I hope I'm not insulting your intelligence here, if I am, I truly apologize). I am still learning and additional links to go over never hurt!, I am of the opinion that a good programmers has never finished learning new stuff. sorry on point 1, that was a typo, I meant 1. The range must be known prior to execution of a gpu code block. as for 3. Code blocks can only receive a single range, it can however be multidimensional int a[100] = [ ... ]; int b[100]; void example3( aggregate in range r ; k, in float a[], float b[]){ b[k] = a[k]; } example3( 0 .. 100 , a,b); This function would be executed 100 times. int a[10_000] = [ ... ]; int b[10_000]; void example3( aggregate in range r ; kx,aggregate in range r2 ; ky, in float a[], float b[]){ b[kx+(ky*100)] = a[kx+(ky*100)]; } example3( 0 .. 100 , 0 .. 100 , a,b); this function would be executed 10,000 times. the two aggregate ranges being treated as a single 2 dimensional range. Maybe a better description of the rule would be that multiple ranges are multiplicative, and functionally operate as a single range. OH. I think I was totally misunderstanding you earlier. The 'aggregate' is the range over the *problem space*, not the values being punched into the problem. Is this true or false? (if true I'm about to feel incredibly sheepish) Is problem space the correct industry term, I am self taught on much of this, so I on occasion I miss out on what the correct terminology for something is. But yes that is what i meant.
Re: GPGPUs
I chose the term aggregate, because it is the term used in the description of the foreach syntax. foreach( value, key ; aggregate ) aggregate being an array or range, it seems to fit as even when the aggregate is an array, as you still implicitly have a range being 0 .. array.length, and will have a key or index position created by the foreach in addition to the value. A wrapped function could very easily be similar to the intended initial outcome void example( ref float a[], float b[], float c[] ) { foreach( v, k ; a ) { a[k] = b[k] + c[k]; } } is functionally the same as void example( aggregate ref float a[] ; k, float b[], float c[] ) { a[k] = b[k] + c[k]; } maybe : would make more sense then ; but I am not sure as to the best way to represent that index value.
Re: GPGPU and D
On Sunday, 18 August 2013 at 08:40:33 UTC, Russel Winder wrote: Luminousone, Atash, John, Thanks for the email exchanges on this, there is a lot of good stuff in there that needs to be extracted from the mail threads and turned into a manifesto type document that can be used to drive getting a design and realization together. The question is what infrastructure would work for us to collaborate. Perhaps create a GitHub group and a repository to act as a shared filestore? I can certainly do that bit of admin and then try and start a document summarizing the email threads so far, if that is a good way forward on this. Github seems fine to me, my coding skills are likely more limited then Atash or John; I am currently working as a student programmer at Utah's Weber State University while also attending as a part time student, I am currently working on finishing the last couple credit hours of the assoc degree in CS, I would like to work towards a higher level degree or even eventually a Phd in CS. I will help in whatever way I can however.
Re: GPGPUs
On Saturday, 17 August 2013 at 06:09:53 UTC, Atash wrote: On Saturday, 17 August 2013 at 00:53:39 UTC, luminousone wrote: You can't mix cpu and gpu code, they must be separate. H'okay, let's be clear here. When you say 'mix CPU and GPU code', you mean you can't mix them physically in the compiled executable for all currently extant cases. They aren't the same. I agree with that. That said, this doesn't preclude having CUDA-like behavior where small functions could be written that don't violate the constraints of GPU code and simultaneously has semantics that could be executed on the CPU, and where such small functions are then allowed to be called from both CPU and GPU code. However this still has problems of the cpu having to generate CPU code from the contents of gpu{} code blocks, as the GPU is unable to allocate memory, so for example , gpu{ auto resultGPU = dot(c, cGPU); } likely either won't work, or generates an array allocation in cpu code before the gpu block is otherwise ran. I'm fine with an array allocation. I'd 'prolly have to do it anyway. Also how does that dot product function know the correct index range to run on?, are we assuming it knows based on the length of a?, while the syntax, c[] = a[] * b[]; is safe for this sort of call, a function is less safe todo this with, with function calls the range needs to be told to the function, and you would call this function without the gpu{} block as the function itself is marked. auto resultGPU = dot$(0 .. returnLesser(cGPU.length,dGPU.length))(cGPU, dGPU); 'Dat's a point. Remember with gpu's you don't send instructions, you send whole programs, and the whole program must finish before you can move onto the next cpu instruction. I disagree with the assumption that the CPU must wait for the GPU while the GPU is executing. Perhaps by default the behavior could be helpful for sequencing global memory in the GPU with CPU operations, but it's not a *necessary* behavior. Well, I disagree with the assumption assuming said assumption is being made and I'm not just misreading that bit. :-P === Another thing... I'm with luminousone's suggestion for some manner of function attribute, to the tune of several metric tonnes of chimes. Wind chimes. I'm supporting this suggestion with at least a metric tonne of wind chimes. I'd prefer this (and some small number of helpers) rather than straight-up dumping a new keyword and block type into the language. I really don't think D *needs* to have this any lower level than a library based solution, because it already has the tools to make it ridiculously more convenient than C/C++ (not necessarily as much as CUDA's totally separate program nvcc does, but a huge amount). ex. @kernel auto myFun(BufferT)(BufferT glbmem) { // brings in the kernel keywords and whatnot depending __FUNCTION__ // (because mixins eval where they're mixed in) mixin KernelDefs; // ^ and that's just about all the syntactic noise, the rest uses mixed-in // keywords and the glbmem object to define several expressions that // effectively record the operations to be performed into the return type // assignment into global memory recovers the expression type in the glbmem. glbmem[glbid] += 4; // This assigns the *expression* glbmem[glbid] to val. auto val = glbmem[glbid]; // Ignoring that this has a data race, this exemplifies recapturing the // expression 'val' (glbmem[glbid]) in glbmem[glbid+1]. glbmem[glbid+1] = val; return glbmem; /// I lied about the syntactic noise. This is the last bit. } Now if you want to, you can at runtime create an OpenCL-code string (for example) by passing a heavily metaprogrammed type in as BufferT. The call ends up looking like this: auto promisedFutureResult = Gpu.call!myFun(buffer); The kernel compilation (assuming OpenCL) is memoized, and the promisedFutureResult is some asynchronous object that implements concurrent programming's future (or something to that extent). For convenience, let's say that it blocks on any read other than some special poll/checking mechanism. The constraints imposed on the kernel functions is generalizable to even execute the code on the CPU, as the launching call ( Gpu.call!myFun(buffer) ) can, instead of using an expression-buffer, just pass a normal array in and have the proper result pop out given some interaction between the identifiers mixed in by KernelDefs and the launching caller (ex. using a loop). Alternatively to returning the captured expressions, the argument glbmem could have been passed ref, and the same sort of expression capturing could occur. Heck, more arguments could've been passed, too, this doesn't require there to be one single argument representing global memory. With CTFE, this method *I think* can also generate the code at compile time given the proper kind of expression-type-recording-BufferT. Again, though, all
Re: GPGPUs
On Saturday, 17 August 2013 at 20:17:17 UTC, Atash wrote: On Saturday, 17 August 2013 at 15:37:58 UTC, deadalnix wrote: Unified memory have too much benefice for it to be ignored. The open questions are about cache coherency, direct communication between chips, identical performances through the address space, and so on. But the unified memory will remains. Even when memory is physically separated, you'll see an unified memory model emerge, with disparate performances depending on address space. I'm not saying 'ignore it', I'm saying that it's not the least common denominator among popular devices, and that in all likelihood it won't be the least common denominator among compute devices ever. AMD/ATi being 'right' doesn't mean that they'll dominate the whole market. Having two slots on your mobo is more limiting than having the ability to just chuck more computers in a line hidden behind some thin wrapper around some code built to deal with non-uniform memory access. Additionally, in another post, I tried to demonstrate a way for it to target the least common denominator, and in my (obviously biased) opinion, it didn't look half bad. Unlike uniform memory access, non-uniform memory access will *always* be a thing. Uniform memory access is cool n'all, but it isn't popular enough to be here now, and it isn't like non-uniform memory access which has a long history of being here and looks like it has a permanent stay in computing. Pragmatism dictates to me here that any tool we want to be 'awesome', eliciting 'wowzers' from all the folk of the land, should target the widest variety of devices while still being pleasant to work with. *That* tells me that it is paramount to *not* brush off non-uniform access, and that because non-uniform access is the least common denominator, that should be what is targeted. On the other hand, if we want to start up some sort of thing where one lib handles the paradigm of uniform memory access in as convenient a way as possible, and another lib handles non-uniform memory access, that's fine too. Except that the first lib really would just be a specialization of the second alongside some more 'convenience'-functions. There are two major things, unified memory, and unified virtual address space. Unified virtual address will be universal within a few years, and the user space application will no longer manage the cpu/gpu copies anymore, this instead will be handled by the gpu system library, hMMU, and operating system. Even non-uniform memory will be uniform from the perspective of the application writer.
Re: GPGPUs
We basically have to follow these rules, 1. The range must be none prior to execution of a gpu code block 2. The range can not be changed during execution of a gpu code block 3. Code blocks can only receive a single range, it can however be multidimensional 4. index keys used in a code block are immutable 5. Code blocks can only use a single key(the gpu executes many instances in parallel each with their own unique key) 6. index's are always an unsigned integer type 7. openCL,CUDA have no access to global state 8. gpu code blocks can not allocate memory 9. gpu code blocks can not call cpu functions 10. atomics tho available on the gpu are many times slower then on the cpu 11. separate running instances of the same code block on the gpu can not have any interdependency on each other. Now if we are talking about HSA, or other similar setup, then a few of those rules don't apply or become fuzzy. HSA, does have limited access to global state, HSA can call cpu functions that are pure, and of course because in HSA the cpu and gpu share the same virtual address space most of memory is open for access. HSA also manages memory, via the hMMU, and their is no need for gpu memory management functions, as that is managed by the operating system and video card drivers. Basically, D would either need to opt out of legacy api's such as openCL, CUDA, etc, these are mostly tied to c/c++ anyway, and generally have ugly as sin syntax; or D would have go the route of a full and safe gpu subset of features. I don't think such a setup can be implemented as simply a library, as the GPU needs compiled source. If D where to implement gpgpu features, I would actually suggest starting by simply adding a microthreading function syntax, for example... void example( aggregate in float a[] ; key , in float b[], out float c[]) { c[key] = a[key] + b[key]; } By adding an aggregate keyword to the function, we can assume the range simply using the length of a[] without adding an extra set of brackets or something similar. This would make access to the gpu more generic, and more importantly, because llvm will support HSA, removes the needs for writing more complex support into dmd as openCL and CUDA would require, a few hints for the llvm backend would be enough to generate the dual bytecode ELF executables.
Re: GPGPUs
On Sunday, 18 August 2013 at 01:43:33 UTC, Atash wrote: Unified virtual address-space I can accept, fine. Ignoring that it is, in fact, in a totally different address-space where memory latency is *entirely different*, I'm far *far* more iffy about. We basically have to follow these rules, 1. The range must be none prior to execution of a gpu code block 2. The range can not be changed during execution of a gpu code block 3. Code blocks can only receive a single range, it can however be multidimensional 4. index keys used in a code block are immutable 5. Code blocks can only use a single key(the gpu executes many instances in parallel each with their own unique key) 6. index's are always an unsigned integer type 7. openCL,CUDA have no access to global state 8. gpu code blocks can not allocate memory 9. gpu code blocks can not call cpu functions 10. atomics tho available on the gpu are many times slower then on the cpu 11. separate running instances of the same code block on the gpu can not have any interdependency on each other. Please explain point 1 (specifically the use of the word 'none'), and why you added in point 3? Additionally, point 11 doesn't make any sense to me. There is research out there showing how to use cooperative warp-scans, for example, to have multiple work-items cooperate over some local block of memory and perform sorting in blocks. There are even tutorials out there for OpenCL and CUDA that shows how to do this, specifically to create better performing code. This statement is in direct contradiction with what exists. Now if we are talking about HSA, or other similar setup, then a few of those rules don't apply or become fuzzy. HSA, does have limited access to global state, HSA can call cpu functions that are pure, and of course because in HSA the cpu and gpu share the same virtual address space most of memory is open for access. HSA also manages memory, via the hMMU, and their is no need for gpu memory management functions, as that is managed by the operating system and video card drivers. Good for HSA. Now why are we latching onto this particular construction that, as far as I can tell, is missing the support of at least two highly relevant giants (Intel and NVidia)? Basically, D would either need to opt out of legacy api's such as openCL, CUDA, etc, these are mostly tied to c/c++ anyway, and generally have ugly as sin syntax; or D would have go the route of a full and safe gpu subset of features. Wrappers do a lot to change the appearance of a program. Raw OpenCL may look ugly, but so do BLAS and LAPACK routines. The use of wrappers and expression templates does a lot to clean up code (ex. look at the way Eigen 3 or any other linear algebra library does expression templates in C++; something D can do even better). I don't think such a setup can be implemented as simply a library, as the GPU needs compiled source. This doesn't make sense. Your claim is contingent on opting out of OpenCL or any other mechanism that provides for the application to carry abstract instructions which are then compiled on the fly. If you're okay with creating kernel code on the fly, this can be implemented as a library, beyond any reasonable doubt. If D where to implement gpgpu features, I would actually suggest starting by simply adding a microthreading function syntax, for example... void example( aggregate in float a[] ; key , in float b[], out float c[]) { c[key] = a[key] + b[key]; } By adding an aggregate keyword to the function, we can assume the range simply using the length of a[] without adding an extra set of brackets or something similar. This would make access to the gpu more generic, and more importantly, because llvm will support HSA, removes the needs for writing more complex support into dmd as openCL and CUDA would require, a few hints for the llvm backend would be enough to generate the dual bytecode ELF executables. 1) If you wanted to have that 'key' nonsense in there, I'm thinking you'd need to add several additional parameters: global size, group size, group count, and maybe group-local memory access (requires allowing multiple aggregates?). I mean, I get the gist of what you're saying, this isn't me pointing out a problem, just trying to get a clarification on it (maybe give 'key' some additional structure, or something). 2) ... I kind of like this idea. I disagree with how you led up to it, but I like the idea. 3) How do you envision *calling* microthreaded code? Just the usual syntax? 4) How would this handle working on subranges? ex. Let's say I'm coding up a radix sort using something like this: https://sites.google.com/site/duanemerrill/PplGpuSortingPreprint.pdf?attredirects=0 What's the high-level program organization with this syntax if we can only use one range at a time? How many work-items get fired off? What's the gpu-code launch procedure? sorry typo,
Re: GPGPUs
On Sunday, 18 August 2013 at 01:43:33 UTC, Atash wrote: Unified virtual address-space I can accept, fine. Ignoring that it is, in fact, in a totally different address-space where memory latency is *entirely different*, I'm far *far* more iffy about. We basically have to follow these rules, 1. The range must be none prior to execution of a gpu code block 2. The range can not be changed during execution of a gpu code block 3. Code blocks can only receive a single range, it can however be multidimensional 4. index keys used in a code block are immutable 5. Code blocks can only use a single key(the gpu executes many instances in parallel each with their own unique key) 6. index's are always an unsigned integer type 7. openCL,CUDA have no access to global state 8. gpu code blocks can not allocate memory 9. gpu code blocks can not call cpu functions 10. atomics tho available on the gpu are many times slower then on the cpu 11. separate running instances of the same code block on the gpu can not have any interdependency on each other. Please explain point 1 (specifically the use of the word 'none'), and why you added in point 3? Additionally, point 11 doesn't make any sense to me. There is research out there showing how to use cooperative warp-scans, for example, to have multiple work-items cooperate over some local block of memory and perform sorting in blocks. There are even tutorials out there for OpenCL and CUDA that shows how to do this, specifically to create better performing code. This statement is in direct contradiction with what exists. You do have limited Atomics, but you don't really have any sort of complex messages, or anything like that. Now if we are talking about HSA, or other similar setup, then a few of those rules don't apply or become fuzzy. HSA, does have limited access to global state, HSA can call cpu functions that are pure, and of course because in HSA the cpu and gpu share the same virtual address space most of memory is open for access. HSA also manages memory, via the hMMU, and their is no need for gpu memory management functions, as that is managed by the operating system and video card drivers. Good for HSA. Now why are we latching onto this particular construction that, as far as I can tell, is missing the support of at least two highly relevant giants (Intel and NVidia)? Intel doesn't have a dog in this race, so their is no way to know what they plan on doing if anything at all. The reason to point out HSA, is because it is really easy add support for, it is not a giant task like opencl would be. A few changes to the front end compiler is all that is needed, LLVM's backend does the rest. Basically, D would either need to opt out of legacy api's such as openCL, CUDA, etc, these are mostly tied to c/c++ anyway, and generally have ugly as sin syntax; or D would have go the route of a full and safe gpu subset of features. Wrappers do a lot to change the appearance of a program. Raw OpenCL may look ugly, but so do BLAS and LAPACK routines. The use of wrappers and expression templates does a lot to clean up code (ex. look at the way Eigen 3 or any other linear algebra library does expression templates in C++; something D can do even better). I don't think such a setup can be implemented as simply a library, as the GPU needs compiled source. This doesn't make sense. Your claim is contingent on opting out of OpenCL or any other mechanism that provides for the application to carry abstract instructions which are then compiled on the fly. If you're okay with creating kernel code on the fly, this can be implemented as a library, beyond any reasonable doubt. OpenCL isn't just a library, it is a language extension, that is ran through a preprocessor that compiles the embedded __KERNEL and __DEVICE functions, into usable code, and then outputs .c/.cpp files for the c compiler to deal with. If D where to implement gpgpu features, I would actually suggest starting by simply adding a microthreading function syntax, for example... void example( aggregate in float a[] ; key , in float b[], out float c[]) { c[key] = a[key] + b[key]; } By adding an aggregate keyword to the function, we can assume the range simply using the length of a[] without adding an extra set of brackets or something similar. This would make access to the gpu more generic, and more importantly, because llvm will support HSA, removes the needs for writing more complex support into dmd as openCL and CUDA would require, a few hints for the llvm backend would be enough to generate the dual bytecode ELF executables. 1) If you wanted to have that 'key' nonsense in there, I'm thinking you'd need to add several additional parameters: global size, group size, group count, and maybe group-local memory access (requires allowing multiple aggregates?). I mean, I get the gist of what you're saying, this isn't me pointing out a
Re: GPGPUs
The core (!) point here is that processor chips are rapidly becoming a collection of heterogeneous cores. Any programming language that assumes a single CPU or a collection of homogeneous CPUs has built-in obsolescence. So the question I am interested in is whether D is the language that can allow me to express in a single codebase a program in which parts will be executed on one or more GPGPUs and parts on multiple CPUs. D has support for the latter, std.parallelism and std.concurrency. I guess my question is whether people are interested in std.gpgpu (or some more sane name). CUDA, works as a preprocessor pass that generates c files from .cu extension files. In effect, to create a sensible environment for microthreaded programming, they extend the language. a basic CUDA function looking something like... __global__ void add( float * a, float * b, float * c) { int i = threadIdx.x; c[i] = a[i] + b[i]; } add 1, 10 ( ptrA, ptrB, ptrC ); Their is the buildin variables to handle the index location threadIdx.x in the above example, this is something generated by the thread scheduler in the video card/apu device. Generally calls to this setup has a very high latency, so using this for a small handful of items as in the above example makes no sense. In the above example that would end up using a single execution cluster, and leave you prey to the latency of the pcie bus, execution time, and latency costs of the video memory. it doesn't get effective until you are working with large data sets, that can take advantage of a massive number of threads where the latency problems would be secondary to the sheer calculations done. as far as D goes, we really only have one build in microthreading capable language construct, foreach. However I don't think a library extension similar to std.parallelism would work gpu based microthreading. foreach would need to have something to tell the compiler to generate gpu bytecode for the code block it uses, and would need instructions on when to use said code block based on dataset size. while it is completely possible to have very little change with function just add new property @microthreaded and the build in variables for the index position/s, the calling syntax would need changes to support a work range or multidimensional range of some sort. perhaps looking something like add$(1 .. 10)(ptrA,ptrB,ptrC); a templated function looking similar add!(float)$(1 .. 10)(ptrA,ptrB,ptrC);
Re: GPGPUs
On Friday, 16 August 2013 at 20:07:32 UTC, John Colvin wrote: We have a[] = b[] * c[] - 5; etc. which could work very neatly perhaps? While this in fact could work, given the nature of GPGPU it would not be very effective. In a non shared memory and non cache coherent setup, the entirety of all 3 arrays have to be copied into GPU memory, had that statement ran as gpu bytecode, and then copied back to complete the operation. GPGPU doesn't make sense on small code blocks, both in instruction count, and by how memory bound a particular statement would be. The compiler needs to either be explicitly told what can/should be ran as a GPU function, or have some intelligence about what to or not to run as a GPU function. This will get better in the future, APU's using the full HSA implementation will drastically reduce the buyin latency/cycle cost of using a GPGPU function, and make them more practical for smaller(in instruction count/memory boundess) operations.
Re: GPGPUs
On Friday, 16 August 2013 at 21:14:12 UTC, Atash wrote: Regarding functionality, @microthreaded is sounding a lot like the __kernel or __global__ keywords in OpenCL and CUDA. Is this intentional? The more metaphors that can be drawn between extant tools and whatever is come up with the better, methinks. Yes, And that is just a word I pull out the air, if another term makes more sense then I am not against it.
Re: GPGPUs
On Friday, 16 August 2013 at 23:30:12 UTC, John Colvin wrote: On Friday, 16 August 2013 at 22:11:41 UTC, luminousone wrote: On Friday, 16 August 2013 at 20:07:32 UTC, John Colvin wrote: We have a[] = b[] * c[] - 5; etc. which could work very neatly perhaps? While this in fact could work, given the nature of GPGPU it would not be very effective. In a non shared memory and non cache coherent setup, the entirety of all 3 arrays have to be copied into GPU memory, had that statement ran as gpu bytecode, and then copied back to complete the operation. GPGPU doesn't make sense on small code blocks, both in instruction count, and by how memory bound a particular statement would be. The compiler needs to either be explicitly told what can/should be ran as a GPU function, or have some intelligence about what to or not to run as a GPU function. This will get better in the future, APU's using the full HSA implementation will drastically reduce the buyin latency/cycle cost of using a GPGPU function, and make them more practical for smaller(in instruction count/memory boundess) operations. I didn't literally mean automatically inserting GPU code. I was more imagining this: void foo(T)(T[] arr) { useArray(arr); } auto a = someLongArray; auto b = someOtherLongArray; gpu { auto aGPU = toGPUMem(a); auto bGPU = toGPUMem(b); auto c = GPUArr(a.length); c[] = a[] * b[]; auto cCPU = toCPUMem(c); c.foo(); dot(c, iota(c.length).array().toGPUMem()) .foo(); } gpu T dot(T)(T[] a, T[] b) { //gpu dot product } with cpu arrays and gpu arrays identified separately in the type system. Automatic conversions could be possible, but of course that would allow carelessness. Obviously there is some cpu code mixed in with the gpu code there, which should be executed asynchronously if possible. You could also have onlyGPU { //only code that can all be executed on the GPU. } Just ideas off the top of my head. Definitely full of holes and I haven't really considered the detail :) You can't mix cpu and gpu code, they must be separate. auto a = someLongArray; auto b = someOtherLongArray; auto aGPU = toGPUMem(a); auto bGPU = toGPUMem(b); auto c = GPUArr(a.length); gpu { // this block is one gpu shader program c[] = a[] * b[]; } auto cCPU = toCPUMem(c); cCPU.foo(); auto cGPU = toGPUMem(cCPU); auto dGPU = iota(c.length).array().toGPUMem(); gpu{ // this block is another wholly separate shader program auto resultGPU = dot(cGPU, dGPU); } auto resultCPU = toCPUMem(resultGPU); resultCPU.foo(); gpu T dot(T)(T[] a, T[] b) { //gpu dot product } Your example rewritten to fit the gpu. However this still has problems of the cpu having to generate CPU code from the contents of gpu{} code blocks, as the GPU is unable to allocate memory, so for example , gpu{ auto resultGPU = dot(c, cGPU); } likely either won't work, or generates an array allocation in cpu code before the gpu block is otherwise ran. Also how does that dot product function know the correct index range to run on?, are we assuming it knows based on the length of a?, while the syntax, c[] = a[] * b[]; is safe for this sort of call, a function is less safe todo this with, with function calls the range needs to be told to the function, and you would call this function without the gpu{} block as the function itself is marked. auto resultGPU = dot$(0 .. returnLesser(cGPU.length,dGPU.length))(cGPU, dGPU); Remember with gpu's you don't send instructions, you send whole programs, and the whole program must finish before you can move onto the next cpu instruction.
Re: GPGPUs
On Tuesday, 13 August 2013 at 16:27:46 UTC, Russel Winder wrote: The era of GPGPUs for Bitcoin mining are now over, they moved to ASICs. The new market for GPGPUs is likely the banks, and other Big Data folk. True many of the banks are already doing some GPGPU usage, but it is not big as yet. But it is coming. Most of the banks are either reinforcing their JVM commitment, via Scala, or are re-architecting to C++ and Python. True there is some C#/F# but it is all for terminals not for strategic computing, and it is diminishing (despite what you might hear from .NET oriented training companies). Currently GPGPU tooling means C. OpenCL and CUDA (if you have to) are C API for C coding. There are some C++ bindings. There are interesting moves afoot with the JVM to enable access to GPGPU from Java, Scala, Groovy, etc. but this is years away, which is a longer timescale than the opportunity. Python's offerings, PyOpenCL and PyCUDA are basically ways of managing C coded kernels which rather misses the point. I may get involved in trying to write an expression language in Python to go with PyOpenCL so that kernels can be written in Python – a more ambitious version aimed at Groovy is also mooted. However, D has the opportunity of gaining a bridgehead if a combination of D, PyD, QtD and C++ gets to be seen as a viable solid platform for development. The analogue here is the way Java is giving way to Scala and Groovy, but in an evolutionary way as things all interwork. The opportunity is for D to be seen as the analogue of Scala on the JVM for the native code world: a language that interworks well with all the other players on the platform but provides more. The entry point would be if D had a way of creating GPGPU kernels that is better than the current C/C++ + tooling. This email is not a direct proposal to do work, just really an enquiry to see if there is any interest in this area. I suggest looking into HSA. http://developer.amd.com/wordpress/media/2012/10/hsa10.pdf This will be available on AMD APUs in December, and will trickle out to arm and other platforms over time.
Re: GPGPUs
On Tuesday, 13 August 2013 at 22:24:18 UTC, Nick B wrote: On Tuesday, 13 August 2013 at 18:35:28 UTC, luminousone wrote: On Tuesday, 13 August 2013 at 16:27:46 UTC, Russel Winder wrote: The era of GPGPUs for Bitcoin mining are now over, they moved to ASICs. http://developer.amd.com/wordpress/media/2012/10/hsa10.pdf This will be available on AMD APUs in December, and will trickle out to arm and other platforms over time. What a very interesting concept redesigned from the ground up. How about this for the future: D2 LLVM Compiler HSAIC Finaliser Architected Queueing Language Here is a another usefull link: http://developer.amd.com/resources/heterogeneous-computing/what-is-heterogeneous-system-architecture-hsa/ Nick And its not just AMD, HSA is supported by the HSA Foundation, with wide industry support. http://hsafoundation.com/ It is platform independent, at least in so far as it doesn't need x86 to operate, within a few years most ARM devices will support HSA. And HSAIL bytecode sits inside the ELF executable file next to the platform's bytecode, so compiling it in does not break any platform that does not support HSA. Memory isn't simply a shared architecture, its fully cache coherent, allows the GPU to use the same virtual address space as the CPU, On an APU platform you never need to copy data to and from GPU memory, simply pass a pointer and your done. HSAIL bytecode also is expressive enough for c++(including virtual functions) to compile directly to it, so no reason D can't. Some additions to D to handle micro threading, wouldn't go amiss however. The HSA finalizer AMD will be provided is supposed to use LLVM(at least that is my understanding). So changes required to support HSA would likely be minimal, most of these changes would be friendly to building in support for openCL or the like as well for none supported platforms.
deimos libx11 license
I finely got around to checking the libx11 deimos project for updates, i haven't updated in ages, and the github has a LGPL license file included with it, is this intentional?, The opengl deimos library does not contain this, are all of the deimos projects LGPL, or is their some sort of error in this repository containing this?
Re: deimos libx11 license
On Tuesday, 13 August 2013 at 05:03:10 UTC, Jonathan M Davis wrote: On Tuesday, August 13, 2013 05:53:50 luminousone wrote: I finely got around to checking the libx11 deimos project for updates, i haven't updated in ages, and the github has a LGPL license file included with it, is this intentional?, The opengl deimos library does not contain this, are all of the deimos projects LGPL, or is their some sort of error in this repository containing this? Deimos projects have no relation to each other beyond the fact that they're all in the same group on github. They're simply D bindings to a variety of unrelated libraries which were written in C. So, the license of one project has no bearing on the license of another. Given that they're bindings, I would expect them to have the same license as the original C code. In the case of flac, I outright copied the copyrights from the C code. It really doesn't make much sense IMHO to give the bindings a different license from the original. At best, you might be able to get away with marking them as Boost, but since you'd be using the original library to do anything, you'd still be restricted by its license. But I'm not a lawyer, so I don't know what all of the murky details are. It just seemed simplest to me to copy the copyrights over. As for the opengl deimos project, I don't know what its license is. It's probably listed in the copyright notices in the files. - Jonathan M Davis Their are other opengl wrappers with various licenses, I am actually more concered with the libx11 license, I need to be able to statically link without surrendering my code to the lgpl license. The original license of Xlib I am pretty sure is the x11 license, any idea who the maintainer of the libx11 deimos project is, such that I may query them, before I relagate myself to writting a new xlib wrapper? I ask purely because I think their might be an error, not because I am arguing the merits of the license, I just wanna be sure all my ducks are in a row so to speak!
Re: request switch statement with common block
perhaps a more generic solution should be looked at, extend contracts to work with all scope blocks. switch(somenumber) in { ... before stuff ... } out { after stuff ... } body { case 1: in { ... etc } out { ... more etc ... } body { ... } case 2: // and so on } or perhaps for( int i = 0 ; i 10 ; i ++ ) in { assert( i == 0 ); } out { assert( i == 9 ); } body { ... stuff ... } if it is desired for a particular contract block to be called in release builds perhaps a attribute label to mark it as a runtime block or something similar. foreach( i, k ; somerange ) @runtime in { ... } body { }
Re: request switch statement with common block
On Monday, 5 August 2013 at 20:45:47 UTC, Borislav Kosharov wrote: On Monday, 5 August 2013 at 19:58:21 UTC, ron wrote: On Monday, 5 August 2013 at 08:46:54 UTC, Andre Artus wrote: On Monday, 5 August 2013 at 06:28:12 UTC, luminousone wrote: perhaps a more generic solution should be looked at, extend contracts to work with all scope blocks. switch(somenumber) in { ... before stuff ... } out { after stuff ... } body { case 1: in { ... etc } out { ... more etc ... } body { ... } case 2: // and so on } or perhaps for( int i = 0 ; i 10 ; i ++ ) in { assert( i == 0 ); } out { assert( i == 9 ); } body { ... stuff ... } if it is desired for a particular contract block to be called in release builds perhaps a attribute label to mark it as a runtime block or something similar. foreach( i, k ; somerange ) @runtime in { ... } body { } Please do not take offense, but I do not see this as a good idea. Contracts have a very different function; not just in D, but every language that uses them. The idea is to support design-by-contract programming. Overloading the constructs for the purposes proposed here would, in my opinion, cause confusion and/or weaken the proper use of contract programming. The code in the contract conditions should never do anything more than what is necessary to specify the contract. It should not do explicit IO (other than implied by assert()), mutate state, or anything like that. At the bottom of this page you can find a reading list for more info. http://www.digitalmars.com/d/dbc.html Or for a general overview: http://en.wikipedia.org/wiki/Design_by_contract Walter, does the D compiler or any of it's companion tools do any static analysis on the contracts? Such as a void safety/null reference check? None taken, =-p. I don't see how this is different from current contract usage, right now they apply to function scopes only. currently I believe you could get a similar effect via using an inner function. void a() { int i = 0; void b() in { assert( i == 0 ); } out { assert( i == 10 ); } body { for( ; i 10 ; i ++ ) { ... do something ... } } b(); } Speaking of contracts, and reading the docs I see: Pre and Post Contracts The pre contracts specify the preconditions before a statement is executed. The most typical use of this would be in validating the parameters to a function. The post contracts validate the result of the statement. The most typical use of this would be in validating the return value of a function and of any side effects it has... So are contracts possible outside function declarations? For example just scopes or random places in code. I being zero is the precondition for that loop, and i being 10 is the post condition for that loop. Pretty much I think that any scope can potentially fit the definition for contracts. Really any block of code, can be considered to have pre and post conditions, functions just happen to be one way to organize code.
Re: request switch statement with common block
On Monday, 5 August 2013 at 21:48:46 UTC, Andre Artus wrote: On Monday, 5 August 2013 at 19:58:21 UTC, ron wrote: On Monday, 5 August 2013 at 08:46:54 UTC, Andre Artus wrote: On Monday, 5 August 2013 at 06:28:12 UTC, luminousone wrote: perhaps a more generic solution should be looked at, extend contracts to work with all scope blocks. switch(somenumber) in { ... before stuff ... } out { after stuff ... } body { case 1: in { ... etc } out { ... more etc ... } body { ... } case 2: // and so on } or perhaps for( int i = 0 ; i 10 ; i ++ ) in { assert( i == 0 ); } out { assert( i == 9 ); } body { ... stuff ... } if it is desired for a particular contract block to be called in release builds perhaps a attribute label to mark it as a runtime block or something similar. foreach( i, k ; somerange ) @runtime in { ... } body { } Please do not take offense, but I do not see this as a good idea. Contracts have a very different function; not just in D, but every language that uses them. The idea is to support design-by-contract programming. Overloading the constructs for the purposes proposed here would, in my opinion, cause confusion and/or weaken the proper use of contract programming. The code in the contract conditions should never do anything more than what is necessary to specify the contract. It should not do explicit IO (other than implied by assert()), mutate state, or anything like that. At the bottom of this page you can find a reading list for more info. http://www.digitalmars.com/d/dbc.html Or for a general overview: http://en.wikipedia.org/wiki/Design_by_contract Walter, does the D compiler or any of it's companion tools do any static analysis on the contracts? Such as a void safety/null reference check? None taken, =-p. I don't see how this is different from current contract usage, right now they apply to function scopes only. currently I believe you could get a similar effect via using an inner function. void a() { int i = 0; void b() in { assert( i == 0 ); } out { assert( i == 10 ); } body { for( ; i 10 ; i ++ ) { ... do something ... } } b(); } I could be missing something, if so please clarify. The construct I have issue with is this one, switch(somenumber) in { ... before stuff ... } out { after stuff ... } I would contend that code within in/out/invariant blocks should be 'pure' (no state changes, no IO [other than assert throwing]), it's only there to validate that a class and it's methods do not violate certain conditions. They should be able to be stripped out of the release build without altering the execution of the application in any way. A classic example is the null dereference check, which some compilers and most (all?) static analysers can detect. string whoIsAMonkey(Person p) in { assert(p !is null, Person can not be null); assert(!isNullOrEmpty(p.Name), Person name can not be null or empty); } body { return p.Name ~ is a monkey!; } void main() { Person p = null; // Compiler / analyser should complain with // Person can not be null writeln(whoIsAMonkey(p)); // ^ here } void main() { Person p = new Person(); // Compiler / analyser should complain with // Person name can not be null or empty writeln(whoIsAMonkey(p)); } etc. Contracts are meant to define the public (*) interface of a class. * By public I mean here anything not 'private', e.g. 'protected' for inheritance. As Andrei points out in his book (The D Programming Language) contracts are not used to validate/scrub user (or any external) input as they can be compiled out of the executable. Contracts are there to check sanity at compile time, or at the very least during testing. The contract is (or should be) part of the documentation. You are correct. I will have to check out his book.
Re: D game development: a call to action
On Monday, 5 August 2013 at 18:18:30 UTC, Jonathan A Dunlap wrote: I am one of the few who have taken a keen interest in D for game development. The concise language and modern conveniences may be able to reduce many hours worth of development time off a game project, while making the code more maintainable. Aside from the core language, Dlang graphics bindings have a way to go before even earning acceptance in the indie gaming scene, but it's making great strides to get there. The main challenge I've hit is the lack of any sort of path for adopting a media engine. Bindings (like SFML https://github.com/krzat/SFML-D) all suffer from: A) No information about its current status: this is scary if its repo hasn't been updated in months. B) Usually are complex to get working in a new project (manually building or searching for undocumented dependency DLLs) C) Lack practical references and tutorials for real would usage e.g. how to create an OpenGL window or how to render a triangle versus something like how to load from disk an image texture onto a quad and move it around using keyboard events SFML bindings are also in https://github.com/aldacron/Derelict3 but I couldn't find a scrap of information on how to use it, how to compile correctly, or example usage. It's unclear if the library is even usable in its current state. Please don't take this as blind criticism, but rather a plea to action for the community to provide better library documentation support for: current lib status, getting started adding it, and a general use tutorial/example. If we start doing this, it'll make a big impact for other game developers who are new to Dlang to adopt the language. Thanks for listening! I am working on a media/gaming library for D, its not even pre alpha, and I am learning parts of the language as I go so the code is very ugly, and the naming conventions are scatter brained. However I don't use any wrappers of other media libraries such as sfml, I only have the minimal bindings required to link with X11 and opengl(I do plan on windows bindings as well, but i haven't done that yet). At the moment I am tackling concurrency, That bit is giving me endless headaches, I am trying to setup a seperate thread to handle opengl calls and a seperate thread for handling object updates. https://github.com/luminousone/dmedia I haven't picked a license yet, but it will be something that is rather open but leaves me the option to staticly link it in closed projects. I still think you might find a few interesting bits in that link, but it does have a while to go before it is remotely useable. I am open to working with others, or making changes to what I have done if anyone is interested.