Skip to content

Commit

Permalink
Basic Windows support for OpenCL samples
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-v-gorshkov committed Nov 17, 2021
1 parent 2f55ed9 commit a791cf9
Show file tree
Hide file tree
Showing 52 changed files with 489 additions and 520 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.40.1
0.40.3
4 changes: 3 additions & 1 deletion build_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ macro(SetRequiredCMakeVersion)
endmacro()

macro(RequirePythonInterp)
if(NOT DEFINED PYTHON_EXECUTABLE)
if(NOT DEFINED _Python_EXECUTABLE)
find_package(Python COMPONENTS Interpreter REQUIRED)
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
else()
set(PYTHON_EXECUTABLE "${_Python_EXECUTABLE}")
endif()
endmacro()

Expand Down
2 changes: 1 addition & 1 deletion samples/cl_debug_info/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ As a result, listing like the following will be printed for each kernel (once pe
```
## Supported OS
- Linux
- Windows (*under development*)
- Windows

## Prerequisites
- [CMake](https://cmake.org/) (version 3.12 and above)
Expand Down
2 changes: 1 addition & 1 deletion samples/cl_gemm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Total execution time: 0.739879 sec
```
## Supported OS
- Linux
- Windows (*under development*)
- Windows

## Prerequisites
- [CMake](https://cmake.org/) (version 3.12 and above)
Expand Down
2 changes: 1 addition & 1 deletion samples/cl_gemm_inst/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Estimated total number of HW threads: 336
```
## Supported OS
- Linux
- Windows (*under development*)
- Windows

## Prerequisites
- [CMake](https://cmake.org/) (version 3.12 and above)
Expand Down
2 changes: 1 addition & 1 deletion samples/cl_gemm_itt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Total execution time: 0.739879 sec
```
## Supported OS
- Linux
- Windows (*under development*)
- Windows

## Prerequisites
- [CMake](https://cmake.org/) (version 3.12 and above)
Expand Down
2 changes: 1 addition & 1 deletion samples/cl_gpu_metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To set target device and sub-device to collect metrics from one can specify `PTI

## Supported OS
- Linux
- Windows (*under development*)
- Windows

## Prerequisites
- [CMake](https://cmake.org/) (version 3.12 and above)
Expand Down
2 changes: 1 addition & 1 deletion samples/cl_gpu_query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To set target device and sub-device to collect metrics from one can specify `PTI

## Supported OS
- Linux
- Windows (*under development*)
- Windows

## Prerequisites
- [CMake](https://cmake.org/) (version 3.12 and above)
Expand Down
4 changes: 2 additions & 2 deletions samples/cl_hot_functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ clCreateCommandQueueWithProperties, 1, 1388, 0.00,
```
## Supported OS
- Linux
- Windows (*under development*)
- Windows

## Prerequisites
- [CMake](https://cmake.org/) (version 3.12 and above)
Expand Down Expand Up @@ -86,5 +86,5 @@ cl_hot_functions.exe <target_application>
One may use [cl_gemm](../cl_gemm) or [dpc_gemm](../dpc_gemm) as target application:
```sh
cl_hot_functions.exe ..\..\cl_gemm\build\cl_gemm.exe
cl_hot_functions.exe ..\..\dpc_gemm\build\dpc_gemm.exe cpu
cl_hot_functions.exe ..\..\dpc_gemm\build\Release\dpc_gemm.exe cpu
```
4 changes: 2 additions & 2 deletions samples/cl_hot_kernels/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Total Device Time for GPU (ns): 174828332
```
## Supported OS
- Linux
- Windows (*under development*)
- Windows

## Prerequisites
- [CMake](https://cmake.org/) (version 3.12 and above)
Expand Down Expand Up @@ -62,5 +62,5 @@ cl_hot_kernels.exe <target_application>
One may use [cl_gemm](../cl_gemm) or [dpc_gemm](../dpc_gemm) as target application:
```sh
cl_hot_kernels.exe ..\..\cl_gemm\build\cl_gemm.exe
cl_hot_kernels.exe ..\..\dpc_gemm\build\dpc_gemm.exe cpu
cl_hot_kernels.exe ..\..\dpc_gemm\build\Release\dpc_gemm.exe cpu
```
2 changes: 1 addition & 1 deletion samples/cl_hot_kernels/cl_kernel_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class ClKernelCollector {
kernel.min_time = time;
}
kernel.call_count += 1;
kernel.simd_width = std::max(kernel.simd_width, simd_width);
kernel.simd_width = (std::max)(kernel.simd_width, simd_width);
}
}

Expand Down
3 changes: 2 additions & 1 deletion samples/dpc_gemm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ SetRequiredCMakeVersion()
cmake_minimum_required(VERSION ${REQUIRED_CMAKE_VERSION})

if(WIN32)
set(CMAKE_CXX_COMPILER "dpcpp.exe")
set(CMAKE_CXX_COMPILER "dpcpp-cl.exe")
set(CMAKE_GENERATOR_TOOLSET "Intel(R) oneAPI DPC++ Compiler")
else()
set(CMAKE_CXX_COMPILER "dpcpp")
endif()
Expand Down
8 changes: 5 additions & 3 deletions samples/dpc_gemm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Total execution time: 0.373728 sec
```
## Supported OS
- Linux
- Windows (*under development*)
- Windows

## Prerequisites
- [CMake](https://cmake.org/) (version 3.12 and above)
Expand All @@ -39,16 +39,18 @@ Use this command line to run the application:
```sh
./dpc_gemm [cpu|gpu|host] [matrix_size] [repeat_count]
```
### Windows (manual build)
### Windows
Use Microsoft* Visual Studio x64 command prompt to run the following commands and build the sample (make sure you have oneAPI DPC++ Compiler in `PATH` for building):
```sh
<inteloneapi>\setvars.bat
cd <pti>\samples\dpc_gemm
mkdir build
cd build
dpcpp [-O2|-O0 -g] ..\main.cc -I..\..\..\utils -o dpc_gemm.exe
cmake ..
cmake --build . --config Release
```
Use this command line to run the application:
```sh
cd Release
dpc_gemm.exe [cpu|gpu|host] [matrix_size] [repeats_count]
```
3 changes: 2 additions & 1 deletion samples/dpc_info/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ SetRequiredCMakeVersion()
cmake_minimum_required(VERSION ${REQUIRED_CMAKE_VERSION})

if(WIN32)
set(CMAKE_CXX_COMPILER "dpcpp.exe")
set(CMAKE_CXX_COMPILER "dpcpp-cl.exe")
set(CMAKE_GENERATOR_TOOLSET "Intel(R) oneAPI DPC++ Compiler")
else()
set(CMAKE_CXX_COMPILER "dpcpp")
endif()
Expand Down
8 changes: 5 additions & 3 deletions samples/dpc_info/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following modes are implemented:
## Supported OS
- Linux
- Windows (*under development*)
- Windows
## Prerequisites
- [CMake](https://cmake.org/) (version 3.12 and above)
Expand All @@ -65,16 +65,18 @@ Use this command line to run the utility:
```sh
./dpc_info [-l|-a]
```
### Windows (manual build)
### Windows
Use Microsoft* Visual Studio x64 command prompt to run the following commands and build the sample (make sure you have oneAPI DPC++ Compiler in `PATH` for building):
```sh
<inteloneapi>\setvars.bat
cd <pti>\samples\dpc_info
mkdir build
cd build
dpcpp [-O2|-O0 -g] ..\main.cc -o dpc_info.exe
cmake ..
cmake --build . --config Release
```
Use this command line to run the application:
```sh
cd Release
dpc_info.exe [-l|-a]
```
35 changes: 21 additions & 14 deletions tests/samples/cl_debug_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,38 @@
from samples import cl_gemm
import utils

if sys.platform == 'win32':
cmake_generator = "NMake Makefiles"
file_extention = ".exe"
file_name_prefix = ""
make = ["nmake"]
else:
cmake_generator = "Unix Makefiles"
file_extention = ""
file_name_prefix = "./"
make = ["make"]


def config(path):
p = subprocess.Popen(["cmake",\
"-DCMAKE_BUILD_TYPE=" + utils.get_build_flag(), ".."],\
cwd = path, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
p.wait()
stdout, stderr = utils.run_process(p)
cmake = ["cmake", "-G", cmake_generator,\
"-DCMAKE_BUILD_TYPE=" + utils.get_build_flag(), ".."]
stdout, stderr = utils.run_process(cmake, path)
if stderr and stderr.find("CMake Error") != -1:
return stderr
return None

def build(path):
p = subprocess.Popen(["make"], cwd = path,\
stdout = subprocess.PIPE, stderr = subprocess.PIPE)
p.wait()
stdout, stderr = utils.run_process(p)
stdout, stderr = utils.run_process(make, path)
if stderr and stderr.lower().find("error") != -1:
return stderr
return None

def run(path):
app_folder = utils.get_sample_build_path("cl_gemm")
app_file = os.path.join(app_folder, "cl_gemm")
p = subprocess.Popen(["./cl_debug_info", app_file, "gpu", "1024", "1"],
cwd = path, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
stdout, stderr = utils.run_process(p)
app_folder = utils.get_sample_executable_path("cl_gemm")
app_file = os.path.join(app_folder, "cl_gemm" + file_extention)
command = [file_name_prefix + "cl_debug_info" + file_extention,\
app_file, "gpu", "1024", "1"]
stdout, stderr = utils.run_process(command, path)
if not stdout:
return "stdout is empty"
if not stderr:
Expand Down
31 changes: 19 additions & 12 deletions tests/samples/cl_gemm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,36 @@

import utils

if sys.platform == 'win32':
cmake_generator = "NMake Makefiles"
file_extention = ".exe"
file_name_prefix = ""
make = ["nmake"]
else:
cmake_generator = "Unix Makefiles"
file_extention = ""
file_name_prefix = "./"
make = ["make"]


def config(path):
p = subprocess.Popen(["cmake",\
"-DCMAKE_BUILD_TYPE=" + utils.get_build_flag(), ".."],\
cwd = path, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
p.wait()
stdout, stderr = utils.run_process(p)
cmake = ["cmake", "-G", cmake_generator,\
"-DCMAKE_BUILD_TYPE=" + utils.get_build_flag(), ".."]
stdout, stderr = utils.run_process(cmake, path)
if stderr and stderr.find("CMake Error") != -1:
return stderr
return None

def build(path):
p = subprocess.Popen(["make"], cwd = path,\
stdout = subprocess.PIPE, stderr = subprocess.PIPE)
p.wait()
stdout, stderr = utils.run_process(p)
stdout, stderr = utils.run_process(make, path)
if stderr and stderr.lower().find("error") != -1:
return stderr
return None

def run(path, option):
p = subprocess.Popen(["./cl_gemm", option, "1024", "1"],\
cwd = path, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
stdout, stderr = utils.run_process(p)
command = [file_name_prefix + "cl_gemm" + file_extention,\
option, "1024", "1"]
stdout, stderr = utils.run_process(command, path)
if stderr:
return stderr
if not stdout:
Expand Down
31 changes: 19 additions & 12 deletions tests/samples/cl_gemm_inst.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,28 @@

import utils

if sys.platform == 'win32':
cmake_generator = "NMake Makefiles"
file_extention = ".exe"
file_name_prefix = ""
make = ["nmake"]
else:
cmake_generator = "Unix Makefiles"
file_extention = ""
file_name_prefix = "./"
make = ["make"]


def config(path):
p = subprocess.Popen(["cmake",\
"-DCMAKE_BUILD_TYPE=" + utils.get_build_flag(), ".."],\
cwd = path, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
p.wait()
stdout, stderr = utils.run_process(p)
cmake = ["cmake", "-G", cmake_generator,\
"-DCMAKE_BUILD_TYPE=" + utils.get_build_flag(), ".."]
stdout, stderr = utils.run_process(cmake, path)
if stderr and stderr.find("CMake Error") != -1:
return stderr
return None

def build(path):
p = subprocess.Popen(["make"], cwd = path,\
stdout = subprocess.PIPE, stderr = subprocess.PIPE)
p.wait()
stdout, stderr = utils.run_process(p)
stdout, stderr = utils.run_process(make, path)
if stderr and stderr.lower().find("error") != -1:
return stderr
return None
Expand All @@ -37,9 +44,9 @@ def parse(stdout):
return False

def run(path):
p = subprocess.Popen(["./cl_gemm_inst", "1024", "1"],\
cwd = path, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
stdout, stderr = utils.run_process(p)
command = [file_name_prefix + "cl_gemm_inst" + file_extention,\
"1024", "1"]
stdout, stderr = utils.run_process(command, path)
if stderr:
return stderr
if not stdout:
Expand Down
31 changes: 19 additions & 12 deletions tests/samples/cl_gemm_itt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,36 @@

import utils

if sys.platform == 'win32':
cmake_generator = "NMake Makefiles"
file_extention = ".exe"
file_name_prefix = ""
make = ["nmake"]
else:
cmake_generator = "Unix Makefiles"
file_extention = ""
file_name_prefix = "./"
make = ["make"]


def config(path):
p = subprocess.Popen(["cmake",\
"-DCMAKE_BUILD_TYPE=" + utils.get_build_flag(), ".."],\
cwd = path, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
p.wait()
stdout, stderr = utils.run_process(p)
cmake = ["cmake", "-G", cmake_generator,\
"-DCMAKE_BUILD_TYPE=" + utils.get_build_flag(), ".."]
stdout, stderr = utils.run_process(cmake, path)
if stderr and stderr.find("CMake Error") != -1:
return stderr
return None

def build(path):
p = subprocess.Popen(["make"], cwd = path,\
stdout = subprocess.PIPE, stderr = subprocess.PIPE)
p.wait()
stdout, stderr = utils.run_process(p)
stdout, stderr = utils.run_process(make, path)
if stderr and stderr.lower().find("error") != -1:
return stderr
return None

def run(path, option):
p = subprocess.Popen(["./cl_gemm_itt", option, "1024", "1"],\
cwd = path, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
stdout, stderr = utils.run_process(p)
command = [file_name_prefix + "cl_gemm_itt" + file_extention,\
option, "1024", "1"]
stdout, stderr = utils.run_process(command, path)
if stderr:
return stderr
if not stdout:
Expand Down
Loading

0 comments on commit a791cf9

Please sign in to comment.