Skip to content
Browse files

Added PassThrough and Fixed issue with transferring data back

  • Loading branch information...
1 parent 881f707 commit ec41070b11cf82dbff1b1f02811481569a90f871 @gmhawash gmhawash committed May 30, 2012
Showing with 159 additions and 48 deletions.
  1. 0 QRBGLib/QRBG.cpp
  2. 0 QRBGLib/QRBG.h
  3. 0 QRBGLib/QRBGLib.vcxproj
  4. 0 QRBGLib/QRBGLib.vcxproj.filters
  5. 0 QRBGLib/QRBGLib.vcxproj.user
  6. 0 QRBGLib/ReadMe.txt
  7. 0 RandomServerClient/AssemblyInfo.cpp
  8. 0 RandomServerClient/RandomServerClient.cpp
  9. 0 RandomServerClient/RandomServerClient.vcxproj
  10. 0 RandomServerClient/RandomServerClient.vcxproj.filters
  11. 0 RandomServerClient/RandomServerClient.vcxproj.user
  12. 0 RandomServerClient/ReadMe.txt
  13. 0 RandomServerClient/app.ico
  14. 0 RandomServerClient/app.rc
  15. 0 RandomServerClient/resource.h
  16. 0 RandomServerClient/stdafx.cpp
  17. 0 RandomServerClient/stdafx.h
  18. 0 RandomServerLib/AssemblyInfo.cpp
  19. 0 RandomServerLib/RandomServerLib.cpp
  20. 0 RandomServerLib/RandomServerLib.h
  21. 0 RandomServerLib/RandomServerLib.vcxproj
  22. 0 RandomServerLib/RandomServerLib.vcxproj.filters
  23. 0 RandomServerLib/RandomServerLib.vcxproj.user
  24. 0 RandomServerLib/ReadMe.txt
  25. 0 RandomServerLib/Stdafx.cpp
  26. 0 RandomServerLib/Stdafx.h
  27. 0 RandomServerLib/Thread.h
  28. 0 RandomServerLib/TrueRandom.cpp
  29. 0 RandomServerLib/TrueRandom.h
  30. 0 RandomServerLib/app.ico
  31. 0 RandomServerLib/app.rc
  32. 0 RandomServerLib/resource.h
  33. 0 inputs/Binary/10-bits-src/function-0.txt
  34. 0 inputs/Binary/11-bits-src/function-0.txt
  35. 0 inputs/Binary/30-bits-src/function1.xlsm
  36. 0 inputs/Binary/4-bits-src/Nouraddin.txt
  37. 0 inputs/Binary/4-bits-src/function-0.txt
  38. 0 inputs/Binary/4-bits-src/random-0.txt
  39. 0 inputs/Binary/4-bits-src/stedman-0.txt
  40. 0 inputs/Binary/4-bits-src/stedman-1.txt
  41. 0 inputs/Binary/4-bits-src/stedman-10.txt
  42. 0 inputs/Binary/4-bits-src/stedman-11.txt
  43. 0 inputs/Binary/4-bits-src/stedman-12.txt
  44. 0 inputs/Binary/4-bits-src/stedman-13.txt
  45. 0 inputs/Binary/4-bits-src/stedman-14.txt
  46. 0 inputs/Binary/4-bits-src/stedman-15.txt
  47. 0 inputs/Binary/4-bits-src/stedman-16.txt
  48. 0 inputs/Binary/4-bits-src/stedman-2.txt
  49. 0 inputs/Binary/4-bits-src/stedman-3.txt
  50. 0 inputs/Binary/4-bits-src/stedman-4.txt
  51. 0 inputs/Binary/4-bits-src/stedman-5.txt
  52. 0 inputs/Binary/4-bits-src/stedman-6.txt
  53. 0 inputs/Binary/4-bits-src/stedman-7.txt
  54. 0 inputs/Binary/4-bits-src/stedman-8.txt
  55. 0 inputs/Binary/4-bits-src/stedman-9.txt
  56. 0 inputs/Binary/5-bits-src/function-0.txt
  57. 0 inputs/Binary/6-bits-src/Nouraddin.txt
  58. 0 inputs/Binary/6-bits-src/function-0.txt
  59. 0 inputs/Binary/7-bits-src/function-0.txt
  60. 0 inputs/Binary/8-bits-src/function-0.txt
  61. 0 inputs/Binary/9-bits-src/function-0.txt
  62. 0 inputs/Ternary/HWT10.txt
  63. 0 inputs/Ternary/HWT2.txt
  64. 0 inputs/Ternary/HWT3.txt
  65. 0 inputs/Ternary/HWT4.txt
  66. 0 inputs/Ternary/HWT5.txt
  67. 0 inputs/Ternary/HWT6.txt
  68. 0 inputs/Ternary/HWT7.txt
  69. 0 inputs/Ternary/HWT8.txt
  70. 0 inputs/Ternary/HWT9.txt
  71. BIN quLogicSynthesis.sdf
  72. 0 quLogicSynthesis.sln
  73. BIN quLogicSynthesis.suo
  74. 0 quLogicSynthesis/AssemblyInfo.cpp
  75. 0 quLogicSynthesis/Basic.cpp
  76. 0 quLogicSynthesis/Basic.h
  77. 0 quLogicSynthesis/Conductors/ConductorCore.h
  78. +3 −2 quLogicSynthesis/Conductors/GeneticAlgorithm.h
  79. +5 −0 quLogicSynthesis/Conductors/GeneticAlgorithmParameters.h
  80. +47 −0 quLogicSynthesis/Conductors/Ternary/PassThrough.h
  81. 0 quLogicSynthesis/Generators/GeneratorCore.h
  82. 0 quLogicSynthesis/Generators/Ternary/OrderedSet.h
  83. 0 quLogicSynthesis/Rand.h
  84. 0 quLogicSynthesis/ReadMe.txt
  85. +9 −6 quLogicSynthesis/Sequence.h
  86. 0 quLogicSynthesis/Synthesizers/SynthesizerCore.h
  87. 0 quLogicSynthesis/Synthesizers/Ternary/Basic.h
  88. +13 −13 quLogicSynthesis/Synthesizers/Ternary/Cuda/Basic.h
  89. +18 −12 quLogicSynthesis/Synthesizers/Ternary/Cuda/BasicKernel.cu
  90. 0 quLogicSynthesis/Synthesizers/Ternary/Cuda/CudaSequence.h
  91. 0 quLogicSynthesis/Synthesizers/Ternary/Cuda/cuda_debug.cpp
  92. 0 quLogicSynthesis/Synthesizers/Ternary/Cuda/cuda_debug.h
  93. +2 −1 quLogicSynthesis/Utilities/Config.h
  94. 0 quLogicSynthesis/Utilities/FileSrc.h
  95. 0 quLogicSynthesis/Utilities/Helpers.cpp
  96. 0 quLogicSynthesis/Utilities/Helpers.h
  97. +2 −3 quLogicSynthesis/Utilities/Rand.cpp
  98. +1 −1 quLogicSynthesis/Utilities/Rand.h
  99. +13 −4 quLogicSynthesis/Utilities/Results.h
  100. 0 quLogicSynthesis/Utilities/StopWatch.h
  101. 0 quLogicSynthesis/Utilities/Thread.h
  102. 0 quLogicSynthesis/app.ico
  103. 0 quLogicSynthesis/app.rc
  104. 0 quLogicSynthesis/constants.h
  105. +35 −6 quLogicSynthesis/quLogicSynthesis.cpp
  106. +2 −0 quLogicSynthesis/quLogicSynthesis.vcxproj
  107. +6 −0 quLogicSynthesis/quLogicSynthesis.vcxproj.filters
  108. +3 −0 quLogicSynthesis/quLogicSynthesis.vcxproj.user
  109. 0 quLogicSynthesis/resource.h
  110. 0 quLogicSynthesis/stdafx.cpp
  111. 0 quLogicSynthesis/stdafx.h
  112. 0 quLogicSynthesis/tmpxft_00001c48_00000000-6_BasicKernel.cpp3.o
  113. BIN quLogicSynthesis/vc100.pdb
