mirror of
https://github.com/andreinechaev/nvcc4jupyter.git
synced 2026-06-14 03:00:47 +05:30
Create separate files for blur kernel and the error handling macro to make the main function more readable
This commit is contained in:
@@ -187,26 +187,10 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"colab": {
|
|
||||||
"base_uri": "https://localhost:8080/"
|
|
||||||
},
|
|
||||||
"id": "hhkNS3HJlFlC",
|
|
||||||
"outputId": "bb0b3fad-f132-4a26-e247-32bf5e29c1a4"
|
|
||||||
},
|
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%%cuda --compiler-args \"$COMPILER_ARGS\"\n",
|
"%%cuda_group_save -n \"error_handling.h\" -g \"shared\"\n",
|
||||||
"\n",
|
|
||||||
"#include <opencv2/core.hpp>\n",
|
|
||||||
"#include <opencv2/imgcodecs.hpp>\n",
|
|
||||||
"\n",
|
|
||||||
"#include <iostream>\n",
|
|
||||||
"\n",
|
|
||||||
"#define BLUR_SIZE 5\n",
|
|
||||||
"#define R 0\n",
|
|
||||||
"#define G 1\n",
|
|
||||||
"#define B 2\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"// error checking macro\n",
|
"// error checking macro\n",
|
||||||
"#define cudaCheckErrors(msg) \\\n",
|
"#define cudaCheckErrors(msg) \\\n",
|
||||||
@@ -219,7 +203,18 @@
|
|||||||
" fprintf(stderr, \"*** FAILED - ABORTING\\n\"); \\\n",
|
" fprintf(stderr, \"*** FAILED - ABORTING\\n\"); \\\n",
|
||||||
" exit(1); \\\n",
|
" exit(1); \\\n",
|
||||||
" } \\\n",
|
" } \\\n",
|
||||||
" } while (0)\n",
|
" } while (0)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%%cuda_group_save -n \"blur_kernel.h\" -g \"shared\"\n",
|
||||||
|
"\n",
|
||||||
|
"#define BLUR_SIZE 5\n",
|
||||||
"\n",
|
"\n",
|
||||||
"// kernel taken from https://stackoverflow.com/a/65973288\n",
|
"// kernel taken from https://stackoverflow.com/a/65973288\n",
|
||||||
"__global__ void blurKernel(\n",
|
"__global__ void blurKernel(\n",
|
||||||
@@ -249,7 +244,34 @@
|
|||||||
" }\n",
|
" }\n",
|
||||||
" out[row * width * num_channel + col * num_channel + channel] = (unsigned char)(pixVal/pixels);\n",
|
" out[row * width * num_channel + col * num_channel + channel] = (unsigned char)(pixVal/pixels);\n",
|
||||||
" }\n",
|
" }\n",
|
||||||
"}\n",
|
"}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"colab": {
|
||||||
|
"base_uri": "https://localhost:8080/"
|
||||||
|
},
|
||||||
|
"id": "hhkNS3HJlFlC",
|
||||||
|
"outputId": "bb0b3fad-f132-4a26-e247-32bf5e29c1a4"
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%%cuda --compiler-args \"$COMPILER_ARGS\"\n",
|
||||||
|
"\n",
|
||||||
|
"#include <iostream>\n",
|
||||||
|
"\n",
|
||||||
|
"#include <opencv2/core.hpp>\n",
|
||||||
|
"#include <opencv2/imgcodecs.hpp>\n",
|
||||||
|
"\n",
|
||||||
|
"#include \"error_handling.h\"\n",
|
||||||
|
"#include \"blur_kernel.h\"\n",
|
||||||
|
"\n",
|
||||||
|
"#define R 0\n",
|
||||||
|
"#define G 1\n",
|
||||||
|
"#define B 2\n",
|
||||||
"\n",
|
"\n",
|
||||||
"int main()\n",
|
"int main()\n",
|
||||||
"{\n",
|
"{\n",
|
||||||
@@ -354,7 +376,7 @@
|
|||||||
"kaggle": {
|
"kaggle": {
|
||||||
"accelerator": "nvidiaTeslaT4",
|
"accelerator": "nvidiaTeslaT4",
|
||||||
"dataSources": [],
|
"dataSources": [],
|
||||||
"dockerImageVersionId": 30699,
|
"dockerImageVersionId": 30716,
|
||||||
"isGpuEnabled": true,
|
"isGpuEnabled": true,
|
||||||
"isInternetEnabled": true,
|
"isInternetEnabled": true,
|
||||||
"language": "python",
|
"language": "python",
|
||||||
|
|||||||
Reference in New Issue
Block a user