-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from Polytonic/development
Add Windows Support
- Loading branch information
Showing
8 changed files
with
151 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cmake --build . --target tests | ||
pushd Debug | ||
tests.exe | ||
popd | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,39 @@ | ||
// Include the Chlorine Header | ||
#include "chlorine.hpp" | ||
int main() | ||
|
||
// Visual Studio has trouble finding files on disk because the working directory | ||
// is not set using CMake. For the purposes of having a "clone and play" sample, | ||
// that runs on every platform, I have hard-coded the sample kernel here. | ||
static const char* kernel = | ||
"__kernel void swap(__global float * spam, __global float * eggs)" | ||
"{" | ||
" unsigned int i = get_global_id(0);" | ||
" float swap = spam[i];" | ||
" spam[i] = eggs[i];" | ||
" eggs[i] = swap;" | ||
"}" | ||
; | ||
|
||
// Slightly Modified Sample Code from Readme | ||
int main(int argc, char * argv[]) | ||
{ | ||
std::cout << "Hello World\n"; | ||
return 0; | ||
} | ||
// Create Some Data | ||
std::vector<float> spam(10, 3.1415f); | ||
std::vector<float> eggs(10, 2.7182f); | ||
|
||
// Initialize a Chlorine Worker | ||
ch::Worker worker; | ||
|
||
// Build the OpenCL Kernel | ||
worker.build_kernel(kernel); | ||
|
||
// Call the Swap Function in the Given Kernel | ||
auto event = worker.call("swap", spam, eggs); | ||
|
||
// Host Containers Are Automatically Updated | ||
std::cout << "Spam: " << spam[0] << "\n"; // 2.7182 | ||
std::cout << "Eggs: " << eggs[0] << "\n"; // 3.1415 | ||
|
||
// Print Some Profiling Data | ||
std::cout << "Elapsed Time: " << ch::elapsed(event) << "ns\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters