S
Skybuck Flying
Hello,
I need the following code to work:
var
Memory : pointer;
Block : dynamic pointer;
Element : dynamic pointer;
BlockIndex : integer;
ElementIndex : integer;
begin
ElementCount := 8000;
ElementSize := 4;
BlockCount := 1000;
BlockSize := ElementCount * ElementSize;
GetMem( Memory, BlockCount * BlockSize );
Block( Memory, BlockSize );
Element( nil, ElementSize );
Block[ BlockIndex ] : Element[ ElementIndex ] := 1000;
Block[ 500 ] : Element[ 1000 ] := Block[ 300 ] : Element[ 2000 ];
end;
What the following code does is:
Block( Memory, BlockSize );
initializes the block dynamic pointer to have a base address of memory and a
stride of block size.
What the following code does is:
Element( nil, ElementSize );
Initialize the element dynamic pointer to have a base address of nil and a
stride of element size.
What the following code does is:
Block[ BlockIndex ] : Element[ ElementIndex ] := 1000;
BlockPointer := BlockBase + BlockIndex * BlockSize;
: indicates the block pointer is to be passed on as the base for element:
ElementBase := BlockPointer;
ElementPointer := ElementBase + ElementIndex * ElementSize;
ElementPointer^ := 1000;
Additional the compiler is capable of recgonizing different indexing pairs:
Block[ 500 ] : Element[ 1000 ] := Block[ 300 ] : Element[ 2000 ];
Invokes the code above twice for the first and the second pair.
And does:
ElementPointer1^ := ElementPointer2^;
I need this language feature today !
In other words as soon as possible so get to it !
It would also be beneficial if C/C++ had this and if CUDA C/C++ can
integrate this as soon as possible.
C syntax:
int main()
{
void *Memory;
dynamic void *Block;
dynamic void *Element;
int BlockSize;
int ElementSize;
int BlockIndex;
int ElementIndex;
... etc ...;
Memory = Malloc( etc );
Block( Memory, BlockSize );
Element( NULL, ElementSize );
Block[ BlockIndex ] : Element[ ElementIndex ] = 1000;
// However perhaps this might present a little issue since : is already used
in C.
// A solution could be to use a double colon like so:
Block[ BlockIndex ] :: Element[ ElementIndex ] = 1000;
}
Bye,
Skybuck.
I need the following code to work:
var
Memory : pointer;
Block : dynamic pointer;
Element : dynamic pointer;
BlockIndex : integer;
ElementIndex : integer;
begin
ElementCount := 8000;
ElementSize := 4;
BlockCount := 1000;
BlockSize := ElementCount * ElementSize;
GetMem( Memory, BlockCount * BlockSize );
Block( Memory, BlockSize );
Element( nil, ElementSize );
Block[ BlockIndex ] : Element[ ElementIndex ] := 1000;
Block[ 500 ] : Element[ 1000 ] := Block[ 300 ] : Element[ 2000 ];
end;
What the following code does is:
Block( Memory, BlockSize );
initializes the block dynamic pointer to have a base address of memory and a
stride of block size.
What the following code does is:
Element( nil, ElementSize );
Initialize the element dynamic pointer to have a base address of nil and a
stride of element size.
What the following code does is:
Block[ BlockIndex ] : Element[ ElementIndex ] := 1000;
BlockPointer := BlockBase + BlockIndex * BlockSize;
: indicates the block pointer is to be passed on as the base for element:
ElementBase := BlockPointer;
ElementPointer := ElementBase + ElementIndex * ElementSize;
ElementPointer^ := 1000;
Additional the compiler is capable of recgonizing different indexing pairs:
Block[ 500 ] : Element[ 1000 ] := Block[ 300 ] : Element[ 2000 ];
Invokes the code above twice for the first and the second pair.
And does:
ElementPointer1^ := ElementPointer2^;
I need this language feature today !
In other words as soon as possible so get to it !
It would also be beneficial if C/C++ had this and if CUDA C/C++ can
integrate this as soon as possible.
C syntax:
int main()
{
void *Memory;
dynamic void *Block;
dynamic void *Element;
int BlockSize;
int ElementSize;
int BlockIndex;
int ElementIndex;
... etc ...;
Memory = Malloc( etc );
Block( Memory, BlockSize );
Element( NULL, ElementSize );
Block[ BlockIndex ] : Element[ ElementIndex ] = 1000;
// However perhaps this might present a little issue since : is already used
in C.
// A solution could be to use a double colon like so:
Block[ BlockIndex ] :: Element[ ElementIndex ] = 1000;
}
Bye,
Skybuck.