Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework4 #3

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Homework4 #3

wants to merge 29 commits into from

Conversation

Rrytel
Copy link
Owner

@Rrytel Rrytel commented Nov 11, 2022

No description provided.

@Rrytel Rrytel requested a review from stevenireeves November 11, 2022 21:14
@Rrytel Rrytel requested a review from stevenireeves November 14, 2022 21:58
@Rrytel Rrytel requested a review from stevenireeves November 15, 2022 21:29
@Rrytel Rrytel requested review from stevenireeves and removed request for stevenireeves November 22, 2022 00:04
Comment on lines +13 to +33
__device__ float Normal(float x, float mu, float sig) {
float temp1 = 1.0f / (std::sqrt(2.0f * 3.14) * sig);
float temp2 = 0.5f * (x - mu) * (x - mu) / (sig * sig);
float val = temp1 * std::exp(-temp2);
return val;
}

__global__ void DataGen(float *data, float *x, float xBeg, float deltaX,
float mu, float sig, int n) {
// generate x and data
// use x for plotting later
int tId = threadIdx.x + blockDim.x * blockIdx.x;
if (tId < 1 || tId > n) {
return;
}
float xTemp[2];
xTemp[0] = xBeg + tId * deltaX;
xTemp[1] = xBeg + (tId - 1) * deltaX;
data[tId - 1] =(Normal(xTemp[0], mu, sig) + Normal(xTemp[1], mu, sig)) * deltaX * 0.5f;
x[tId - 1] = xTemp[0];
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can get rid of these.

//}


ShmemReduceKernelSum<<<gridDim,blockDim,size>>>(dReduc,dHisto);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we just need <<<1, 1024>>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants