| 52 | #endif // _MSC_VER |
| 53 | |
| 54 | bool Program::Build() |
| 55 | { |
| 56 | if (m_Built) |
| 57 | return true; |
| 58 | |
| 59 | string Path, Source = m_Source; |
| 60 | |
| 61 | if (Source == "") |
| 62 | { |
| 63 | if (m_Path == "") |
| 64 | return false; |
| 65 | |
| 66 | Path = m_CL->GetClFilePath() + m_Path; |
| 67 | |
| 68 | Source = LoadClFile(Path); |
| 69 | } |
| 70 | |
| 71 | m_Program = cl::Program(*m_CL, Source, false); |
| 72 | |
| 73 | string optionStr = m_Options; |
| 74 | |
| 75 | if (m_Path != "" && IsDebuggerPresent() && |
| 76 | m_CL->GetPlatformType() == COpenCL::IntelPlatform && m_CL->GetDeviceType() == CL_DEVICE_TYPE_CPU) |
| 77 | { |
| 78 | // Add debug information for Intel OpenCL SDK Debugger |
| 79 | optionStr += " -g -s \"" + Path + "\""; |
| 80 | } |
| 81 | |
| 82 | |
| 83 | // Add include path |
| 84 | optionStr += " -I " + m_CL->GetClFilePath(); // The path must not have spaces if using NVIDIA platform |
| 85 | |
| 86 | // Try to build |
| 87 | try |
| 88 | { |
| 89 | m_Program.build(optionStr.c_str()); |
| 90 | m_Built = true; |
| 91 | } |
| 92 | catch (cl::Error error) |
| 93 | { |
| 94 | // Build failed |
| 95 | |
| 96 | string build_info; |
| 97 | m_Program.getBuildInfo(*m_CL, CL_PROGRAM_BUILD_LOG, &build_info); |
| 98 | |
| 99 | cerr << "Program build failed : " << build_info << endl; |
| 100 | if (Path != "") |
| 101 | cerr << " - in file : " << Path << endl; |
| 102 | |
| 103 | throw error; // Rethrow |
| 104 | } |
| 105 | |
| 106 | return true; |
| 107 | } |
| 108 | |
| 109 | std::string Program::LoadClFile(const std::string& Path) |
| 110 | { |
no test coverage detected