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

Finish Project2,Bo Zhang #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Project/Debug/Project2.ilk
Binary file not shown.
Binary file added Project/Debug/Project2.pdb
Binary file not shown.
Binary file added Project/Project2.sdf
Binary file not shown.
26 changes: 26 additions & 0 deletions Project/Project2.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project2", "Project2\Project2.vcxproj", "{BE4852FE-D7AE-4A1F-B95C-837E32193DDB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BE4852FE-D7AE-4A1F-B95C-837E32193DDB}.Debug|Win32.ActiveCfg = Debug|Win32
{BE4852FE-D7AE-4A1F-B95C-837E32193DDB}.Debug|Win32.Build.0 = Debug|Win32
{BE4852FE-D7AE-4A1F-B95C-837E32193DDB}.Debug|x64.ActiveCfg = Debug|x64
{BE4852FE-D7AE-4A1F-B95C-837E32193DDB}.Debug|x64.Build.0 = Debug|x64
{BE4852FE-D7AE-4A1F-B95C-837E32193DDB}.Release|Win32.ActiveCfg = Release|Win32
{BE4852FE-D7AE-4A1F-B95C-837E32193DDB}.Release|Win32.Build.0 = Release|Win32
{BE4852FE-D7AE-4A1F-B95C-837E32193DDB}.Release|x64.ActiveCfg = Release|x64
{BE4852FE-D7AE-4A1F-B95C-837E32193DDB}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file added Project/Project2.suo
Binary file not shown.
63 changes: 63 additions & 0 deletions Project/Project2/CPUcode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include "CPUcode.h"
#include <Windows.h>


//Part 1
void PrefixSum(int* origin,int *result,int n)
{
result[0] = 0;
for(int i=1;i<n;i++)
result[i] = result[i-1] + origin[i-1];

return;
}

//Part 4
void SerialScatter(int* origin,int *result,int n)
{
for(int i=0;i<n;i++)
{
if(origin[i]>0)
origin[i] = 1;
}

PrefixSum(origin,result,n);
}

int* StreamCompact(int* origin,int n,int &l)
{
int* corigin = new int[n];
int *result = new int[n];
for(int i=0;i<n;i++)
corigin[i] = origin[i];

SerialScatter(origin,result,n);
int *r = new int[result[n-1]+1];
int indexmax = result[n-1];
for(int i=n-1;i>=0;i--)
{
if(result[i]==indexmax)
{
r[indexmax] = corigin[i];
indexmax--;
}
}

//Reset Origin Array
for(int i=0;i<n;i++)
origin[i] = corigin[i];

l = result[n-1]+1;
return r;
}

double gettime()
{
LARGE_INTEGER litmp;
QueryPerformanceFrequency(&litmp);
double dff =(double)litmp.QuadPart;
QueryPerformanceCounter(&litmp);
double t =(double)litmp.QuadPart;
return t/dff;
}

8 changes: 8 additions & 0 deletions Project/Project2/CPUcode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <vector>
#include <iostream>
using namespace std;

void PrefixSum(int* origin,int *result,int n);
void SerialScatter(int* origin,int *result,int n);
int* StreamCompact(int* origin,int n, int &l);
double gettime();
Binary file added Project/Project2/Debug/CL.read.1.tlog
Binary file not shown.
Binary file added Project/Project2/Debug/CL.write.1.tlog
Binary file not shown.
10 changes: 10 additions & 0 deletions Project/Project2/Debug/Project2.exe.embed.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Binary file not shown.
10 changes: 10 additions & 0 deletions Project/Project2/Debug/Project2.exe.intermediate.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
2 changes: 2 additions & 0 deletions Project/Project2/Debug/Project2.lastbuildstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#v4.0:v100
Debug|Win32|D:\Graduate\second-year-first-semester\CIS-565\Project-2\Project2-StreamCompaction\Project\|
118 changes: 118 additions & 0 deletions Project/Project2/Debug/Project2.log

Large diffs are not rendered by default.

Binary file not shown.
Empty file.
Binary file added Project/Project2/Debug/Project2_manifest.rc
Binary file not shown.
Binary file added Project/Project2/Debug/cl.command.1.tlog
Binary file not shown.
49 changes: 49 additions & 0 deletions Project/Project2/Debug/kernel.cu.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Identity=kernel.cu
AdditionalCompilerOptions=
AdditionalCompilerOptions=
AdditionalDependencies=
AdditionalDeps=
AdditionalLibraryDirectories=
AdditionalOptions=
AdditionalOptions=
CInterleavedPTX=false
CodeGeneration=compute_20,sm_20
CodeGeneration=compute_20,sm_20
CompileOut=Debug\kernel.cu.obj
CudaRuntime=Static
CudaToolkitCustomDir=
Defines=;WIN32;_DEBUG;_CONSOLE;_MBCS;
Emulation=false
FastMath=false
GenerateLineInfo=false
GenerateRelocatableDeviceCode=false
GPUDebugInfo=true
GPUDebugInfo=true
HostDebugInfo=true
Include=;;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include
Inputs=
Keep=false
KeepDir=Debug
LinkOut=
MaxRegCount=0
NvccCompilation=compile
NvccPath=
Optimization=Od
Optimization=Od
PerformDeviceLink=
PtxAsOptionV=false
RequiredIncludes=
Runtime=MDd
Runtime=MDd
RuntimeChecks=RTC1
RuntimeChecks=RTC1
TargetMachinePlatform=32
TargetMachinePlatform=32
TypeInfo=
TypeInfo=
UseHostDefines=true
UseHostInclude=true
UseHostLibraryDependencies=
UseHostLibraryDirectories=
Warning=W3
Warning=W3
Loading