Commit 4f40f897 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

QCOR CSP compile time data collection script



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 6bbb81f1
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
// Dummy file to compile OpenQASM using qcor in syntax handler mode.
#include "qcor.hpp"

#ifdef TEST_SOURCE_FILE
__qpu__ void testKernel(qreg quVar) {
  using qcor::openqasm;
#include TEST_SOURCE_FILE
}

int main() {
  return 0;
}
#endif
 No newline at end of file
+27 −0
Original line number Diff line number Diff line
import os, glob, time, csv

dirPath = os.path.dirname(os.path.realpath(__file__))
os.chdir(dirPath)

listOfSrcFiles = glob.glob(dirPath + "/qasm/*.qasm")
# We must run smaller files first.
# It may hang indefinitely for larger files...
listOfSrcFiles = sorted(listOfSrcFiles, key = os.path.getsize)

#Time to compile via syntax handler
headers = ["Test Case", "total time"]
firstWrite = True

for file in listOfSrcFiles:
  print(file)
  rowData = [os.path.splitext(os.path.basename(file))[0]]
  start_time = time.time()
  os.system("qcor -DTEST_SOURCE_FILE=\\\"" + file + "\\\" qcor_csp.cpp")
  rowData.append(time.time() - start_time)
  with open('result_csp.csv', 'a', newline='') as csvfile:
    resultWriter = csv.writer(csvfile)
    if firstWrite is True:
      resultWriter.writerow(headers)
      firstWrite = False
    # Write data
    resultWriter.writerow(rowData)
 No newline at end of file