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 9135909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:53:01+00:00 2026-06-17T08:53:01+00:00

INTRODUCTION In this question we can learn how to disable L1 cache for one

  • 0

INTRODUCTION

In this question we can learn how to disable L1 cache for one single variable.
Here is the accepted answer:

As mentioned above you can use inline PTX, here is an example:

__device__ __inline__ double ld_gbl_cg(const double *addr) {
  double return_value;
  asm("ld.global.cg.f64 %0, [%1];" : "=d"(return_value) : "l"(addr));
  return return_value;
}

You can easily vary this by swapping .f64 for .f32 (float) or .s32
(int) etc., the constraint of return_value “=d” for “=d” (float) or
“=r” (int) etc. Note that the last constraint before (addr) – “l” –
denotes 64 bit addressing, if you are using 32 bit addressing, it
should be “r”.

Now, I however, I want to load a boolean (1 byte) not a floating point. So, I thought that I could do something like this (for architecture >=sm_20):

__device__ inline bool ld_gbl_cg(const bool* addr){
  bool return_value;
  asm("ld.global.cg.u8 %0, [%1];" : "=???"(return_value) : "l"(addr));
  return return_value;
}

, where “???” should be the appropriate constraint letter for a boolean, respectively for an 8 bit unsinged integer (From this question, i deduced this, since it is noted that for >=sm_20, “u8” is used for a boolean). Howevever, I cannot find an appropriate constraint letter in nvidias document “Using inline PTX Assembly in CUDA” (On page 6 are listed some constraint letters). So my question is:

QUESTION

  1. Is there any CUDA inline PTX constraint letter for any of the types:

    • boolean
    • unsigned 8 bit integer
    • or evtl 8 bit binary variable
  2. If not, what can I do in my case (explained in the introduction)? – Can the parameters “b0”, “b1”, etc shortly discussed here, be of help?

Thank you very much in advance for any help or comments!

UPDATE

I also need a store function reading from L2 cache instead of global memory – i.e. the store function that is complementary to the above ld_gbl_cg function (only once I have this function, I can completely verify that njuffa’s answer works).
My best guess based on njuffa’s answer below would be:

__device__ __forceinline__ void st_gbl_cg (const bool *addr, bool t)
{
#if defined(__LP64__) || defined(_WIN64)
    asm ("st.global.cg.u8 [%0], %1;" : "=l"(addr) : "h"((short)t));
#else
    asm ("st.global.cg.u8 [%0], %1;" : "=r"(addr) : "h"((short)t));
#endif
}

However, the compiler gives the warning “parameter “addr” was set but never used” and the programm fails at runtime with an “unspecified launch failure”.
I also tried with .u16 instead of .u8, as I do not know to what exactly it refers. Yet the result is the same.

(Additional information) The following paragraph in the PTX 3.1 documentation, seems to be important for this question:

5.2.2 Restricted Use of Sub-Word Sizes The .u8, .s8, and .b8 instruction types are restricted to ld, st, and cvt instructions. The
.f16 floating-point type is allowed only in conversions to and from
.f32 and .f64 types. All floating-point instructions operate only on
.f32 and .f64 types. For convenience, ld, st, and cvt instructions
permit source and destination data operands to be wider than the
instruction-type size, so that narrow values may be loaded, stored,
and converted using regular-width registers. For example, 8-bit or
16-bit values may be held directly in 32-bit or 64-bit registers when
being loaded, stored, or converted to other types and sizes.

  • 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-17T08:53:02+00:00Added an answer on June 17, 2026 at 8:53 am

    According to the document “Using Inline PTX in CUDA”, there is no constraint for byte-sized operands. Best I can tell, the closest you can get to the desired functionality is to move the data through an intermediate ‘short’. This results in one additional SASS instruction for the conversion from ‘short’ to ‘bool’.

    __device__ __forceinline__ bool ld_gbl_cg (const bool *addr)
    {
        short t;
    #if defined(__LP64__) || defined(_WIN64)
        asm ("ld.global.cg.u8 %0, [%1];" : "=h"(t) : "l"(addr));
    #else
        asm ("ld.global.cg.u8 %0, [%1];" : "=h"(t) : "r"(addr));
    #endif
        return (bool)t;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Introduction I have a question coming from this one: Loop calling an asynchronous function
Introduction: Now I know this question could be very broad and it would be
This is quite a long introduction to a simple question, but otherwise there will
-> Short Introduction, you can SKIP this part I'm glad to be able to
Introduction I've a question about something that I think it can become a little
Introduction I know I'm going to lose a lot of reputation for this question
This feels like an extremely n00b question, but here goes... I have a series
With the introduction of the Portable Class Library , developers can release a single
Introduction: I asked this question on the P2-forum already but I couldnt get any
Newbie question here. I'm trying to teach myself, and sometimes the solo route can

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.