Article View: pl.comp.lang.c
Article #310364gpu extension to c
From: (fir)
Date: Mon, 20 Sep 2021 19:44
Date: Mon, 20 Sep 2021 19:44
36 lines
3199 bytes
3199 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)
Technical Details
Message-ID:
<36cbf839-4f68-4c8d-8bd7-1d8c3a06a202n@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.usenet.farm!feed.usenet.farm!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Received: by 2002:a05:622a:18c:: with SMTP id s12mr21325798qtw.62.1632167077021; Mon, 20 Sep 2021 12:44:37 -0700 (PDT) X-Received: by 2002:ac8:5782:: with SMTP id v2mr16335174qta.389.1632167076819; Mon, 20 Sep 2021 12:44:36 -0700 (PDT) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.usenet.farm!feed.usenet.farm!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: pl.comp.lang.c Date: Mon, 20 Sep 2021 12:44:36 -0700 (PDT) Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.157; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN NNTP-Posting-Host: 5.172.255.157 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <36cbf839-4f68-4c8d-8bd7-1d8c3a06a202n@googlegroups.com> Subject: gpu extension to c From: "(fir)" <profesor.fir@gmail.com> Injection-Date: Mon, 20 Sep 2021 19:44:36 +0000 Lines: 52 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit