Пример #1
0
        public static void createCudaIncludesAndLibaryPath(
            StreamWriter writer,
            ProjectInfo_CPP projectInfo,
            ProjectInfo_CUDA projectCudaInfo)
        {
            if (projectCudaInfo.IsCUDA)
            {
                var configurationInfos = projectInfo.getConfigurationInfos();

                foreach (var configurationInfo in configurationInfos)
                {
                    var includes        = MakefileBuilder_Project_CPP.getIncludePathVariableName(configurationInfo);
                    var cudaIncludePath = getCudaPath() + "/include";
                    writer.WriteLine("{0}+=-I\"{1}\"", includes, cudaIncludePath);
                }

                writer.WriteLine("");

                foreach (var configurationInfo in configurationInfos)
                {
                    var libPath         = MakefileBuilder_Project_CPP.getLibraryPathVariableName(configurationInfo);
                    var cudaLabraryPath = getCudaPath() + "/lib64";
                    writer.WriteLine("{0}+=-L\"{1}\"", libPath, cudaLabraryPath);
                }

                writer.WriteLine("");
            }
        }
Пример #2
0
        public static string getObjectFiles(string intermediateFolder, ProjectInfo_CUDA projectCudaInfo)
        {
            var files = "";

            if (projectCudaInfo.IsCUDA)
            {
                foreach (var info in projectCudaInfo.CompileInfos)
                {
                    var filename = info.File;

                    string path = String.Format("{0}/{1}", intermediateFolder, filename);
                    if (filename.StartsWith(".."))
                    {
                        var tmp = filename.Replace("../", "");
                        path = String.Format("{0}/{1}", intermediateFolder, tmp);
                    }
                    string objectPath = Path.ChangeExtension(path, ".o");

                    files += objectPath + " ";
                }

                files += getLinkedCudaFile(intermediateFolder) + " ";
            }

            return(files);
        }
Пример #3
0
        public static void createCudaLinker(
            StreamWriter writer,
            ProjectInfo_CPP projectInfo,
            ProjectConfigurationInfo_CPP configurationInfo,
            ProjectInfo_CUDA projectCudaInfo)
        {
            if (!projectCudaInfo.IsCUDA || projectCudaInfo.CompileInfos.Count == 0)
            {
                return;
            }

            var projectSettings = MakeItSoConfig.Instance.getProjectConfig(projectInfo.Name);

            var intermediateFolder = MakefileBuilder_Project_CPP.getIntermediateFolder(projectInfo, configurationInfo);

            string files = "";

            foreach (var info in projectCudaInfo.CompileInfos)
            {
                var filename = info.File;

                if (projectSettings.filesOrDirectoriesShouldBeRemoved(filename))
                {
                    continue;
                }

                string path = String.Format("{0}/{1}", intermediateFolder, filename);
                if (filename.StartsWith(".."))
                {
                    var tmp = filename.Replace("../", "");
                    path = String.Format("{0}/{1}", intermediateFolder, tmp);
                }
                string objectPath = Path.ChangeExtension(path, ".o");

                files += objectPath + " ";
            }


            // TODO
            string sm = "sm_20";
            {
                var compileInfo = projectCudaInfo.CompileInfos.Count > 0 ? projectCudaInfo.CompileInfos[0] : projectCudaInfo.AllCompileInfo;

                var opt  = compileInfo.getOption(configurationInfo.Name);
                var gens = getCodeGenerations(opt);
                sm = gens[1];
            }

            var linkedFile = getLinkedCudaFile(intermediateFolder);

            writer.WriteLine("# Link gpu code files.");
            writer.WriteLine("{0}: {1}", linkedFile, files);
            writer.WriteLine("\t$(NVCC) -arch={0} -dlink {1} -o {2}", sm, files, linkedFile);
            writer.WriteLine("");
        }
        /// <summary>
        /// Constructor
        /// </summary>
        private MakefileBuilder_Project_CPP(ProjectInfo_CPP project, ProjectInfo_CUDA projectInfoCuda)
        {
            m_projectInfo     = project;
            m_projectInfoCuda = projectInfoCuda;

            try
            {
                // We create the file '[project-name].makefile', and set it to
                // use unix-style line endings...
                string path = String.Format("{0}/{1}.makefile", m_projectInfo.RootFolderAbsolute, m_projectInfo.Name);
                m_file         = new StreamWriter(path, false);
                m_file.NewLine = MakeItSoConfig.Instance.NewLine;

                // We create variables...
                createCompilerVariables();
                createIncludePathVariables();
                createLibraryPathVariables();
                createLibrariesVariables();
                createPreprocessorDefinitionsVariables();
                createImplicitlyLinkedObjectsVariables();
                createCompilerFlagsVariables();

                MakefileBuilder_Project_CUDA.createCudaLocationAndCompiler(m_file, m_projectInfoCuda);
                MakefileBuilder_Project_CUDA.createCudaIncludesAndLibaryPath(m_file, m_projectInfo, m_projectInfoCuda);

                // We create an 'all configurations' root target...
                createAllConfigurationsTarget();

                // We create one target for each configuration...
                createConfigurationTargets();

                // We create a target to create the intermediate and output folders...
                createCreateFoldersTarget();

                // Creates the target that cleans intermediate files...
                createCleanTarget();
            }
            finally
            {
                if (m_file != null)
                {
                    m_file.Close();
                    m_file.Dispose();
                }
            }
        }