View
0 QRBGLib/QRBG.cpp 100644 → 100755
File mode changed.
View
0 QRBGLib/QRBG.h 100644 → 100755
File mode changed.
View
0 QRBGLib/QRBGLib.vcxproj 100644 → 100755
File mode changed.
View
0 QRBGLib/QRBGLib.vcxproj.filters 100644 → 100755
File mode changed.
View
0 QRBGLib/QRBGLib.vcxproj.user 100644 → 100755
File mode changed.
View
0 QRBGLib/ReadMe.txt 100644 → 100755
File mode changed.
View
0 RandomServerClient/AssemblyInfo.cpp 100644 → 100755
File mode changed.
View
0 RandomServerClient/RandomServerClient.cpp 100644 → 100755
File mode changed.
View
0 RandomServerClient/RandomServerClient.vcxproj 100644 → 100755
File mode changed.
View
0 RandomServerClient/RandomServerClient.vcxproj.filters 100644 → 100755
File mode changed.
View
0 RandomServerClient/RandomServerClient.vcxproj.user 100644 → 100755
File mode changed.
View
0 RandomServerClient/ReadMe.txt 100644 → 100755
File mode changed.
View
0 RandomServerClient/app.ico 100644 → 100755
File mode changed.
View
0 RandomServerClient/app.rc 100644 → 100755
File mode changed.
View
0 RandomServerClient/resource.h 100644 → 100755
File mode changed.
View
0 RandomServerClient/stdafx.cpp 100644 → 100755
File mode changed.
View
0 RandomServerClient/stdafx.h 100644 → 100755
File mode changed.
View
0 RandomServerLib/AssemblyInfo.cpp 100644 → 100755
File mode changed.
View
0 RandomServerLib/RandomServerLib.cpp 100644 → 100755
File mode changed.
View
0 RandomServerLib/RandomServerLib.h 100644 → 100755
File mode changed.
View
0 RandomServerLib/RandomServerLib.vcxproj 100644 → 100755
File mode changed.
View
0 RandomServerLib/RandomServerLib.vcxproj.filters 100644 → 100755
File mode changed.
View
0 RandomServerLib/RandomServerLib.vcxproj.user 100644 → 100755
File mode changed.
View
0 RandomServerLib/ReadMe.txt 100644 → 100755
File mode changed.
View
0 RandomServerLib/Stdafx.cpp 100644 → 100755
File mode changed.
View
0 RandomServerLib/Stdafx.h 100644 → 100755
File mode changed.
View
0 RandomServerLib/Thread.h 100644 → 100755
File mode changed.
View
0 RandomServerLib/TrueRandom.cpp 100644 → 100755
File mode changed.
View
0 RandomServerLib/TrueRandom.h 100644 → 100755
File mode changed.
View
0 RandomServerLib/app.ico 100644 → 100755
File mode changed.
View
0 RandomServerLib/app.rc 100644 → 100755
File mode changed.
View
0 RandomServerLib/resource.h 100644 → 100755
File mode changed.
View
0 inputs/Binary/10-bits-src/function-0.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/11-bits-src/function-0.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/30-bits-src/function1.xlsm 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/Nouraddin.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/function-0.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/random-0.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-0.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-1.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-10.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-11.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-12.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-13.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-14.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-15.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-16.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-2.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-3.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-4.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-5.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-6.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-7.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-8.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/4-bits-src/stedman-9.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/5-bits-src/function-0.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/6-bits-src/Nouraddin.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/6-bits-src/function-0.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/7-bits-src/function-0.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/8-bits-src/function-0.txt 100644 → 100755
File mode changed.
View
0 inputs/Binary/9-bits-src/function-0.txt 100644 → 100755
File mode changed.
View
0 inputs/Ternary/HWT10.txt 100644 → 100755
File mode changed.
View
0 inputs/Ternary/HWT2.txt 100644 → 100755
File mode changed.
View
0 inputs/Ternary/HWT3.txt 100644 → 100755
File mode changed.
View
0 inputs/Ternary/HWT4.txt 100644 → 100755
File mode changed.
View
0 inputs/Ternary/HWT5.txt 100644 → 100755
File mode changed.
View
0 inputs/Ternary/HWT6.txt 100644 → 100755
File mode changed.
View
0 inputs/Ternary/HWT7.txt 100644 → 100755
File mode changed.
View
0 inputs/Ternary/HWT8.txt 100644 → 100755
File mode changed.
View
0 inputs/Ternary/HWT9.txt 100644 → 100755
File mode changed.
View
BIN quLogicSynthesis.sdf 100644 → 100755
Binary file not shown.
View
0 quLogicSynthesis.sln 100644 → 100755
File mode changed.
View
BIN quLogicSynthesis.suo 100644 → 100755
Binary file not shown.
View
0 quLogicSynthesis/AssemblyInfo.cpp 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Basic.cpp 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Basic.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Conductors/ConductorCore.h 100644 → 100755
File mode changed.
View
5 quLogicSynthesis/Conductors/GeneticAlgorithm.h 100644 → 100755
@@ -52,6 +52,7 @@ namespace Conductor {
InitializePopulation();
Helper::StopTimer.Start();
+ int iteration = 0;
while(NextGeneticAlgorithmParameters()) {
Utility::CStopWatch s;
s.Start();
@@ -62,7 +63,7 @@ namespace Conductor {
DoGeneration(g);
s.Stop();
- //PrintResult(1, s.getElapsedTime());
+ PrintResult(iteration++, GeneticParametersForDisplay(), s.getElapsedTime());
P(String::Format("NextGeneticAlgorithmParameter: {0}\n", Helper::StopTimer.getElapsedTime()));
}
}
@@ -95,7 +96,7 @@ namespace Conductor {
if (m_BestFit > qCost) {
m_BestFit = qCost;
Console::WriteLine("Gen: {0}, BestCost: {1}\n", gen, m_BestFit);
- //SaveResult(m_pSeq[i]);
+ SaveResult(m_pSeq[i]);
}
}
View
5 quLogicSynthesis/Conductors/GeneticAlgorithmParameters.h 100644 → 100755
@@ -25,6 +25,11 @@ namespace Conductor
delete m_sr;
}
+ String^ GeneticParametersForDisplay()
+ {
+ return String::Format("#Generations: {0}, #Runs: {1}, Pm: {2}, Pc: {3}, Crossover: {4}", m_nGenerations, m_nRuns, m_Pm, m_Pc, m_nCrossOver);
+ }
+
bool NextGeneticAlgorithmParameters()
{
String ^s;
View
47 quLogicSynthesis/Conductors/Ternary/PassThrough.h
@@ -0,0 +1,47 @@
+#pragma once
+#include "../ConductorCore.h"
+#include "Generators/GeneratorCore.h"
+#include "Synthesizers/SynthesizerCore.h"
+#include "Sequence.h"
+#include "Synthesizers/Ternary/Cuda/CudaSequence.h"
+#include "Utilities/Rand.h"
+using namespace System;
+using namespace System::IO;
+
+
+#define ROLETTE_SIZE (sizeof(m_RoletteWheel)/sizeof(m_RoletteWheel[0]))
+
+namespace Conductor {
+ class PassThrough : public Core, public Helper::Result {
+ private:
+ Generator::Core *m_pGenerator;
+ Synthesizer::Core *m_pSynthesizer;
+ Sequence *m_pSeq;
+
+ public:
+ PassThrough(int nBits, Generator::Core *pGen, Synthesizer::Core *pSyn) {
+ m_pGenerator = pGen;
+ m_pSynthesizer = pSyn;
+ }
+
+ ~PassThrough() {
+ delete m_pSeq;
+ }
+
+ void Process()
+ {
+ m_pSeq = m_pGenerator->GetSequence();
+
+ Helper::StopTimer.Start();
+ Utility::CStopWatch s;
+ s.Start();
+ m_pSynthesizer->Initialize();
+ m_pSynthesizer->AddSequence(m_pSeq);
+ m_pSynthesizer->Process();
+
+ s.Stop();
+ SaveResult(m_pSeq);
+ PrintResult(0, "PassThrough", s.getElapsedTime());
+ }
+ };
+}
View
0 quLogicSynthesis/Generators/GeneratorCore.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Generators/Ternary/OrderedSet.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Rand.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/ReadMe.txt 100644 → 100755
File mode changed.
View
15 quLogicSynthesis/Sequence.h 100644 → 100755
@@ -20,26 +20,29 @@ class Sequence {
Sequence(){Init();}
+ // Copy Constructor
Sequence(const Sequence& base) {
Init();
m_nBits = base.m_nBits;
m_nTerms = base.m_nTerms;
m_nGates = base.m_nGates;
m_pIn = new int[m_nTerms];
-// m_pOut = new int[m_nTerms];
- // Again, we don't need to copy these on the Copy Constructor...
-// CopyMemory(m_pControl, base.m_pControl, by(MAX_GATES));
-// CopyMemory(m_pTarget, base.m_pTarget, MAX_GATES);
-// CopyMemory(m_pGates, base.m_pGates, MAX_GATES);
+ m_pOut = new int[m_nTerms];
CopyMemory(m_pIn, base.m_pIn, m_nTerms * sizeof(int));
-// CopyMemory(m_pOut, base.m_pOut, m_nTerms * sizeof(int));
+ CopyMemory(m_pOut, base.m_pOut, m_nTerms * sizeof(int));
+ CopyMemory(m_pControl, base.m_pControl, by(m_nGates));
+ CopyMemory(m_pGates, base.m_pGates, by(m_nGates));
+ CopyMemory(m_pTarget, base.m_pTarget, by(m_nGates));
}
void Init() {
m_pInputRadixBuffer = m_pOutputRadixBuffer = NULL;
m_pControl = (LPINT)VirtualAlloc(NULL,by(MAX_GATES), MEM_COMMIT, PAGE_READWRITE);
m_pGates = (LPBYTE)VirtualAlloc(NULL,MAX_GATES, MEM_COMMIT, PAGE_READWRITE);
m_pTarget = (LPBYTE)VirtualAlloc(NULL,MAX_GATES, MEM_COMMIT, PAGE_READWRITE);
+
+ if (m_pControl == NULL || m_pGates == NULL || m_pTarget == NULL)
+ throw("One of these is null: m_pControl: m_pGates: m_pTarget:");
}
void GenerateOutput(int* pOut)
View
0 quLogicSynthesis/Synthesizers/SynthesizerCore.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Synthesizers/Ternary/Basic.h 100644 → 100755
File mode changed.
View
26 quLogicSynthesis/Synthesizers/Ternary/Cuda/Basic.h 100644 → 100755
@@ -5,7 +5,7 @@
#include "CudaSequence.h"
#include "cuda_debug.h"
-void SynthesizeKernel(CudaSequence *pcuSeq);
+void SynthesizeKernel(CudaSequence *pcuSeq, int nSequences);
namespace Synthesizer {
namespace Ternary {
@@ -43,7 +43,7 @@ namespace Synthesizer {
TransferToDevice();
P(String::Format("TransferToDevice: {0}\n", Helper::StopTimer.getElapsedTime()));
- SynthesizeKernel(m_pcuPacket);
+ SynthesizeKernel(m_pcuPacket, m_cuSeq.m_nSequences);
P(String::Format("SynthesizeKernel: {0}\n", Helper::StopTimer.getElapsedTime()));
//cudaThreadSynchronize();
@@ -99,20 +99,20 @@ namespace Synthesizer {
// just need the number of quantum gates which currently represents the quantum cost. In the case we use
// a different quantum cost, we should return that.
- //CS( cudaMemcpy(m_cuSeq.m_pControl, m_cuSeq.m_cuControl, by(m_nTotalTransferGates), cudaMemcpyDeviceToHost) );
- //CS( cudaMemcpy(m_cuSeq.m_pGates, m_cuSeq.m_cuGates, m_nTotalTransferGates, cudaMemcpyDeviceToHost) );
- //CS( cudaMemcpy(m_cuSeq.m_pTarget, m_cuSeq.m_cuTarget, m_nTotalTransferGates, cudaMemcpyDeviceToHost) );
+ CS( cudaMemcpy(m_cuSeq.m_pControl, m_cuSeq.m_cuControl, by(m_nTotalTransferGates), cudaMemcpyDeviceToHost) );
+ CS( cudaMemcpy(m_cuSeq.m_pGates, m_cuSeq.m_cuGates, m_nTotalTransferGates, cudaMemcpyDeviceToHost) );
+ CS( cudaMemcpy(m_cuSeq.m_pTarget, m_cuSeq.m_cuTarget, m_nTotalTransferGates, cudaMemcpyDeviceToHost) );
for(int i=0; i<m_cuSeq.m_nSequences; i++) {
int nGates = m_Sequences[i]->m_nGates = m_cuSeq.m_pnGates[i];
- //LPBYTE pDst = m_Sequences[i]->m_pTarget;
- //LPBYTE pSrc = &m_cuSeq.m_pTarget [i*MAX_GATES];
- //ZeroMemory(m_Sequences[i]->m_pControl, by(nGates));
- //ZeroMemory(m_Sequences[i]->m_pTarget, nGates);
- //ZeroMemory(m_Sequences[i]->m_pGates, nGates);
- //CopyMemory(m_Sequences[i]->m_pControl, &m_cuSeq.m_pControl [i*MAX_GATES], by(nGates));
- //CopyMemory(m_Sequences[i]->m_pTarget, &m_cuSeq.m_pTarget [i*MAX_GATES], nGates);
- //CopyMemory(m_Sequences[i]->m_pGates, &m_cuSeq.m_pGates[i*MAX_GATES], nGates);
+ LPBYTE pDst = m_Sequences[i]->m_pTarget;
+ LPBYTE pSrc = &m_cuSeq.m_pTarget [i*MAX_GATES];
+ ZeroMemory(m_Sequences[i]->m_pControl, by(nGates));
+ ZeroMemory(m_Sequences[i]->m_pTarget, nGates);
+ ZeroMemory(m_Sequences[i]->m_pGates, nGates);
+ CopyMemory(m_Sequences[i]->m_pControl, &m_cuSeq.m_pControl [i*MAX_GATES], by(nGates));
+ CopyMemory(m_Sequences[i]->m_pTarget, &m_cuSeq.m_pTarget [i*MAX_GATES], nGates);
+ CopyMemory(m_Sequences[i]->m_pGates, &m_cuSeq.m_pGates[i*MAX_GATES], nGates);
}
}
View
30 quLogicSynthesis/Synthesizers/Ternary/Cuda/BasicKernel.cu 100644 → 100755
@@ -44,6 +44,12 @@ __device__ void CopySharedToGlobal(PINT pDst, PINT pSrc, int nWords)
pDst[i] = pSrc[i];
}
+__device__ void CopySharedBytesToGlobal(PBYTE pDst, PBYTE pSrc, int nBytes)
+{
+ for (int i=0; i<nBytes; i++)
+ pDst[i] = pSrc[i];
+}
+
__global__ void cuSynthesizeKernel(CudaSequence *data)
{
CudaSequence seq = data[0];
@@ -54,9 +60,9 @@ __global__ void cuSynthesizeKernel(CudaSequence *data)
__shared__ int pIn[81];
__shared__ int pOut[81];
- __shared__ int pControl[1*1024];
- __shared__ BYTE pGates[1*1024];
- __shared__ BYTE pTarget[1*1024];
+ __shared__ int pControl[3*1024];
+ __shared__ BYTE pGates[3*1024];
+ __shared__ BYTE pTarget[3*1024];
for(int i=0; i<seq.m_nTerms; i++) {
pIn[i] = seq.m_cuIn[inputIndex+i];
@@ -76,22 +82,22 @@ __global__ void cuSynthesizeKernel(CudaSequence *data)
for(int i=0; i<nGates; i++) {
CopySharedToGlobal(&seq.m_cuControl[outputIndex], pControl, nGates);
- CopySharedToGlobal((PINT)&seq.m_cuTarget[outputIndex], (PINT)pTarget, nGates/sizeof(int));
- CopySharedToGlobal((PINT)&seq.m_cuGates[outputIndex], (PINT)pGates, nGates/sizeof(int));
+ CopySharedBytesToGlobal(&seq.m_cuTarget[outputIndex], pTarget, nGates);
+ CopySharedBytesToGlobal(&seq.m_cuGates[outputIndex], pGates, nGates);
}
seq.m_cuNumGates[blockIdx.x] = nGates;
- //printf("block: nGates Index: %d [%d]\n", blockIdx.x, seq.m_cuGates[blockIdx.x]);
+ printf("block: nGates Index: %d [%d]\n", blockIdx.x, seq.m_cuGates[blockIdx.x]);
}
-void SynthesizeKernel(CudaSequence *pcuSeq)
+void SynthesizeKernel(CudaSequence *pcuSeq, int nSequences)
{
// Constants are scoped to a file, and cannot use extern..
CS( cudaMemcpyToSymbol(gcuBitMask, gBitMask, sizeof(gBitMask)) );
CS( cudaMemcpyToSymbol(gcuTernaryOps, gTernaryOps, sizeof(gTernaryOps)) );
CS( cudaMemcpyToSymbol(gcuOpMap, gOpMap, sizeof(gOpMap)) );
- cuSynthesizeKernel<<<NUMBER_OF_CUDA_BLOCKS, 1>>>(pcuSeq);
+ cuSynthesizeKernel<<<nSequences, 1>>>(pcuSeq);
}
__device__ int Propagate(int outTerm, PINT pControl, PBYTE pTarget, PBYTE pOperation, int nGates)
@@ -111,10 +117,10 @@ __device__ int Propagate(int outTerm, PINT pControl, PBYTE pTarget, PBYTE pOpera
__device__ void Process(int inTerm, int outTerm, int nBits, PINT pnGates, PINT pControl, PBYTE pTarget, PBYTE pOperation)
{
- //printf("\n****** In,out:[%d, %d] ", inTerm, outTerm);
+ printf("\n****** In,out:[%d, %d], nGates: [%d] ", inTerm, outTerm, *pnGates);
outTerm = Propagate(outTerm, pControl, pTarget, pOperation, *pnGates);
- //printf("After Propgate: %d \n", outTerm);
+ printf("After Propgate: %d \n", outTerm);
// process low (output) to high (input) transitions first then high to low
for(int dir=1; dir>-2; dir-=2) {
@@ -127,10 +133,10 @@ __device__ void Process(int inTerm, int outTerm, int nBits, PINT pnGates, PINT p
pTarget [*pnGates] = i; // Save index of target bits
pControl [*pnGates] = ~gcuBitMask[i] & outTerm; // For now, it is everything except target bits is a control bit
pOperation[*pnGates] = gcuOpMap[BIT(inTerm,i)][BIT(outTerm,i)]; // Find the appropriate operation.
- //printf("dir(%d) [C,T,O] [%d, %d, %d] ", dir, pControl[*pnGates], i, pOperation[*pnGates]);
+ printf("dir(%d) [C,T,O] [%d, %d, %d] ", dir, pControl[*pnGates], i, pOperation[*pnGates]);
(*pnGates)++;
outTerm = (~gcuBitMask[i] & outTerm) | (gcuBitMask[i] & inTerm);
- //printf(" => %d \n", outTerm);
+ printf(" => %d \n", outTerm);
}
}
}
View
0 quLogicSynthesis/Synthesizers/Ternary/Cuda/CudaSequence.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Synthesizers/Ternary/Cuda/cuda_debug.cpp 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Synthesizers/Ternary/Cuda/cuda_debug.h 100644 → 100755
File mode changed.
View
3 quLogicSynthesis/Utilities/Config.h
@@ -1,4 +1,5 @@
#pragma once
+using namespace std;
namespace Config {
class Core {
@@ -7,6 +8,7 @@ namespace Config {
int m_Radix;
int m_RadixMask;
int m_nBits;
+ string m_FunctionName;
Core(int nBits) {
m_nBits = nBits;
@@ -43,6 +45,5 @@ namespace Config {
int RadixBits();
int Bits();
int RadixMask();
- static int Date= 23;
static int NumberOfCudaBlocks = 100;
}
View
0 quLogicSynthesis/Utilities/FileSrc.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Utilities/Helpers.cpp 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Utilities/Helpers.h 100644 → 100755
File mode changed.
View
5 quLogicSynthesis/Utilities/Rand.cpp 100644 → 100755
@@ -31,9 +31,10 @@ namespace Rand
{
while(true) {
Fill();
- Sleep(1000);
+ Sleep(10);
}
+ Console::WriteLine("Why am I exiting");
return true;
}
@@ -50,8 +51,6 @@ namespace Rand
line = reader->ReadLine();
line = reader->ReadLine();
- IntPtr ip = Marshal::StringToBSTR(line);
- char* str = static_cast<char*>(ip.ToPointer());
for(int i=0; i<BufferSize/2; i++) {
Extract(line, 2*i);
View
2 quLogicSynthesis/Utilities/Rand.h 100644 → 100755
@@ -20,7 +20,7 @@ namespace Rand
extern Rand *m_pRandom;
- inline void Initialize() { m_pRandom = new Rand();}
+ inline void Initialize() { m_pRandom = new Rand(); m_pRandom->Start(NULL);}
inline double Double() {return m_pRandom->Double();}
inline int Integer(int range=INT_MAX) {return (int)(range*m_pRandom->Double());}
}
View
17 quLogicSynthesis/Utilities/Results.h 100644 → 100755
@@ -7,6 +7,7 @@
using namespace System::IO;
using namespace System;
using namespace std;
+using namespace System::Runtime::InteropServices;
namespace Helper {
class Result
@@ -22,13 +23,20 @@ namespace Helper {
m_pSeq = new Sequence(*seq);
}
- void PrintResult(int iteration, double Time)
+ void PrintResult(int iteration, String^ Description, double Time)
{
char szTmp[1024];
- Directory::CreateDirectory( String::Format("..\\SaveData\\{0}-bits\\{1}", m_pSeq->m_nBits, Config::Date));
- sprintf(szTmp, "../SaveData/%d-bits/%d/%d-iteration.qsy", m_pSeq->m_nBits, Config::Date, iteration);
+ String^ today = DateTime::Now.ToShortDateString();
+
+ Directory::CreateDirectory( String::Format("..\\SaveData\\{0}-bits\\{1}", m_pSeq->m_nBits, today));
+ sprintf(szTmp, "../SaveData/%d-bits/%s/%d-iteration.qsy", m_pSeq->m_nBits, today, iteration);
ofstream fs(szTmp);
+ IntPtr ip = Marshal::StringToHGlobalAnsi(Description);
+ char* str = static_cast<char*>(ip.ToPointer());
+ fs << "Genetic Parameters: " << str << endl;
+ fs << "Time To Synthesize: " << Time << endl;
+ fs << "Radix: " << Config::Radix() << endl;
fs << "Bit Count: " << m_pSeq->m_nBits << endl;
fs << "Quantum Cost: " << m_pSeq->QuantumCost() << endl;
@@ -64,8 +72,9 @@ namespace Helper {
fs << Helper::InRadixDigits(m_pSeq->m_pControl[i]) << " | ";
fs.fill(' ');
fs.width(5);
- fs << m_pSeq->m_pTarget[i] << " | ";
+ fs << (int)m_pSeq->m_pTarget[i] << " | ";
fs.width(2);
+ fs << gates[(int)m_pSeq->m_pGates[i]] << endl;
}
fs.close();
}
View
0 quLogicSynthesis/Utilities/StopWatch.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/Utilities/Thread.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/app.ico 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/app.rc 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/constants.h 100644 → 100755
File mode changed.
View
41 quLogicSynthesis/quLogicSynthesis.cpp 100644 → 100755
@@ -3,6 +3,7 @@
#include "stdafx.h"
#include "Winbase.h"
#include "Conductors/GeneticAlgorithm.h"
+#include "Conductors/Ternary/PassThrough.h"
#include "Generators/Ternary/OrderedSet.h"
#include "Synthesizers/Ternary/Basic.h"
#include "Synthesizers/Ternary/Cuda/Basic.h"
@@ -12,20 +13,29 @@ using namespace std;
using namespace System;
#define FILE_PATTERN "Ternary\\hwt"
-int ternary()
+int GATernary();
+int TestTernary();
+
+int main()
{
- for (int nBits=5; nBits<=5; nBits++) {
+ GATernary();
+}
+
+int TestTernary()
+{
+ for (int nBits=4; nBits<=6; nBits++) {
Config::SetRadix(3, nBits);
int* pOut;
Utility::FileSrc fs(nBits, FILE_PATTERN + Convert::ToString(nBits));
while (pOut = fs.Next() ) {
+ Console::WriteLine("Processing Next Sequence");
Helper::pOutput = pOut;
Console::WriteLine("Function: " + fs.Name);
Synthesizer::Core *pSyn = new Synthesizer::Ternary::Cuda::Basic(nBits);
Generator::Core *pGen = new Generator::Ternary::OrderedSet(nBits, pOut);
- Conductor::Core *pAlgo = new Conductor::GeneticAlgorithm(nBits, pGen, pSyn);
+ Conductor::Core *pAlgo = new Conductor::PassThrough(nBits, pGen, pSyn);
pAlgo->Process();
delete pSyn;
delete pGen;
@@ -35,9 +45,28 @@ int ternary()
return 0;
}
-int main()
+int GATernary()
{
Rand::Initialize();
+ for (int nBits=4; nBits<=6; nBits++) {
+ Config::SetRadix(3, nBits);
+
+ int* pOut;
+ Utility::FileSrc fs(nBits, FILE_PATTERN + Convert::ToString(nBits));
+
+ while (pOut = fs.Next() ) {
+ Console::WriteLine("Processing Next Sequence");
+ Helper::pOutput = pOut;
+ Console::WriteLine("Function: " + fs.Name);
+ Synthesizer::Core *pSyn = new Synthesizer::Ternary::Cuda::Basic(nBits);
+ Generator::Core *pGen = new Generator::Ternary::OrderedSet(nBits, pOut);
+ Conductor::Core *pAlgo = new Conductor::GeneticAlgorithm(nBits, pGen, pSyn);
+ pAlgo->Process();
+ delete pSyn;
+ delete pGen;
+ delete pAlgo;
+ }
+ }
+ return 0;
+}
- ternary();
-}
View
2 quLogicSynthesis/quLogicSynthesis.vcxproj 100644 → 100755
@@ -160,6 +160,7 @@
<ClInclude Include="Conductors\ConductorCore.h" />
<ClInclude Include="Conductors\GeneticAlgorithm.h" />
<ClInclude Include="Conductors\GeneticAlgorithmParameters.h" />
+ <ClInclude Include="Conductors\Ternary\PassThrough.h" />
<ClInclude Include="constants.h" />
<ClInclude Include="Generators\GeneratorCore.h" />
<ClInclude Include="Generators\Ternary\OrderedSet.h" />
@@ -178,6 +179,7 @@
<ClInclude Include="Utilities\Helpers.h" />
<ClInclude Include="Utilities\Results.h" />
<ClInclude Include="Utilities\StopWatch.h" />
+ <ClInclude Include="Utilities\StringConvertor.h" />
<ClInclude Include="Utilities\Thread.h" />
<ClInclude Include="Utilities\Rand.h" />
</ItemGroup>
View
6 quLogicSynthesis/quLogicSynthesis.vcxproj.filters 100644 → 100755
@@ -114,6 +114,12 @@
<ClInclude Include="Utilities\Rand.h">
<Filter>Utilities</Filter>
</ClInclude>
+ <ClInclude Include="Conductors\Ternary\PassThrough.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Utilities\StringConvertor.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="app.rc">
View
3 quLogicSynthesis/quLogicSynthesis.vcxproj.user 100644 → 100755
@@ -1,3 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ShowAllFiles>true</ShowAllFiles>
+ </PropertyGroup>
</Project>
View
0 quLogicSynthesis/resource.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/stdafx.cpp 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/stdafx.h 100644 → 100755
File mode changed.
View
0 quLogicSynthesis/tmpxft_00001c48_00000000-6_BasicKernel.cpp3.o 100644 → 100755
File mode changed.
View
BIN quLogicSynthesis/vc100.pdb 100644 → 100755
Binary file not shown.

0 comments on commit ec41070

Please sign in to comment.
Something went wrong with that request. Please try again.