import sys
import os
import subprocess
import string
import random

num_of_programs = sys.argv[1]
output_directory = sys.argv[2]

os.system("cd "+output_directory)

for i in range (int(num_of_programs)):
        cudafile = "cudatest"+str(i)
        os.system("nvcc -c "+output_directory+"/"+cudafile+".cu >/dev/null 2>&1 && nvcc -o cudatest "+cudafile+".o")
        os.system("./cudatest")
        os.system("rm ./cudatest*")