SIMD library attempt inf

The Partridge Family were neither partridges nor a family. Discuss.
Slidy
Posts: 80
Joined: September 9th, 2017, 1:19 pm

Re: SIMD library attempt inf

Post by Slidy » October 4th, 2020, 8:01 am

albinopapa wrote:
October 2nd, 2020, 12:08 am
Found some resources for helping learn how to compile my own language, but does anyone else have troubles translating example code to your own code?
Experienced that a lot with rastertek.

For making your own language, can highly recommend https://craftinginterpreters.com/

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: SIMD library attempt inf

Post by albinopapa » October 5th, 2020, 3:42 am

Experienced that a lot with rastertek
Yeah, I seriously have my nitpicks with rastertek, but still found them useful for what I needed from them. DirectXTutorials.com made a lot more sense to me. The descriptions were more clear and the code was a lot cleaner.

With rastertek I saw something that looked like C with classes code and got hung up on that in the beginning so much so that I couldn't concentrate. What I got from rastertek was examples about D3D initialization and usage, but the part I couldn't and still can't figure out is the structure of the code and how to turn that into a modular framework for a game. That's where things broke down for me. I can still use it as reference material for setting up a raster state or creating a texture, but that's as far as it goes for me.

I tried taking their code and modernizing it using smart pointers and properly using constructors/destructors and exceptions...I've tried this 3-4 times and never got it to work, there was always something wrong in one place or another. That is how fragile their code is in my experience. Perhaps as I've gained more knowledge about C++ and DX in general I could do it.

Thanks for the material, I'll definitely look it over. I think right now procedurally generating the AST is where I'm getting stuck. I can follow examples and understand-ish the process of walking the tree to interpret one code form to another, but building the tree is going to take a bit. Also, with the exception of constants ( ex: 7+4 ) I haven't figured that part out either...so hopefully that link will provide a little more insight.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: SIMD library attempt inf

Post by albinopapa » October 6th, 2020, 8:58 pm

Holy cow, never would have come up with like 70% of this stuff.

Thank you so much Slidy, this tutorial is exactly what I needed.

The biggest issues I had prior was going from Lexer to syntax tree. I have found other resource that helped a little in the way of walking and either printing or evaluating a tree, but producing the tree was a little beyond me. I'm gaining confidence though that I'll actually be able to pull this off...here's hoping.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: SIMD library attempt inf

Post by albinopapa » October 11th, 2020, 9:20 am

I'm on chapter 24 of that book, so much to keep track of. This may take a really long time to take it all in lol. I tried translating the java version to c++, but ran into some difficulty when doing blocks. In the book, it seems Java can change an overridden function's signature. All other statement functions up until this point return a single object while the block statement returns a Java List<T>. Seeing as how this is an inherited function requiring a single object, I just skipped to to the C byte code compiler section.

Either way, very useful information and tutorial. It's got me really wanting to finish to see how far I can take it. Anyway, thanks again Slidy.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: SIMD library attempt inf

Post by albinopapa » October 22nd, 2020, 3:54 am

Well, I've completed the book, but somewhere along the way I mistranslated the C code. I get stuck in an infinite loop and haven't found where yet.

Going through a rough patch right now, so not very motivated to do much coding. I have a few ideas about what I want to do, but they will have to wait until my son and I get back on our feet. Plus of course, the holidays are right around the corner and I always seem to be unavailable during the next two months anyway. I'll be around, just not very active.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: SIMD library attempt inf

Post by albinopapa » November 25th, 2020, 9:13 am

Over a month since making the last post and not much has changed. I'm still packing and getting ready to move. A month seems like a long time to pack, but I still have two weeks before I can even move in to my new place, so I've been taking my time. Then there is the process of cleaning up the house and getting it ready to sell, this ought to be fun as it's my first time selling a house.

Anyway, as far as coding goes I'm still apprehensive on continuing my previous projects. I can't seem to devote much time and energy into them right now or I'll get nothing done around here. There seems to be a lot of visits to this thread, so I'll definitely keep that in mind when I do get back to it.

Below are going to be some notes for me to consider when that time comes. Hopefully, they will be of use to others when that time comes.
  • Finish fixing up the tutorial code
  • Look for ways to optimize
  • Test OOP: The tutorial uses a fair bit of casting to handle the different commands and data payload, I'd like to use std::variant.
  • If I understand enough of the process, then perhaps a small tutorial.
  • Prune what I don't need for what my original intentions were, the SIMD shader.
The tutorial linked uses a fair bit of casting and dynamic memory allocation, so I'd like to convert it to use std::variant. One reason is no dynamic memory allocation, another is concrete types so no if/else if/else or switch/case branches. As far as I can tell, Microsoft's implementation already uses a switch block to branch to a specific function or to determine what the active object is, so it isn't 100% static dispatch. I think it'd clean up the code a bit as well, and if I do actually make a small tutorial on it, this is what will be included.

I thought over some things regarding the SIMD shader, and I'm not entirely sure what the end result is going to be. For instance, each version of SIMD ( SSE, AVX/2, AVX512 ) has different size and alignment requirements as well as different processor and operating system support.

The hardware and software support I don't see being an issue. I found a bit of code I copied from stackoverflow for that part. The issue is going to be data layout, alignment and register widths.

I want to have mathematical vectors like Vec2/3/4 available as intrinsic types. Now, if I keep them as AoS which is easiest to program in, I have to worry about a Vec2 only taking up two slots of say an 8 slot SIMD register or going past memory boundaries. However, I could convert the data into SoA format when the user creates a buffer. It would be difficult to convert between AoS -> SoA and then back, but with templates or some kind of runtime description I think it'd be possible.

The compilation would be done when you pass in the shader script. The return of that, assuming a successful compilation would be a simd_shader object that stores an std::vector<std::variant<...>> where the ... would be a list of supported commands.

Seeing as SIMD is all math based, I wouldn't need support for functions nor structures, though I think structures would be useful. Another useful feature which is included in the tutorial is first class functions..ie lambdas, so I'll probably keep those in as well.

As a final note to myself, I thought it'd be fun to create a type of software emulated arcade machine or console. Of course, it'd wouldn't be very powerful, but who knows it could turn out some rather interesting programs. I watched a few YT videos about the 6502 processor that was in the original Nintendo and Commodore 64, with all it's limitations and how creative programmers had to be and it kind of inspired the idea.

END OF NOTES
Another big change may be that I actually may have to get a job. Seeing as I don't have much in the way of formal education and with my visual impairment it'll just be a menial one at best. Basically, I won't have a lot of time if that happens, so things are going to be slowed by that as well, but we'll see. Anyway, for those in America, happy Thanksgiving, Merry Christmas and have a happy New Year.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply