Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #162774 > unrolled thread

gpu extension to c

Started byfir <profesor.fir@gmail.com>
First post2021-09-20 12:12 -0700
Last post2021-10-03 02:00 +0000
Articles 5 — 3 participants

Back to article view | Back to comp.lang.c


Contents

  gpu extension to c fir <profesor.fir@gmail.com> - 2021-09-20 12:12 -0700
    Re: gpu extension to c fir <profesor.fir@gmail.com> - 2021-09-20 15:16 -0700
    Re: gpu extension to c Philipp Klaus Krause <pkk@spth.de> - 2021-10-02 12:56 +0200
      Re: gpu extension to c fir <profesor.fir@gmail.com> - 2021-10-02 15:24 -0700
        Re: gpu extension to c Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-03 02:00 +0000

#162774 — gpu extension to c

Fromfir <profesor.fir@gmail.com>
Date2021-09-20 12:12 -0700
Subjectgpu extension to c
Message-ID<b5413da6-f4d3-4552-ad5f-2a7fc481e8b8n@googlegroups.com>
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)

[toc] | [next] | [standalone]


#162783

Fromfir <profesor.fir@gmail.com>
Date2021-09-20 15:16 -0700
Message-ID<cdd4a111-34a4-499b-9e86-7e2e179edf7en@googlegroups.com>
In reply to#162774
poniedziałek, 20 września 2021 o 21:12:20 UTC+2 fir napisał(a):
> 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)

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

[toc] | [prev] | [next] | [standalone]


#162933

FromPhilipp Klaus Krause <pkk@spth.de>
Date2021-10-02 12:56 +0200
Message-ID<sj9dsp$b0i$1@solani.org>
In reply to#162774
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.

[toc] | [prev] | [next] | [standalone]


#162949

Fromfir <profesor.fir@gmail.com>
Date2021-10-02 15:24 -0700
Message-ID<85c13845-dada-464b-ac92-0967a5cbf994n@googlegroups.com>
In reply to#162933
sobota, 2 października 2021 o 12:56:38 UTC+2 Philipp Klaus Krause napisał(a):
> 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.

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

[toc] | [prev] | [next] | [standalone]


#162955

FromBranimir Maksimovic <branimir.maksimovic@icloud.com>
Date2021-10-03 02:00 +0000
Message-ID<9986J.143439$rl3.54726@fx45.iad>
In reply to#162949
On 2021-10-02, fir <profesor.fir@gmail.com> wrote:
> sobota, 2 października 2021 o 12:56:38 UTC+2 Philipp Klaus Krause napisał(a):
>> 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.
>
> 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
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c


csiph-web