Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9296973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:57:17+00:00 2026-06-18T21:57:17+00:00

I made a macro to simplify CUDA kernel calls: #define LAUNCH LAUNCH_ASYNC #define LAUNCH_ASYNC(kernel_name,

  • 0

I made a macro to simplify CUDA kernel calls:

#define LAUNCH LAUNCH_ASYNC

#define LAUNCH_ASYNC(kernel_name, gridsize, blocksize, ...) \
    LOG("Async kernel launch: " #kernel_name);              \
    kernel_name <<< (gridsize), (blocksize) >>> (__VA_ARGS__);

#define LAUNCH_SYNC(kernel_name, gridsize, blocksize, ...)     \
    LOG("Sync kernel launch: " #kernel_name);                  \
    kernel_name <<< (gridsize), (blocksize) >>> (__VA_ARGS__); \
    cudaDeviceSynchronize();                                   \
    // error check, etc...

Usage:

LAUNCH(my_kernel, 32, 32, param1, param2)

LAUNCH(my_kernel<int>, 32, 32, param1, param2)

This works fine; with the first define I can enable synronous calls and error checking for debugging.

However it does not work with multiple template arguments like below:

LAUNCH(my_kernel<int,float>, 32, 32, param1, param3)

The error message I get in the line where I call the macro:

error : expected a ">"

Is it possible to make this macro work with multiple template arguments?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T21:57:19+00:00Added an answer on June 18, 2026 at 9:57 pm

    The problem is that the preprocessor knows nothing about angle bracket nesting, so it interprets the comma between them as macro argument separator.

    If the kernel-launch syntax supports parentheses around the kernel name (I can’t check now, not on a CUDA machine), you could do this:

    LAUNCH((my_kernel<int, float>), 32, 32, param1, param3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading an article where #define macro was made like this: #define TEST(level)
I have made a minor change to an Excel macro, and although it worked
I am trying to craft a macro replacing newlines. My first try was: define(`m4_pascal_str',`
I made an Outlook macro. How can I deploy it to use it on
I have made some small macro that I am using to display text line
At work, I have made a macro to format and chart out data that
#define boo(fmt, ...) SomethingToDo(fmt, __VA_ARGS__) void foo(PCSTR fmt, ...) { // some other codes
Hi I'm using office 2007 and I made a macro in ppt what opens
I made and tested this macro in Excel 2010 on Windows 7, also tested
I have an Excel 2010 macro application that is made up of several workbook

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.