Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gpu extension to c

61 views
Skip to first unread message

fir

unread,
Sep 20, 2021, 3:12:20 PM9/20/21
to
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)

fir

unread,
Sep 20, 2021, 6:16:13 PM9/20/21
to
btw i remember once navia or somebody was sending some proposals to c standarisation comitee (or am i wrong?)

the comitee it doing some slight nonsenses etc and this is an extension that could change a lot
(here the extensions it to add that one ketword to denote gpu ram and gpoy function/kernel and
other is this "by 10000000" whicgh denotes on how many channels run that kernel

if someone would like to sent this as an official proposition it may send it but only need to add "ass proposed by user fir on comp.lang.c " etc ;c ..eventually some could also consult with me the text of this proposition

imagine how much it would change if c compilers like gcc would later support it and being able to run gpu codes on the fly with ease

Philipp Klaus Krause

unread,
Oct 2, 2021, 6:56:38 AM10/2/21
to
There are GPU experts that put a lot of effort into adapting C for GPUs
/ making a C-like language for GPUs.
The result was OpenCL 1.0, based on ISO C99. AFAIR, since OpenCL 2.0 it
is based on ISO C11, since OpenCL 3.0 on ISO C17.

fir

unread,
Oct 2, 2021, 6:24:49 PM10/2/21
to
they made efforts to define c-like language to shape gpu computiung in kind of c-like code which is run on gpu...but here im talking about somethingthey not done as far as i know

if you want to write and execute gpu code as far as i know (i say afaik as i compiled soem examplec in opencl but not many and few years ago) you must put that c-like gpu-kernel code in a string of chars and then set it to being compiled by opencl then after compiling you may run it you also need to setup arguments by calling opencl finctons etc...this all setup and 'sewing' code is long and kinda ugly - the idea is to remove it and use only one or two keywords making c support it on language level - that kind of c would be compiled on two targets cpu and gpu but being 'glued' begind the language scenes by compiler .. i gabe example how it can look

Branimir Maksimovic

unread,
Oct 2, 2021, 10:00:47 PM10/2/21
to
Learn to use proper news reader and how to poperly format text,
before talking anything on usenet..


--

7-77-777
Evil Sinner!
to weak you should be meek, and you should brainfuck stronger
https://github.com/rofl0r/chaos-pp
0 new messages