Пример #5
0
        public static void createCudaLocationAndCompiler(
            StreamWriter writer,
            ProjectInfo_CUDA projectCudaInfo)
        {
            if (projectCudaInfo.IsCUDA)
            {
                // CUDA location.
                writer.WriteLine("# Location of the CUDA Toolkit");
                var path = getCudaPath();
                writer.WriteLine("CUDA_PATH?=\"{0}\"", path);

                // NVCC.
                writer.WriteLine("NVCC:= $(CUDA_PATH)/bin/nvcc -ccbin $(CPP_COMPILER)");

                writer.WriteLine("");
            }
        }
Пример #6
0
        /// <summary>
        /// Creates a makefile for the project passed in.
        /// </summary>
        private static void createProjectMakefile(ProjectInfo projectInfo, ProjectInfo_CUDA projectInfoCuda)
        {
            // Are we ignoring this project?
            if (MakeItSoConfig.Instance.ignoreProject(projectInfo.Name) == true)
            {
                return;
            }

            // We build a different makefile, depending on the
            // project type...
            if (projectInfo is ProjectInfo_CPP)
            {
                MakefileBuilder_Project_CPP.createMakefile(projectInfo as ProjectInfo_CPP, projectInfoCuda);
            }
            if (projectInfo is ProjectInfo_CSharp)
            {
                MakefileBuilder_Project_CSharp.createMakefile(projectInfo as ProjectInfo_CSharp);
            }
        }
Пример #7
0
        public static void createFileTargets(
            StreamWriter writer,
            ProjectInfo_CPP projectInfo,
            ProjectConfigurationInfo_CPP configurationInfo,
            ProjectInfo_CUDA projectCudaInfo)
        {
            if (!projectCudaInfo.IsCUDA)
            {
                return;
            }

            var includePath             = String.Format("$({0})", MakefileBuilder_Project_CPP.getIncludePathVariableName(configurationInfo));
            var preprocessorDefinitions = String.Format("$({0})", MakefileBuilder_Project_CPP.getPreprocessorDefinitionsVariableName(configurationInfo));
            var intermediateFolder      = MakefileBuilder_Project_CPP.getIntermediateFolder(projectInfo, configurationInfo);

            var projectSettings = MakeItSoConfig.Instance.getProjectConfig(projectInfo.Name);

            foreach (var info in projectCudaInfo.CompileInfos)
            {
                var filename = info.File;

                if (projectSettings.filesOrDirectoriesShouldBeRemoved(filename))
                {
                    continue;
                }

                var    opt          = info.getOption(configurationInfo.Name);
                string compileFlags = getCudaCompileFlags(configurationInfo, opt);

                string path = String.Format("{0}/{1}", intermediateFolder, filename);
                if (filename.StartsWith(".."))
                {
                    var tmp = filename.Replace("../", "");
                    path = String.Format("{0}/{1}", intermediateFolder, tmp);
                }
                string objectPath = Path.ChangeExtension(path, ".o");

                writer.WriteLine("# Compiles file {0} for the {1} configuration...", filename, configurationInfo.Name);
                writer.WriteLine("{0}: {1}", objectPath, filename);
                writer.WriteLine("\t$(NVCC) {0} {1} {2} -c {3} -o {4}", compileFlags, includePath, preprocessorDefinitions, filename, objectPath);
                writer.WriteLine("");
            }
        }
 /// <summary>
 /// We create a makefile for the project passed in.
 /// </summary>
 public static void createMakefile(ProjectInfo_CPP project, ProjectInfo_CUDA projectInfoCuda)
 {
     new MakefileBuilder_Project_CPP(project, projectInfoCuda);
 }