|FROM ||Ruben Safir
|SUBJECT ||Re: [Learn] not adequately speced of explained
|From learn-bounces-at-nylxs.com Tue Nov 1 14:19:46 2016
Received: from www.mrbrklyn.com (www.mrbrklyn.com [188.8.131.52])
by mrbrklyn.com (Postfix) with ESMTP id 42EF2161312;
Tue, 1 Nov 2016 14:19:46 -0400 (EDT)
Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com
[184.108.40.206]) by mrbrklyn.com (Postfix) with ESMTP id E66D0160E77
for ; Tue, 1 Nov 2016 14:19:43 -0400 (EDT)
Received: by mail-qt0-f194.google.com with SMTP id n6so2958769qtd.0
for ; Tue, 01 Nov 2016 11:19:43 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=my.liu.edu; s=google;
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
X-Received: by 10.237.51.167 with SMTP id v36mr27913209qtd.46.1478024383100;
Tue, 01 Nov 2016 11:19:43 -0700 (PDT)
Received: from [10.0.0.62] (www.mrbrklyn.com. [220.127.116.11])
by smtp.googlemail.com with ESMTPSA id o44sm16391536qtc.10.2016.11.01.11.19.42
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Tue, 01 Nov 2016 11:19:42 -0700 (PDT)
To: Ruben Safir , learn-at-nylxs.com,
From: Ruben Safir
Date: Tue, 1 Nov 2016 14:19:42 -0400
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Subject: Re: [Learn] not adequately speced of explained
Content-Type: text/plain; charset="us-ascii"
On 11/01/2016 12:30 PM, Ruben Safir wrote:
> Why am I wasting my time with this video on CUDA
> Look at this stupid homework. There is not enough specification here to
> attempt the home work. Instead your expected to beg the website for
> more information.
> We do NOT know the construction of the graphics. I don't even know what
> a uchar4 is but that is not the least of the problem. I don't know is a
> uchar4 is a mapping of data. I have NO CLUE what the two extra params are.
> I didn't even know that i could add two additional params to the GLOBAL
> I'm sick of WASTING TIME with sloppy crap like this. I can waste hours
> of time trying to unravel the mystery of this.
> I don't know what 2D is. I don't know what I am mapping. I don't have
> a specification of any data structures whatsoever.
> I HAVE NO DAMN SPECIFICATION HERE.
> Why are we not using the MIT resources that are well thought out and
> dumbed down to being unusable.
> Why do I have to wander all the time in the dark.
> // Homework 1
> // Color to Greyscale Conversion
> //A common way to represent color images is known as RGBA - the color
> //is specified by how much Red, Green, and Blue is in it.
> //The 'A' stands for Alpha and is used for transparency; it will be
> //ignored in this homework.
> //Each channel Red, Blue, Green, and Alpha is represented by one byte.
> //Since we are using one byte for each color there are 256 different
> //possible values for each color. This means we use 4 bytes per pixel.
> //Greyscale images are represented by a single intensity value per pixel
> //which is one byte in size.
> //To convert an image from color to grayscale one simple method is to
> //set the intensity to the average of the RGB channels. But we will
> //use a more sophisticated method that takes into account how the eye
> //perceives color and weights the channels unequally.
> //The eye responds most strongly to green followed by red and then blue.
> //The NTSC (National Television System Committee) recommends the following
> //formula for color to greyscale conversion:
> //I = .299f * R + .587f * G + .114f * B
> //Notice the trailing f's on the numbers which indicate that they are
> //single precision floating point constants and not double precision
> //You should fill in the kernel as well as set the block and grid sizes
> //so that the entire image is processed.
> #include "reference_calc.cpp"
> #include "utils.h"
> void rgba_to_greyscale(const uchar4* const rgbaImage,
> unsigned char* const greyImage,
> int numRows, int numCols)
> //Fill in the kernel to convert from color to greyscale
> //the mapping from components of a uchar4 to RGBA is:
> // .x -> R ; .y -> G ; .z -> B ; .w -> A
> //The output (greyImage) at each pixel should be the result of
> //applying the formula: output = .299f * R + .587f * G + .114f * B;
> //Note: We will be ignoring the alpha channel for this conversion
> //First create a mapping from the 2D block and grid locations
> //to an absolute 2D location in the image, then use that to
> //calculate a 1D offset
> int R = threadIdx.x;
> int G = threadIdx.y;
> int B = threadIdx.z;
> float fR = float(R) * 0.299f;
> float fG = float(G) * 0.587f;
> float fB = float(B) * 0.114f;
> float ave = (fR + fG + fB) / 3f ;
> void your_rgba_to_greyscale(const uchar4 * const h_rgbaImage, uchar4 *
> const d_rgbaImage,
> unsigned char* const d_greyImage, size_t
> numRows, size_t numCols)
> //You must fill in the correct sizes for the blockSize and gridSize
> //currently only one block with one thread is being launched
> const dim3 blockSize(1, 1, 1); //TODO
> const dim3 gridSize( 1, 1, 1); //TODO
> rgba_to_greyscale<<>>(d_rgbaImage, d_greyImage,
> numRows, numCols);
> cudaDeviceSynchronize(); checkCudaErrors(cudaGetLastError());
This is from the documentation.
B.19. Execution Configuration
Any call to a __global__ function must specify the execution
configuration for that call. The execution configuration defines the
dimension of the grid and blocks that will be used to execute the
function on the device, as well as the associated stream (see CUDA C
Runtime for a description of streams).
The execution configuration is specified by inserting an expression of
the form <<< Dg, Db, Ns, S >>> between the function name and the
parenthesized argument list, where:
Dg is of type dim3 (see dim3) and specifies the dimension and size
of the grid, such that Dg.x * Dg.y * Dg.z equals the number of blocks
Db is of type dim3 (see dim3) and specifies the dimension and size
of each block, such that Db.x * Db.y * Db.z equals the number of threads
Ns is of type size_t and specifies the number of bytes in shared
memory that is dynamically allocated per block for this call in addition
to the statically allocated memory; this dynamically allocated memory is
used by any of the variables declared as an external array as mentioned
in __shared__; Ns is an optional argument which defaults to 0;
S is of type cudaStream_t and specifies the associated stream; S is
an optional argument which defaults to 0.
As an example, a function declared as
__global__ void Func(float* parameter);
must be called like this:
Func<<< Dg, Db, Ns >>>(parameter);
The arguments to the execution configuration are evaluated before the
actual function arguments.
The function call will fail if Dg or Db are greater than the maximum
sizes allowed for the device as specified in Compute Capabilities, or if
Ns is greater than the maximum amount of shared memory available on the
device, minus the amount of shared memory required for static allocation.
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive
http://www.coinhangout.com - coins!
Being so tracked is for FARM ANIMALS and and extermination camps,
but incompatible with living as a free human being. -RI Safir 2013
Learn mailing list