🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by "(fir)" Mon, 20 Sep 2021 12:44
gpu extension to c
#291717
Author: "(fir)"
Date: Mon, 20 Sep 2021 12:44
52 lines
2114 bytes
example: 

int image[1024][1024]; 

video int image_in[1024][1024]; 
video int image_out[1024][1024]; 

video void BlurImageOnMpu( int current_channel_id ) by 1048576 channels 
{ 
int id_x = current_channel_id%1024; 
int id_y = current_channel_id/1024; 
int value; 
if(id_x==0) value = ( image_in[id_y][id_x] + image_in[id_y][id_x+1] ) /2; 
else if(id_x==1023) value = ( image_in[id_y][id_x] + image_in[id_y][id_x-1] ) /2; 
else 
value = (image_in[id_y][id_x-1] + image_in[id_y][id_x] + image_in[id_y][id_x+2]) / 3 ; 
//i know its nonsense coz its rgb not integer but for illistratuon of idea 
image_out[id_y][id_x] = value; 
} 
int main() 
{ 
load_image("some.jpg", image); 
copy_ram_to_vram(image_in, image, 1024*1024); 
BlurImageOnMpu(); 
copy_vram_to_ram(image, image_out, 1024*1024); 
save_image("some out.jpg", image); 
return 1; 
} 

i was sleeping today and dreamin about writing gpu kernells stright form c language level.. (later i also reneme gpu as mpu = matrix processing unit as this name is more general) 
it seem to me that only slight extension to c syntax need to be added mainly some keyword "video" or "mpu" which would denote that tis entity is to be lockated in vram not ram and this funstion is gpu kernel function not regular cpu one.. i use "video" keyword just to be more eye catching here 
the code example is a intentiionally bit simplified for fixed image size and idiotic 'blur' code when i add argb pixels which is nonsense but it is to ilustrate c extension not to use real sense function whuch would be harder to read 
beside "video" keyword one also need to dentote on how many parallel gpu/mpu/video channels given kernel function would be run - i use "by 1048576 parallel channels" stetement which is a bit long and also kinda syntactic stub,. it could be something else like [1048576] after function name or somethnig 
not not that i got this idea in dream, i was thinkiong on this some years ago but today i got a dream which just remembered the thing] 

(fir)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads