Skip to content

Commit aa4383a

Browse files
authored
Merge pull request #74 from oneapi-src/ratul/cudasift/inputdataloc
[cudasift] command line option for input data loc
2 parents 34ee4eb + caef0fd commit aa4383a

File tree

9 files changed

+173
-15
lines changed

9 files changed

+173
-15
lines changed

cudaSift/CUDA/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,17 @@ set(cuda_sources
5252

5353
set(sources
5454
${CMAKE_SOURCE_DIR}/../common/Utility.cpp
55+
${CMAKE_SOURCE_DIR}/../common/workload_params.cpp
56+
${CMAKE_SOURCE_DIR}/../../infrastructure/CommandLineParser.cpp
57+
${CMAKE_SOURCE_DIR}/../../infrastructure/TestBenchBase.cpp
58+
${CMAKE_SOURCE_DIR}/../../infrastructure/Utilities.cpp
5559
geomFuncs.cpp
5660
mainSift.cpp
5761
)
5862

5963
include_directories(
6064
${CMAKE_SOURCE_DIR}/../common/
65+
${CMAKE_SOURCE_DIR}/../../infrastructure
6166
${CMAKE_CURRENT_SOURCE_DIR}
6267
)
6368
if(DEVICE_TIMER)

cudaSift/CUDA/mainSift.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#include "Utility.h"
3939
#include "cudaImage.h"
4040
#include "cudaSift.h"
41+
#include "../common/workload_params.h"
42+
#include "Utilities.h"
43+
#include "CommandLineParser.h"
4144

4245
int ImproveHomography(SiftData &data, float *homography, int numLoops, float minScore, float maxAmbiguity, float thresh);
4346
void PrintMatchData(SiftData &siftData1, SiftData &siftData2, CudaImage &img);
@@ -48,7 +51,7 @@ double ScaleUp(CudaImage &res, CudaImage &src);
4851
///////////////////////////////////////////////////////////////////////////////
4952
// Main program
5053
///////////////////////////////////////////////////////////////////////////////
51-
int main(int argc, char **argv)
54+
int main(int argc, const char **argv)
5255
{
5356
auto totalProgTimer_start = std::chrono::steady_clock::now();
5457
int devNum = 0, imgSet = 0;
@@ -57,6 +60,9 @@ int main(int argc, char **argv)
5760
if (argc > 2)
5861
imgSet = std::atoi(argv[2]);
5962

63+
common::WorkloadParams workload_params(argc, argv);
64+
std::string inputDataLoc = workload_params.getInputDataLoc();
65+
6066
float totTime = 0.0;
6167
float imageInitTime = 0.0;
6268
float extractSiftTime = 0.0;
@@ -78,13 +84,13 @@ int main(int argc, char **argv)
7884
std::string inp_file_1, inp_file_2;
7985
if (imgSet)
8086
{
81-
inp_file_1 = "../../inputData/left.pgm";
82-
inp_file_2 = "../../inputData/righ.pgm";
87+
inp_file_1 = inputDataLoc + "/left.pgm";
88+
inp_file_2 = inputDataLoc + "/righ.pgm";
8389
}
8490
else
8591
{
86-
inp_file_1 = "../../inputData/img1.png";
87-
inp_file_2 = "../../inputData/img2.png";
92+
inp_file_1 = inputDataLoc + "/img1.png";
93+
inp_file_2 = inputDataLoc + "/img2.png";
8894
}
8995

9096
if (!std::filesystem::exists(inp_file_1))

cudaSift/HIP/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ include_directories(${OpenCV_INCLUDE_DIRS})
5757

5858
set(SOURCES
5959
${CMAKE_SOURCE_DIR}/../common/Utility.cpp
60+
${CMAKE_SOURCE_DIR}/../common/workload_params.cpp
61+
${CMAKE_SOURCE_DIR}/../../infrastructure/CommandLineParser.cpp
62+
${CMAKE_SOURCE_DIR}/../../infrastructure/TestBenchBase.cpp
63+
${CMAKE_SOURCE_DIR}/../../infrastructure/Utilities.cpp
6064
cudaImage.cpp
6165
cudaImage.h
6266
cudaSiftH.cpp
@@ -71,6 +75,7 @@ set(SOURCES
7175

7276
include_directories(
7377
${CMAKE_SOURCE_DIR}/../common/
78+
${CMAKE_SOURCE_DIR}/../../infrastructure
7479
${CMAKE_CURRENT_SOURCE_DIR}
7580
${HIP_INCLUDE_DIRS}
7681
)

cudaSift/HIP/mainSift.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#include "Utility.h"
3939
#include "cudaImage.h"
4040
#include "cudaSift.h"
41+
#include "../common/workload_params.h"
42+
#include "Utilities.h"
43+
#include "CommandLineParser.h"
4144

4245
int ImproveHomography(SiftData &data, float *homography, int numLoops, float minScore, float maxAmbiguity, float thresh);
4346
void PrintMatchData(SiftData &siftData1, SiftData &siftData2, CudaImage &img);
@@ -48,7 +51,7 @@ double ScaleUp(CudaImage &res, CudaImage &src);
4851
///////////////////////////////////////////////////////////////////////////////
4952
// Main program
5053
///////////////////////////////////////////////////////////////////////////////
51-
int main(int argc, char **argv)
54+
int main(int argc, const char **argv)
5255
{
5356
auto totalProgTimer_start = std::chrono::steady_clock::now();
5457
int devNum = 0, imgSet = 0;
@@ -57,6 +60,9 @@ int main(int argc, char **argv)
5760
if (argc > 2)
5861
imgSet = std::atoi(argv[2]);
5962

63+
common::WorkloadParams workload_params(argc, argv);
64+
std::string inputDataLoc = workload_params.getInputDataLoc();
65+
6066
float totTime = 0.0;
6167
float imageInitTime = 0.0;
6268
float extractSiftTime = 0.0;
@@ -78,13 +84,13 @@ int main(int argc, char **argv)
7884
std::string inp_file_1, inp_file_2;
7985
if (imgSet)
8086
{
81-
inp_file_1 = "../../inputData/left.pgm";
82-
inp_file_2 = "../../inputData/righ.pgm";
87+
inp_file_1 = inputDataLoc + "/left.pgm";
88+
inp_file_2 = inputDataLoc + "/righ.pgm";
8389
}
8490
else
8591
{
86-
inp_file_1 = "../../inputData/img1.png";
87-
inp_file_2 = "../../inputData/img2.png";
92+
inp_file_1 = inputDataLoc + "/img1.png";
93+
inp_file_2 = inputDataLoc + "/img2.png";
8894
}
8995

9096
if (!std::filesystem::exists(inp_file_1))

cudaSift/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,15 @@ ONEAPI_DEVICE_SELECTOR=hip:* ./cudaSift
9090
**To run hip version**
9191

9292
./cudasift
93+
94+
95+
96+
97+
***NOTE: Regarding default input files location:***
98+
99+
Input files for this workload are located at cudaSift/inputData by default. \
100+
If this needs to be changed, please use the following command line argument to provide the path of a different location:
101+
102+
./cudasift **-input_data_loc** <INPUT_FILES_DIR>
103+
104+

cudaSift/SYCL/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ endif()
5555

5656
set(SOURCES
5757
${CMAKE_SOURCE_DIR}/../common/Utility.cpp
58+
${CMAKE_SOURCE_DIR}/../common/workload_params.cpp
59+
${CMAKE_SOURCE_DIR}/../../infrastructure/CommandLineParser.cpp
60+
${CMAKE_SOURCE_DIR}/../../infrastructure/TestBenchBase.cpp
61+
${CMAKE_SOURCE_DIR}/../../infrastructure/Utilities.cpp
5862
cudaImage.dp.cpp
5963
cudaImage.h
6064
cudaSiftH.dp.cpp
@@ -68,6 +72,7 @@ set(SOURCES
6872

6973
include_directories(
7074
${CMAKE_SOURCE_DIR}/../common/
75+
${CMAKE_SOURCE_DIR}/../../infrastructure
7176
${CMAKE_SOURCE_DIR}
7277
${OpenCV_INCLUDE_DIRS}
7378
)

cudaSift/SYCL/mainSift.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#include "cudaSift.h"
3939
#include "infra/infra.hpp"
4040
#include "Utility.h"
41+
#include "../common/workload_params.h"
42+
#include "Utilities.h"
43+
#include "CommandLineParser.h"
4144

4245
#ifndef KERNEL_USE_PROFILE
4346
#define KERNEL_USE_PROFILE 0
@@ -53,7 +56,7 @@ double ScaleUp(CudaImage &res, CudaImage &src);
5356
///////////////////////////////////////////////////////////////////////////////
5457
// Main program
5558
///////////////////////////////////////////////////////////////////////////////
56-
int main(int argc, char **argv)
59+
int main(int argc, const char **argv)
5760
{
5861
auto totalProgTimer_start = std::chrono::steady_clock::now();
5962
int devNum = 0, imgSet = 0;
@@ -62,6 +65,9 @@ int main(int argc, char **argv)
6265
if (argc > 2)
6366
imgSet = std::atoi(argv[2]);
6467

68+
common::WorkloadParams workload_params(argc, argv);
69+
std::string inputDataLoc = workload_params.getInputDataLoc();
70+
6571
float totTime = 0.0;
6672
float imageInitTime = 0.0;
6773
float extractSiftTime = 0.0;
@@ -91,13 +97,13 @@ int main(int argc, char **argv)
9197
std::string inp_file_1, inp_file_2;
9298
if (imgSet)
9399
{
94-
inp_file_1 = "../../inputData/left.pgm";
95-
inp_file_2 = "../../inputData/righ.pgm";
100+
inp_file_1 = inputDataLoc + "/left.pgm";
101+
inp_file_2 = inputDataLoc + "/righ.pgm";
96102
}
97103
else
98104
{
99-
inp_file_1 = "../../inputData/img1.png";
100-
inp_file_2 = "../../inputData/img2.png";
105+
inp_file_1 = inputDataLoc + "/img1.png";
106+
inp_file_2 = inputDataLoc + "/img2.png";
101107
}
102108

103109
if (!std::filesystem::exists(inp_file_1))

cudaSift/common/workload_params.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* Copyright (C) 2023 Intel Corporation
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"),
5+
* to deal in the Software without restriction, including without limitation
6+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+
* and/or sell copies of the Software, and to permit persons to whom
8+
* the Software is furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included
11+
* in all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
17+
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19+
* OR OTHER DEALINGS IN THE SOFTWARE.
20+
*
21+
* SPDX-License-Identifier: MIT
22+
*/
23+
24+
#include "CommandLineParser.h"
25+
#include "TestBenchBase.h"
26+
#include "Logging.h"
27+
#include "workload_params.h"
28+
#include <iostream>
29+
#include <vector>
30+
#include <string>
31+
#include <algorithm>
32+
33+
//#define CPP_MODULE "WL PARAMS"
34+
35+
using namespace std;
36+
37+
namespace common {
38+
WorkloadParams::WorkloadParams(int argc, const char** argv): TestBenchBase()
39+
{
40+
bool bRequired(true);
41+
VelocityBench::CommandLineParser &parser = GetCmdLineParser();
42+
parser.AddSetting("-input_data_loc", "Input data location", !bRequired, "../../inputData", VelocityBench::CommandLineParser::InputType_t::STRING, 1);
43+
44+
ParseCommandLineArguments(argc, argv);
45+
parseInputParameters(parser);
46+
}
47+
48+
void WorkloadParams::parseInputParameters(const VelocityBench::CommandLineParser& parser) {
49+
inputDataLoc = parser.GetSetting("-input_data_loc");
50+
51+
LOG( "\n");
52+
LOG( "==================================================");
53+
LOG("User input parameters:");
54+
LOG("Trace: " << inputDataLoc);
55+
LOG( "==================================================");
56+
LOG( "\n");
57+
}
58+
}

cudaSift/common/workload_params.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* Copyright (C) 2023 Intel Corporation
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"),
5+
* to deal in the Software without restriction, including without limitation
6+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+
* and/or sell copies of the Software, and to permit persons to whom
8+
* the Software is furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included
11+
* in all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
17+
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19+
* OR OTHER DEALINGS IN THE SOFTWARE.
20+
*
21+
* SPDX-License-Identifier: MIT
22+
*/
23+
24+
#ifndef CUDASIFT_WL_PARAMS_H
25+
#define CUDASIFT_WL_PARAMS_H
26+
27+
#include "TestBenchBase.h"
28+
#include <string>
29+
30+
using namespace std;
31+
32+
namespace common {
33+
class WorkloadParams : public TestBenchBase
34+
{
35+
public:
36+
37+
private:
38+
string inputDataLoc;
39+
40+
public:
41+
WorkloadParams(int argc, const char** argv);
42+
~WorkloadParams(){;}
43+
44+
//WorkloadParams (WorkloadParams const &RHS) = delete;
45+
//WorkloadParams &operator=(WorkloadParams const &RHS) = delete;
46+
void initializeCmdParser();
47+
string getInputDataLoc() { return inputDataLoc;}
48+
49+
private:
50+
void parseInputParameters(const VelocityBench::CommandLineParser& parser);
51+
52+
};
53+
}
54+
55+
#endif

0 commit comments

Comments
 (0)