I'm rendering a particle system using Metal on iOS device. I'm constrained to use Normal shaders instead of compute functions. So I'm using MTLPrimitiveTypePoint for drawing particles.
While following one of the Open GL code for reference, I found that you can query the maximum point size using:
float pointSizeRange[2];
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE,pointSizeRange);
Now how can I get the same information in Metal? I'm assuming this is HW/System dependant hence we need to query it and keep point size constrained under that limit. Unfortunately, I was not able find Metal any API around this.
But I found this Doc, which says
Maximum size of a point primitive = 54 (For all apple devices)
Now this says it's the the same for older iPhones (6s/7) and for MacBooks(M1s) too? Why? Are there any optimization benefits or just H/W limitations?
I came accross an option in the Delphi 6 IDE:
How does changing the memory stack sizes here affect the IDE? If I increase this value would there be more memory available for the IDE?
No, stack size does not influence on IDE work.
This is linker option, it defines how much stack size will be available for your compiled program. At most max stack size.
Stack is used to hold local variables and sometimes function arguments. You seldom need to increase stack sizes if application design is quite good. Stack overflow (if happens) might be a result of unlimited recursion due to logical mistakes or result of defining too large local variables (for example - static arrays)
P.S. What problem are you going to solve?
Write a stack class that can return the size of the stack in constant time.
The problem statement and solution is a little unclear for me. What if I have a variable that keeps track of the size. But this solution seems too easy and not related to stack. Can someone help?
If you want to protect against stack underflow you probably already have a second pointer to the bottom/start of the stack. You can then calculate the difference between the two pointers.
That is practically equivalent to the explicit size counter you find too easy, though.
The title pretty much says it. I am writing an algorithm (and right now porting it into nasm) that would need to allocate lots (upwards of 8gb) of ram (as a severe tradeoff for cpu usage). On every iteration it stores an int onto the stack (for output and later usage). Then, periodically it could free a set of values but only from the bottom of the stack. Could this be done by simply decrementing the stack base (rbp)?
A stack is a stack. You can push and pop values on the top but nothing more. You cannot deallocate anything from it in any other way.
Changing RBP doesn't do anything, it is just a helper register to use for the current stack frame. RSP shows the current top of the stack and moving that changes where the next value will be stored to or retrieved from within the stack. So you can drop a bunch of values from the top if needed, but not from the bottom.
If you have a need to temporarily store values and later release them then a circular buffer or blocks of regular memory would be a much better suited for that.
Some systems such as Symbian insist people to use heap instead of stack when allocating
big objects(such as pathnames, which may be more than 512 bytes). Is there any specific reason for this?
Generally the stack on an embedded device is fixed to be quite small i.e. 8K is the default stack size on Symbian.
If you consider a maximum length filename is 256bytes, but double that for unicode that's 512bytes already (1/16th of your whole stack) just for 1 filename. So you can imagine that it is quite easy to use up the stack if you're not careful.
Most Symbian devices do come with an MMU, but, until very recently, do not support paging. This means that physical RAM is committed for every running process. Each thread on Symbian has (usually) a fixed 8KB stack. If each thread has a stack, then increasing the size of this stack from 8KB to, say 32KB, would have a large impact on the memory requirements of the device.
The heap is global. Increasing its size, if you need to do so, has far less impact. So, on Symbian, the stack is for small data items only - allocate larger ones from the heap.
Embedded devices often have a fixed-sized stack. Since a subroutine call in C only needs to push a few words onto the stack, a few hundred byte may suffice (if you avoid recursive function calls).
Most embedded devices doesn't come with a memory management unit so there is no way for the OS to grow the stack space automatically, transparent to the programmer. Even assuming a growable stack, you will have to manage it yourself which is no better than heap allocation and defeats the purpose of using a stack in the first place.
The stack for embedded devices usually resides in a very small amount of high-speed memory. If you allocate large objects on the stack on such a device, you might be facing a stack overflow.